The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 12:31 PM
Shell Script: want to insert values in database when update script runs ring Shell Programming and Scripting 1 10-25-2007 12:06 AM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 07:15 AM
returning to the parent shell after invoking a script within a script gurukottur Shell Programming and Scripting 5 09-26-2006 04:05 AM
return valuse from child script to parent script borncrazy Shell Programming and Scripting 1 08-20-2004 12:39 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-07-2006
Registered User
 

Join Date: Nov 2006
Posts: 17
sed script



I have a series of folders /temp/a /temp/b /temp/c

In folders a, b, and c, I have files
a1.txt……….a20.txt
b1.txt……….b40.txt &
c1.txt……….c60.txt

Each file has the same data format :-

Line 1 AAAAA aaaa
Line 2 BBB bbbbbb
Line 3 CCCC cccccc
Etc etc

I need to write a sed script which will go through all the files and reformat the data thus :-

Line 1 AAAAA aaaa
Line 2 BBB
Line 3 X bbbbbb
Line 4 CCCC cccccc
Etc etc

So I need to insert a CR/LF in line 2 position 4,
create a new Line 3 with a constant text (X) and the value of what was to the right of the previous Line 2 (bbbbbb)
and move the remaining lines one line down.

Can anyone help please ?
Forum Sponsor
  #2  
Old 12-07-2006
Registered User
 

Join Date: Dec 2006
Posts: 10
Sorry i read only second part and you can do the second part with


awk '{if (NR == 2) { $1=$1"\n"; $2="WHATEVER "$2;} print }' FILE_NAME

The only problem i see with this is, it will add extra space before third line. If if doesnt matter for you then you can live with this.
  #3  
Old 12-07-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Please read our rules and refrain from cross-posting. I'll close this thread and leave this one open.

Thanks
ZB
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:09 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0