Portal Home > Knowledgebase > Articles Database > Please help linux command needed !!!
Please help linux command needed !!!
Posted by cannibal, 10-07-2008, 06:13 AM |
Hello,
please help
I have file.txt
How can I add a text before each line in that file ??
for example
file.txt contains:
webhostingtalk
forum
website
after command to add txt 567 it will save it as
567webhostingtalk
567forum
567website
please help
|
Posted by zuborg, 10-07-2008, 06:50 AM |
sed s/^/567/ < file.txt > file.new.txt
after you verify that file.new.txt contains all data you need - replace old file by new one
# mv file.new.txt file.txt
or replace content of old file and delete new one
# cat file.new.txt > file.txt && rm file.new.txt
note that sed affect empty lines too
|
Posted by steveks, 10-07-2008, 07:06 AM |
Zuborg,
Its a great one. Worked like a Charm.
|
Posted by cannibal, 10-07-2008, 02:25 PM |
Yeah it is
thank you
|
Add to Favourites Print this Article
Also Read