• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 280
  • Last Modified:

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
0
masa2004
Asked:
masa2004
  • 3
  • 2
1 Solution
 
scarcasCommented:
Can you not use awk?
0
 
masa2004Author Commented:
>Can you not use awk?
Yes, I can, however I am new to use unix command yet.
Can you give me the example ?

Masa
0
 
ozoCommented:
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
masa2004Author Commented:
>perl -0777 -pe 's/\s*\n([\D])/$1/g' < inputfile > outputfile
It made the same string as the input file.

Masa.
0
 
ozoCommented:
Are you sure outputfile contained non-numeric characters in the first column of  a line?
Did you enter the command correctly?
Could you cut and paste the command you used, as well as the outptfile you got?
0
 
masa2004Author Commented:
Thank you, ozo.

I could solve the problem.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now