How to get second last field from a cut command

awk, cut, unix

Solution

Got a hint from Unix cut except last two tokens and able to figure out the answer :

cat datafile | rev | cut -d '/' -f 2 | rev

Problem

I have a set of data as input and need the second last field based on deleimiter. The lines may have different numbers of delimiter. How can I get second last field ? example input ``` text,blah,blaah,foo this,is,another,text,line ``` expected output ``` blaah text ```

Original source

Related problems