![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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. |