edit file using sed (not create another!)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers edit file using sed (not create another!)
# 1  
Old 01-18-2006
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 -e 's/pattern/replace/g' < input > output

but in my case of "find", i dont want to create a bunch of output files, rather the editing to take place in the same file..

Any ideas?

Thanks,
Balaji
# 2  
Old 01-18-2006
Not sure if you have the -i option for your sed

If it does, this will work

Code:
find . -type f -exec sed -i -e 's/pattern/replace/g' {} \;

# 3  
Old 01-18-2006
to add with Vino,

-i option in sed is available only in GNU distribution
This User Gave Thanks to matrixmadhan For This Post:
# 4  
Old 01-21-2006
Hi Vino, Madhan,

Thanks for the inputs.. As mentioned, it is not working in my system.. Is there any other thought?

Thanks,
Balaji
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk and sed script to create one output CSV file

Hi All , I would require your help to generate one output file after post processing of one CSV file as stated below This file is just a small cut from a big file . Big file is having 20000 lines PATTERN,pat0,pat1,pat2,pat3,pat4,pat5,pat6,pat7,pat8,pat9... (2 Replies)
Discussion started by: kshitij
2 Replies

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

3. Shell Programming and Scripting

edit sed command

how can i make this sed command run faster? sed '51000000,51347442!d' file and sed '51347442,$ !d' file File is a 9GB in size. it runs on sunos 5.10 and linux red hat 6 servers and i use bash. (5 Replies)
Discussion started by: SkySmart
5 Replies

4. Shell Programming and Scripting

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" (4 Replies)
Discussion started by: fedora
4 Replies

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

6. Shell Programming and Scripting

Script to Edit the file content and create new file

I have a requirement, which is as follows *. Folder contains list of xmls. Script has to create new xml files by copying the existing one and renaming it by appending "_pre.xml" at the end. *. Each file has multiple <Name>fileName</Name> entry. The script has to find the first occurance of... (1 Reply)
Discussion started by: sudesh.ach
1 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

edit entire column from a fixed-width file using awk or sed

Col1 Col2 Col3 Col4 12 Completed 08 0830 12 In Progress 09 0829 11 For F U 07 0828 Considering the file above, how could i replace the third column the most efficient way? The actual file size is almost 1G. I am... (10 Replies)
Discussion started by: tamahomekarasu
10 Replies

9. UNIX and Linux Applications

Application to create/edit chm files

Does someone knows an application to create/edit *.chm files? Any suggestion will be much appreciated! (2 Replies)
Discussion started by: agasamapetilon
2 Replies

10. Shell Programming and Scripting

Simple SED edit

I have output like the following: B D 20070116095820001 N D S0000579.LOG S0000582.LOG B D 20070116095750001 N D S0000574.LOG S0000576.LOG B D 20070116095734001 N D S0000570.LOG S0000573.LOG B D 20070116095705001 N D S0000569.LOG S0000569.LOG B D ... (5 Replies)
Discussion started by: rdudejr
5 Replies
Login or Register to Ask a Question