?
Solved

Looking for a unix command to extract specific lines for cygwin

Posted on 2005-03-05
6
Medium Priority
?
274 Views
Last Modified: 2010-04-17
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
Comment
Question by:masa2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:scarcas
ID: 13465159
Can you not use awk?
0
 

Author Comment

by:masa2004
ID: 13465191
>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
 
LVL 84

Expert Comment

by:ozo
ID: 13465558
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

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

Masa.
0
 
LVL 84

Accepted Solution

by:
ozo earned 1000 total points
ID: 13469215
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
 

Author Comment

by:masa2004
ID: 13580280
Thank you, ozo.

I could solve the problem.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Simple Linear Regression
Progress
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question