Sponsored Content
Full Discussion: sed across multiple files
Top Forums UNIX for Dummies Questions & Answers sed across multiple files Post 13488 by peter.herlihy on Thursday 17th of January 2002 09:59:06 PM
Old 01-17-2002
sed across multiple files

I've got a bunch of files (40 or so) and in each there is a substitution I need to perform.

I execuet the following sed command but it just make the changes to the screen without affecting the original file.

sed "s/, LA/,LA/g" *

(All files in the directory need this update).

So I tried redirecting...

for x in *
do
sed "s/, LA/,LA/g" $x > new_$x
done

And that worked. But I'm not sure about renaming the files back to what they were. mv obviously doesnt' like the wildcards and I'm not sure how to convert back.

I'd also like to know if there is a way to do this without piping to a new file...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to use multiple files in sed with w command

i have a command like : sed -n 's/^* /&/w even' <file if i want to write to multiple files like sed -n 's/^* /&/w zero two three' < file its not working it is taking "zero two three" as a single file i want to write to 3 seperate files . pls can anyone help me (2 Replies)
Discussion started by: santosh1234
2 Replies

2. UNIX for Dummies Questions & Answers

sed on multiple files?

Hi, I want to do a search and replace on multiple text files. Can I use sed to do this? i.e. I want to do something like: $ sed *.html -e 's/<\/body>/<\!-- blah -->\n<\/body>/' | grep -1 body ... then pipe/ channel the results back into the same files that were searched. how would... (2 Replies)
Discussion started by: mgrahamnz
2 Replies

3. UNIX for Dummies Questions & Answers

SED on multiple files

Hello all, Search & replace works fine using sed on a single file. Ex: sed -i 's/day/night/g' test1.sh There are many *.sh files in my current directory that I would like use sed on. I tried running the sed command using wild card but it did not work. sed -i 's/day/night/g' *.sh ... (7 Replies)
Discussion started by: luft
7 Replies

4. UNIX for Dummies Questions & Answers

best method of replacing multiple strings in multiple files - sed or awk? most simple preferred :)

Hi guys, say I have a few files in a directory (58 text files or somthing) each one contains mulitple strings that I wish to replace with other strings so in these 58 files I'm looking for say the following strings: JAM (replace with BUTTER) BREAD (replace with CRACKER) SCOOP (replace... (19 Replies)
Discussion started by: rich@ardz
19 Replies

5. Shell Programming and Scripting

SED command using multiple input files

What is the syntax to use multiple input files in a SED command. i.e. substitute a word with a phrase in every file in a directory. for every file in /usr/include that has the word "date" in the file grep -l '\<date\>' /usr/include/*.h find each occurrence of the word "time" in the file &... (3 Replies)
Discussion started by: sheoguey
3 Replies

6. Shell Programming and Scripting

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. I use the program to change an occurance of a word throughout different files that are being tested. At first i had to Create a new script,... (1 Reply)
Discussion started by: Johnny2518
1 Replies

7. Homework & Coursework Questions

Help with Shell Scripts Using sed in multiple files.

Hi, I was hoping that someone could help me. I have a problem that i am trying to work on and it requires me to change text within multiple files using sed. What i have so far is !/bin/sh File1="$3" File2="$4" File3="$5" testNum="$File1" while test "$testNum" <= "$File3"; do echo... (12 Replies)
Discussion started by: Johnny2518
12 Replies

8. Homework & Coursework Questions

Shell Script to sed with Multiple Files

I am not sure what I am doing wrong here. The code should work fine. I have been making small changes insuring that each new bit works. Now running my sed through multiple files I am getting incorrect output. Any help and instruction would be greatly appreciated. The problem - Generalize... (10 Replies)
Discussion started by: Lycopene
10 Replies

9. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies

10. Shell Programming and Scripting

Using sed to edit multiple files

Created a shell script to invoke sed to edit multiple files, but am missing something. Here's the shell script: oracle:$ cat edit_scripts.sh #!/bin/sh #------------------------------------------------------------------------------ # edit_scripts.sh # # This script executes sed to make global... (4 Replies)
Discussion started by: edstevens
4 Replies
rubibtex(1)							       teTeX							       rubibtex(1)

NAME
rubibtex - make a bibliography for (La)TeX using Russian letters as item names SYNOPSIS
rubibtex BASENAME DESCRIPTION
rubibtex is used to run bibtex(1) on auxiliary files with Russian characters in item names (citation keys). It is part of the T2 package. rubibtex copies the auxiliary file to /tmp, uses sed(1) to convert Cyrillic character commands to their 8-bit ASCII equivalents; runs bib- tex(1) on the modified file; and finally moves the original auxiliary file back (overwriting the modified file). rubibtex assumes that the bibtex(1) database (bib) files are encoded with the KOI8-R encoding. FILES
basename.aux LaTeX auxiliary file BUGS
None known, but report any bugs found to the authors. COPYRIGHT
The T2 package is Copyright 1997-1999 Werner Lemberg, Vladimir Volovich and any individual authors listed elsewhere in package files. It may be distributed under the conditions of the LaTeX Project Public License, either version 1.1 of this license or (at your option) any later version. SEE ALSO
bibtex(1), sed(1), <ftp://ftp.vsu.ru/pub/tex/T2/README>. AUTHOR
Werner Lemberg <wl@gnu.org>, Vladimir Volovich <TeX@vvv.vsu.ru>. This manual page was written by C.M. Connelly <c@eskimo.com>, for the Debian GNU/Linux system. It may be used by other distributions with- out contacting the author. Any mistakes or omissions in the manual page are my fault; inquiries about or corrections to this manual page should be directed to me (and not to the primary author). teTeX October 2000 rubibtex(1)
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy