Reputation: 85
I have a tab delimited file with chunks of data separated by lines of empty fields. It looks like this:
#comment\n
data<TAB>data<TAB>data\n
data<TAB>data<TAB>data\n
<TAB><TAB>\n
#comment\n
#comment 2\n
data<TAB>data<TAB>data\n
data<TAB>data<TAB>data\n
data<TAB>data<TAB>data\n
<TAB><TAB>\n
data<TAB><TAB>\n
I'm trying to use csplit to split this file into chunks. It's only creating two files, when there are 23 matches to my pattern:
$ grep '^ *$' file.txt | wc -l
23
$ csplit file.txt '/^ *$/'
875
587453
$ ls
file.txt xx00 xx01
I'm using CTRL-V to enter the tab, '\t' doesn't work for either csplit or grep. The environment is Bash on Cygwin. I've examined the file with a hex editor, and it's definitely using UNIX line feeds.
What could I be doing wrong?
Upvotes: 0
Views: 121
Reputation: 85
You have to append '{*}' to the end to get it to break more than once. Who knew?
Upvotes: 1