![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| appending strings | scorpio | Shell Programming and Scripting | 1 | 06-03-2008 11:08 AM |
| appending strings to variable | finalight | Shell Programming and Scripting | 1 | 05-20-2008 04:50 AM |
| Appending multiple files into one | Spence23 | Shell Programming and Scripting | 3 | 04-30-2008 11:41 AM |
| Appending the two files | harish409 | UNIX for Dummies Questions & Answers | 3 | 09-13-2007 04:09 AM |
| appending files | edog | UNIX for Dummies Questions & Answers | 4 | 11-06-2002 11:18 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
appending strings in the files
I have some files created by a process in UNIX. I wanted to do some file processing:
1. I want to append a string "EOF" as the first word on the last line of all the files except the last file. 2.Similarly, I want to append "BOF" string as the first word to all the files except the first file, also this "BOF" string should be repeated for lines, till it find a line <abcd>. Thanks for ur time! |
|
||||
|
Try this...But this may not be the quickest way to do this..
for i in $(ls * |sed -n '1!p'| sed -n '$!p') do [[ -f "$i" ]] && { echo "BOF$(cat $i)" > $i; echo "$(cat $i)EOF" >$i; } done echo "BOF$(ls *|sed -n '1p;')" >$(ls *|sed -n '1p;') echo "$(ls *|sed -n '$p;')EOF" >$(ls *|sed -n '$p;') |
|
||||
|
Try this...But this may not be the quickest way to do this..Also,I assume that all the files in the current directory requires this update
for i in $(ls * |sed -n '1!p'| sed -n '$!p') do [[ -f "$i" ]] && { echo "BOF$(cat $i)" > $i; echo "$(cat $i)EOF" >$i; } done echo "BOF$(ls *|sed -n '1p;')" >$(ls *|sed -n '1p;') echo "$(ls *|sed -n '$p;')EOF" >$(ls *|sed -n '$p;') |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|