Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Insert a line to many files
Name: hismail Date: September 6, 2005 at 08:27:26 Pacific OS: Sco Openser CPU/Ram: 2 gig /2 gig
Comment:
Hi I would like to insert a line to many files in a directory : for example: abc has to be inserted to files harry.pf barry.pf tom.pf The common denominator for these files are the "*.pf" I need to insert "abc" any where inside these pf files.
Name: Luke Chi Date: September 6, 2005 at 08:57:14 Pacific
Reply:
for FILE in `ls *.pf` do echo abc >> $FILE done
Luke Chi
0
Response Number 2
Name: hismail Date: September 7, 2005 at 01:48:08 Pacific
Reply:
Hi luke Chi Thanks its works great Just 1 question, if i have to replace a field in the .pf files for example change "128" to "256" ? what do I i use. tried: for FILE in `ls *.pf` do echo sed 's/128/256/g' >> $FILE done
But it just outputs to screen
thanks for your help Hamim
0
Response Number 3
Name: Luke Chi Date: September 7, 2005 at 06:05:38 Pacific
Reply:
Use:
sed 's/128/256/g' `ls *.pf`
Luke Chi
0
Response Number 4
Name: hismail Date: September 7, 2005 at 06:31:47 Pacific
Reply:
Hi Luke I tried using `ls *.pf` instead of $FILE but it still also outputs to the screen.
Summary: Hi, I have a file with 60 lines. I want to write from line 10-20 to one file, 21-40 to another new file, 41-60 to another new file. Can anybody please help me on this? ...
Summary: hi, i am not doing integer aritmatic. i need to pick up a line from the file path.txt using sed command. with sed -n 1p path.txt will give me the first line from the file path.txt. so i am trying to ...