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
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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-09-2007
vijaylak vijaylak is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 5
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!
  #2 (permalink)  
Old 03-09-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 610
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;')
  #3 (permalink)  
Old 03-09-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 610
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;')
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0