Sponsored Content
Top Forums Shell Programming and Scripting Multiple Substitutions across Multiple Files Post 302761271 by Alexander4444 on Friday 25th of January 2013 11:21:26 AM
Old 01-25-2013
Multiple Substitutions across Multiple Files

Hey everyone! I am determining the best method to do what the subject of this thread says. I only have pieces to the puzzle right now. Namely this:

grep -rl "expression" . | xargs open

(I should mention that the intention is to grep through many files containing the "expression" and return the files themselves for subsequent editing.)

and this:

... | for line in source; do sed 's/expression/replacement/g' > tmp; done

Except that the issue is how to open each file, substitute, and save to the same respective files, not just save to one big tmp file. :P This is eluding me. I realize:

mv tmp > original_file

can be done for each case, but this seems to require a level of scripting knowledge I currently lack. Thanks for any help/suggestions/advice on this!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using Sed to perform multiple substitutions?

Hello I have the following output which is returned with the Month in text format instead of numerical. The output I receive is performed by using Rational Synergy CM software commands from the Unix command line and piping Unix commands on the end. bash-3.00$ ccm query -n... (4 Replies)
Discussion started by: Glyn_Mo
4 Replies

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

3. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

4. Shell Programming and Scripting

Multiple variable substitutions

Is there anyway to accomplish this? (ksh) FILES_TO_PROCESS='NAME1 NAME2' SOURCE_NAME1=/tmp/myfile TARGET_NAME1=/somewhere/else # other file names for i in $FILES_TO_PROCESS do file1=SOURCE_$i file2=TARGET_$i echo cp ${$file1} ${$file2} <-- how do get this to work. done (2 Replies)
Discussion started by: koondog
2 Replies

5. Programming

Control multiple program instances - open multiple files problem

Hello. This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine. So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files. My system (ubuntu 10.10), when I right click a file and I... (3 Replies)
Discussion started by: hakermania
3 Replies

6. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

7. UNIX for Dummies Questions & Answers

Multiple substitutions in one expression using sed

Hi, I'm trying to get multiple substitutions in one expression using sed: echo "-foo-_-bar--foo-_bar_-_foo_bar_-foo_-_bar_-" | sed -e "s//-/g" So, as you can see I'm trying to replace all instances of _-, -_, -- with - (dash) I have provided bad example. The question is how to use multiple... (6 Replies)
Discussion started by: useretail
6 Replies

8. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 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. UNIX for Beginners Questions & Answers

Export Oracle multiple tables to multiple csv files using UNIX shell scripting

Hello All, just wanted to export multiple tables from oracle sql using unix shell script to csv file and the below code is exporting only the first table. Can you please suggest why? or any better idea? export FILE="/abc/autom/file/geo_JOB.csv" Export= `sqlplus -s dev01/password@dEV3... (16 Replies)
Discussion started by: Hope
16 Replies
XWORD(1)						      General Commands Manual							  XWORD(1)

NAME
xword - do crossword puzzles in the Across Lite format SYNOPSIS
xword [puzzlefile.puz]... DESCRIPTION
Xword is a GTK program for doing crossword puzzles. It can read and write puzzles in the Across Lite file format. Consequently, it works well for doing puzzles from The New York Times. As well as a clock, it supports printing. It also auto-saves puzzles as you solve them so that you can return to partially completed puzzles. USAGE
First, locate a puzzle on the web. The best place to go is the web site of The New York Times. However, it costs money to access these puz- zles. Free puzzles are available from The Houston Chronicle. After you have found a puzzle, click on it in your web browser. Xword will open the puzzle and you can start solving. You can also choose to save the puzzle on your hard disk. Then you can open the puzzle using Xword later. After you have worked on a puzzle for a while, you may want to save your work. There are two ways to save. The easiest way is to close Xword without any further action. The next time you open the same puzzle (either by opening the .puz file or by clicking the same link on the web), you will be asked whether you want to continue where you left off. If you choose to continue, all your correct and incorrect answers will be saved, as well as the time on the clock. However, this technique only works for opening the puzzle on the same computer. If you need to open the saved puzzle on a different com- puter, then you can choose "Save" from the "File" menu. The saved file can be opened with Xword on any computer. However, incorrect answers and the time on the clock will not be saved. To print a puzzle, select "Print" from the "File" menu. You can see what the printed puzzle will look like by clicking "Print Preview". You can select the paper size and orientation by clicking on the "Paper" tab (puzzles are usually easier to read in landscape mode). Sometimes a puzzle will be locked so that the answers are unavailable. Unfortunately, Xword's support for locked puzzles is somewhat flaky. When using a locked puzzle, you should not click on the "Check" or "Solve" buttons, since they will give incorrect information. How- ever, you can still use Xword to enter answers for a locked puzzle. Later, when an unlocked version of the puzzle is released (usually the next day), open it using Xword. When asked, choose to continue where you left off. Now you can use the "Check" and "Solve" buttons to see how well you did. Sometimes crosswords will come with a four-digit code to unlock a locked puzzle file. This code is not needed by Xword ... For more information, see the project home page at <https://alioth.debian.org/projects/xword/>. AUTHOR
xword was originally written by Bill McCloskey <bill.mccloskey@gmail.com>. This manual page was written by John Sullivan <johns@debian.org>, for the Debian project (but may be used by others). BUGS
Please report bugs to <https://alioth.debian.org/tracker/?atid=413106&group_id=100419&func=browse>. December 3, 2007 XWORD(1)
All times are GMT -4. The time now is 06:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy