Created a shell script to invoke sed to edit multiple files, but am missing something.
Here's the shell script:
As you can see, I'm using a script file 'script.sed' to supply the actual editing commands:
And for testing purposes, I have one .sh script to be edited:
But when I execute edit_scripts.sh, sed_sample.sh is not modified:
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... (4 Replies)
Here's what I have...
$ vi foo1
- open foo1 and work around for a while. I yank a few lines into a buffer and then :w to save.
Next I :e foo2 to open foo2 and paste my buffer. I :w to save, but I would like to then be able to go directly back into foo1 where I was before I opened foo2. ... (4 Replies)
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)
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)
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)
Hi all,
I would like to simply read a file which lists a number of pathnames and files, then search and replace key strings using a few vi commands:
:1,$s/search_str/replace_str/g<return>
but I am not sure how to automate the <return> of these vis commands when I am putting this in a... (8 Replies)
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)
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)
I have 6 different pipe delimiter files. My loads failing due to missing company code.
File1: 31 st field is company code.
402660076310|2014-12-10 17:22:39|2280361|MRYKI|1||CA|92507|US||1|1|0|0|0||N|A1|ONT|1001891771660009250700402660076310|WM|0201|RALA |2014-12-12|5|2014-12-12|5||FRI - 12... (4 Replies)
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
LEARN ABOUT REDHAT
lsdiff
LSDIFF(1)LSDIFF(1)NAME
lsdiff - show which files are modified by a patch
SYNOPSIS
lsdiff [-n] [-p n] [--strip=n] [--addprefix=PREFIX] [-s]
[-i PATTERN] [-x PATTERN] [-v] [file...]
lsdiff {--help | --version | --filter ... | --grep ...}
DESCRIPTION
List the files modified by a patch.
You can use both unified and context format diffs with this program.
OPTIONS -n Display the line number that each patch begins at. If verbose output is requested, each hunk of each patch is listed as well.
For each file that is modified, a line is generated containing the line number of the beginning of the patch, followed by a Tab
character, followed by the name of the file that is modified. If -v is given, following each of these lines will be one line for
each hunk, consisting of a Tab character, the line number that the hunk begins at, another Tab character, the string ``Hunk #'', and
the hunk number (starting at 1).
-p n When matching, ignore the first n components of the pathname.
--strip=n
Remove the first n components of the pathname before displaying it.
--addprefix=PREFIX
Prefix the pathname with PREFIX before displaying it.
-s Show file additions, modifications and removals. A file addition is indicated by a ``+'', a removal by a ``-'', and a modification
by a ``!''.
-i PATTERN
Include only files matching PATTERN.
-x PATTERN
Exclude files matching PATTERN.
-v Verbose output.
--help Display a short usage message.
--version
Display the version number of lsdiff.
--filter
Behave like filterdiff(1) instead.
--grep Behave like grepdiff(1) instead.
SEE ALSO filterdiff(1), grepdiff(1)EXAMPLES
To sort the order of touched files in a patch, you can use:
lsdiff patch | sort -u |
xargs -rn1 filterdiff patch -i
To show only added files in a patch:
lsdiff -s patch | grep '^+' |
cut -c2- | xargs -rn1 filterdiff patch -i
To show the headers of all file hunks:
lsdiff -n patch | (while read n file
do sed -ne "$n,$(($n+1))p" patch
done)
AUTHOR
Tim Waugh <twaugh@redhat.com>.
patchutils 13 May 2002 LSDIFF(1)