Let's say I have a CSV file:col1,col2,col3col4,col5,subtext,col6The problem I have is as follows :cut -d, -f1,2 test.txtcoll1,col2col4,col5The desired output is :col1,col2col4,col5,subtext
Excluding enclosed delimiters with cut
shell script;text processing;cut
The ParseWords module, which ships with Perl, covers this quite elegantly.  Example below.$ perl -MText::ParseWords -nE '@a=quotewords ,,1,$_;say $a[0],,,$a[1]' <test.txtcol1,col2col4,col5,subtext$