masa2004
asked on
Looking for a unix command to extract specific lines for cygwin
Hi, experts,
I'd like to get a grep or sed command which can run on cygwin in order to do
"if a first column of the line is not numeric, concat the current line and the previous line"
The columns are separated by tabs.
For example,
000001<tab>aaaa<tab>bbbbb< tab>
000002<tab>cccc<tab>dd<tab >
ddd<tab>
000003<tab>eeee<tab>fffff< tab>
I just want to get
000002<tab>cccc<tab>ddddd< tab>
Thanks,
Masa
I'd like to get a grep or sed command which can run on cygwin in order to do
"if a first column of the line is not numeric, concat the current line and the previous line"
The columns are separated by tabs.
For example,
000001<tab>aaaa<tab>bbbbb<
000002<tab>cccc<tab>dd<tab
ddd<tab>
000003<tab>eeee<tab>fffff<
I just want to get
000002<tab>cccc<tab>ddddd<
Thanks,
Masa
Can you not use awk?
ASKER
>Can you not use awk?
Yes, I can, however I am new to use unix command yet.
Can you give me the example ?
Masa
Yes, I can, however I am new to use unix command yet.
Can you give me the example ?
Masa
I'm assuming when you say you want to get
000002<tab>cccc<tab>ddddd< tab>
you also want to get
000001<tab>aaaa<tab>bbbbb< tab>
and
000003<tab>eeee<tab>fffff< tab>
perl -0777 -pe 's/\s*\n([\D])/$1/g' < inputfile > outputfile
000002<tab>cccc<tab>ddddd<
you also want to get
000001<tab>aaaa<tab>bbbbb<
and
000003<tab>eeee<tab>fffff<
perl -0777 -pe 's/\s*\n([\D])/$1/g' < inputfile > outputfile
ASKER
>perl -0777 -pe 's/\s*\n([\D])/$1/g' < inputfile > outputfile
It made the same string as the input file.
Masa.
It made the same string as the input file.
Masa.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you, ozo.
I could solve the problem.
I could solve the problem.