what is the switch to let sed edit and save file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting what is the switch to let sed edit and save file
# 1  
Old 06-30-2010
what is the switch to let sed edit and save file

I remember there is a sed switch i can use to edit and save the file at the same time, but i cannot recall it at all.

so instead of

-> sed 's/A/B/' file > file-tmp
-> mv file-tmp file

what can i do to just let sed edit and save the "file"
# 2  
Old 06-30-2010
Code:
sed -i

?
# 3  
Old 06-30-2010
yappppp!SmilieSmilieSmilieSmilieSmilieSmilieSmilieSmilie that is what i am looking for, interesting the manpage does not have it!

Quote:
Originally Posted by bartus11
Code:
sed -i

?
# 4  
Old 06-30-2010
Quote:
Originally Posted by fedora
yappppp!SmilieSmilieSmilieSmilieSmilieSmilieSmilieSmilie that is what i am looking for, interesting the manpage does not have it!
Yea, that's weird. Anyway you can remember it as "in place" editing.
# 5  
Old 06-30-2010
Quote:
interesting the manpage does not have it!
As far as I know, only GNU sed supports editing in place.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - add/edit to file and save - sed?

I'm working on a script to execute a number of items. One being, editing particular files to add certain lines. I'm attempting to utilize sed, but, having issues when running from a bash script. Assistance is greatly appreciated. My example: sed -i '14 i\ # add these lines add these lines to... (5 Replies)
Discussion started by: Nvizn
5 Replies

2. UNIX for Dummies Questions & Answers

Cannot save edit on cron on Solaris 10

Hi Everyone, I have edited my cron using 'crontab -e'. When I try to save the changes using ':wq!' The file closes but the changes are not saved. I get the following messages: "/tmp/crontabJFainH" 45 lines, 2996 characters trail.log crontab: error on previous line; unexpected character found... (11 Replies)
Discussion started by: Scarlet
11 Replies

3. Shell Programming and Scripting

sed delete but save deleted output into other file

Hi guys, I am currently using this to save first 50 lines into top50.txt and delete them from list.txt ... it's 2 commands: head -n 50 list.txt > top50.txt && sed -i "1,50 d" list.txt I want to change that so it's 1 command - whereby sed removes the first 50 lines as above but that which is... (3 Replies)
Discussion started by: holyearth
3 Replies

4. Shell Programming and Scripting

sed and save same file

hi, Im trying to do a sed and save it in teh same file using sed -i option But i think my system doesnt supports that option at all. BTW, im working in ksh. Is there any alternate for this? Thanks (3 Replies)
Discussion started by: dvah
3 Replies

5. Shell Programming and Scripting

Sed save changes to same file in loop

I have got problems saving sed changes to the same file in a loop. Basically I want the delimited value in every line of the file to be set to blank according to the value stored in var. var can be changed anytime. I do not have sed -i and i've tried to mv the file. Any other ideas? My file... (8 Replies)
Discussion started by: alienated
8 Replies

6. Shell Programming and Scripting

Sed or Awk or both to edit file

What is an efficient way to remove all lines from the input file which contain a file name? inputfile: ======================= # comment # comment # comment 5 8 10 /tmp 5 8 10 /var/run 5 8 10 /etc/vfstab 5 8 9 /var/tmp 5 8 10 /var/adm/messages... (7 Replies)
Discussion started by: Arsenalman
7 Replies

7. Shell Programming and Scripting

File edit with awk or sed

I have the follwoing file: This looks to be : seperated. For the first field i want only the file name without ".txt" and also i want to remove "+" sign if the second field starts with "+" sign. Input file: Output file: Appreciate your help (9 Replies)
Discussion started by: pinnacle
9 Replies

8. Shell Programming and Scripting

How search,edit and save the file

Hi All, I want to edit a file using shell script..For ex...a file called /etc/passwd..here I am searching for "ftp" if it is there just change it to "tftp" without using any temporary file. (3 Replies)
Discussion started by: Vichu
3 Replies

9. Shell Programming and Scripting

Edit a file and save the changes

I have an xml file that gets created as a part of daily build. I have to modify some lines in this file, uncomment some lines, comment some line, add 2 new lines in the file every time. Is there an easier automated way to do this using perl, bash, or sh. I would appreciate it if someone can point... (1 Reply)
Discussion started by: saurabh1982
1 Replies

10. UNIX for Dummies Questions & Answers

edit file using sed (not create another!)

Hi, I generally use Perl for this ex. perl -e 's/pattern/replace/g' -p -i <filename> I did something like this.. find . -type f -exec perl -e 's/pattern/replace/g' -p -i {} \; I want to do this with "sed" but what I get is the output being printed on the screen.. i can do sed... (3 Replies)
Discussion started by: oldtrash
3 Replies
Login or Register to Ask a Question