The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: sed query
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 12-07-2006
grinder182533 grinder182533 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 17
sed query

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 ?
I don't know sed very well, and awk not at all.