[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cut feature request: treat multiple consecutive delimiters as one
From: |
Brandon Wood |
Subject: |
cut feature request: treat multiple consecutive delimiters as one |
Date: |
Tue, 26 Apr 2011 15:44:00 -0400 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
When dealing with stdout or delimited files that have multiple
consecutive delimiters, I think that allowing cut to treat these as a
single delimiter may be advantageous.
When considering a trivial example,
$ wc -l *.dat | grep data
1107 data_01.dat
180 data_02.dat
317 data_03.dat
295 data_04.dat
10 data_05.dat
$ !! | cut --mult-delim -d " " -f 1,2
1107 data_01.dat
180 data_02.dat
317 data_03.dat
295 data_04.dat
10 data_05.dat
Another example with a data file,
$ tail -n 3 data.dat
AAAA BBBB CCCC
1111 2222 3333
XXXX YYYY ZZZZ
$ !! | cut --mult-delim -d " " -f 2
BBBB
2222
YYYY
Obviously the flag can be something more suiting.
Though this may be more useful for those users dealing with large
delimited files that are not properly formatted to be cut, though more
creative folks may be able to use it in some more interesting ways.
While this may disturb files that have legitimately blank fields, it
would be off by default to avoid any problems. Treating multiple
delimiters as one is common in most spreadsheet applications when
importing delimited data.
Any thoughts? My apologies if this is a previously requested feature,
though I did not find it in the archives.
- cut feature request: treat multiple consecutive delimiters as one,
Brandon Wood <=