Possible Duplicate:Is there a robust command line tool for processing csv files? I can use cut to extract columns from a file:$ cat foofoo,bar,hellobash,baz,world$ cut -d\, -f2 foobarbazBut what if a column has a delimiter in it that is safe inside an enclosure like this?$ cat foofoo,hello, world,barbash,goodbye,baz$ cut -d\, -f2 temp12hellogoodbyeIs there some way to tell cut to respect the enclosure of quote  characters?
Can you specify an enclosure for cut?
cut
cut could do it if you first preprocess its input to escape the characters inside the quotes (for instance, replace _ with _u and , with _c inside quotes, or replace every character with their 2-byte hex notation) and postprocess it to restore that escaping.Something like:perl -pe 's/(.*?)/\.unpack(H*, $1).\/ge' |  cut -d, -f2 |  perl -pe 's/(.*?)/\.pack(H*,$1).\/ge'(assuming there's no escaped quotes inside (or outside) the quotes).But, given the effort it would require, you might as well use a proper csv parser or do it whole with a perl-like regular expression engine.