how to alter the old file permanently using sed?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to alter the old file permanently using sed?
# 1  
Old 04-06-2006
Question how to alter the old file permanently using sed?

hi ,
m new to sed and awk. can anyone tell me how to alter the old file permanenetly using sed.
e.g.
$sed 's/cat/dog/g' old_file
the above command will replace all the occrance of cat by dog in the file called old_file and by default will show the output at stdout.
so is there anyway of altering the same "old_file" with sed.
plz reply soon,
bye
# 2  
Old 04-06-2006
possible with -i option of sed
its GNU version of sed

please search the forum
; it had been answered many times
# 3  
Old 04-06-2006
MySQL thanks

thnks buddy,
ya its working.can u also tel me how to remove the header from that same file
i.e.
i did
$ sed -i 's/cat/dog/g' old_file
the above is replacing cat to dog from the file called old_file,can i also remove the 1st line from the same file (old_file) simultaneously?
thanks in advance
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Alter existing script to work with longer file name

I have this script: #!/bin/sh for file in "$@" do ext=${file##*.} base=${file%.*} num=${base##*v} zeroes=${num%%*} num=${num#$zeroes} #remove leading zeros, or it uses octal num=$((num+1)) base=${base%v*} new=$(printf... (4 Replies)
Discussion started by: scribling
4 Replies

2. Shell Programming and Scripting

Alter Fixed Width File

Thank u so much .Its working fine as expected. ---------- Post updated at 03:41 PM ---------- Previous update was at 01:46 PM ---------- I need one more help. I have another file(fixed length) that will get negative value (ex:-00000000003000) in postion (98 - 112) then i have to... (6 Replies)
Discussion started by: vinus
6 Replies

3. Solaris

Removal of zip file permanently

Hi Everyone, I see some peculier thing happening on my server. I have one zipped file created long back as a normal user and trying to remove it now. When i tried to remove as that particular user, i was not able to do that. So i logged in as a root user and removed that successfully. But it... (8 Replies)
Discussion started by: Sricharan21
8 Replies

4. UNIX for Dummies Questions & Answers

Replace 8th and 9th characters in file permanently

Good evening, I have a file and wish to replace the 8th and 9th characters on the first line only no matter what they are with 44 and the file permanantly changed. e.g. file example.txt before change: 123456789123456 hi how are you blah blah file example.txt after change: ... (4 Replies)
Discussion started by: GarciasMuffin
4 Replies

5. UNIX for Dummies Questions & Answers

alter data in a file

Hi , I have data in file like below. status ----------- ------ 2287 C 1502 E 19 can anyone pls help me how can i get it modified as below status 2287|C|1502 E|19 can someone pls help. Thanks. (2 Replies)
Discussion started by: gaddamja
2 Replies

6. Homework & Coursework Questions

Help with bash shell to alter text file

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: My first question pertains to the adding a book section, I'm unsure which command or conditional statement I... (0 Replies)
Discussion started by: Vitrophyre
0 Replies

7. Shell Programming and Scripting

Alter file descriptor for stdout

Is there a way to alter the file descriptor for stdout.? sample: #!/bin/ksh exec 1>file exec 2>file echo hi --------->This will go to file print -u4 "come statement"---->I want to make the file descriptor 4 to point to stdout. The reason is ,I have a script which has lot of db2... (1 Reply)
Discussion started by: prasperl
1 Replies

8. Programming

how to delete a file permanently from computer

how to delete a file permanently frm computer? (7 Replies)
Discussion started by: unknown9
7 Replies

9. Solaris

Alter zip file without unzipping

I have some zip files. Every file has a "folder/xml file" inside it. Is there any way to change these zip files directly without unzipping them. I want to convert these zip files to "/xml file" (want to move the xml file/s one root up by removing the folder inside it.) Ex: -bash-3.00$ for file... (1 Reply)
Discussion started by: _prasad
1 Replies

10. Shell Programming and Scripting

File Alter Problem--need help

i have 3 files a.txt , b.txt and c.txt each files have keyfields and some column fields e.g. a.txt keyfield1 keyfield2 keyfield3 col1 col2 col3 1 2 3 44 55 66 4 5 6 92 48 33 .....................etc.................. b.txt keyfield1... (2 Replies)
Discussion started by: manas_ranjan
2 Replies
Login or Register to Ask a Question