What do these successive cut commands do?
cut -f2 -d'"' | cut -f1 -d':'
What do these successive cut commands do?
cut -f2 -d'"' | cut -f1 -d':'
It means take the second field (-f2
) as separated by double quote marks (-d'"'
, which the shell parses to -d'
before running cut) , and then the first field (-f1
) of that as separated by colons (-d:
).
For instance, Phil Miller"developer:junior
will be processed to developer
. This is a very contrived example, and it would be useful to see what is actually being used as input to that pipeline.
The "-f" is the "field specifier" and the "-d" is the delimiter.
The command above says to first cut the line up using '"' as the delimiter and return back the 2nd field ('-f2'). The second command cuts up that result using the ':' delimiter and returns back the 1st field.
Cut is useful for parsing through csv-like files, which have potentially embedded delimiters.