For starters, I'd rewrite the script you posted. The grep isn't needed, and since you're looking for a fixed set of files (*.php I assume), and fixed replace criteria, you don't need to worry about command line parameters. (You should if this is more than a one-off script, but I'll assume you don't need a script that you can run with different criteria.)
The basic script:
The tricky question is what criteria you need to determine which lines of the files to delete. Depending on what it is, the 'insert sed here' line in the previous script will need to change to do the right thing.
If your block of code is bounded by a unique string or phrase in the first and last lines then it will be a simple sed. The more complicated the criteria, the more complicated the code will need to be. Bottom line: post your criteria for deletion and someone will give you some help with writing a sed/awk or something that will delete things.
As for creating a script...
Start your favorite text editor, insert the code from above, or other of your choice, and save the file. Then at the command line, enter this command (assumes the file you saved was called delete_frm_php.ksh):
You then can invoke your script from the command line by typing delete_frm_php.ksh
hi guys,
Suppose you have 100 files in a folder and you want to replace all occurances of a word say "ABCD" in those files with "DCBA", how would you do
it ???
jatin (13 Replies)
I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
... (2 Replies)
i have to search a string and replace with multiple lines.
example
Input
echo 'sample text'
echo 'college days'
output
echo 'sample text'
echo 'information on students'
echo 'emp number'
echo 'holidays'
i have to search a word college and replace the multiple lines
i have... (1 Reply)
I used the following script
cd pathname
for y in `ls *`;
do sed "s/ABCD/DCBA/g" $y > temp; mv temp $y;
done
and it worked fine for finding and replacing strings with names etc. in all files of the given path.
I'm trying to replace a string which consists of path (location of file)
... (11 Replies)
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Hi,
I am creating a script to do a find and replace single/multiple lines in a file with any number of lines.
I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE
print $FIND gives
Hi How r $u
Rahul()
Note:... (0 Replies)
Can someone tell me how I can do this?
e.g:
a=$(echo -e wert trewt ertert ertert ertert erttert
erterte
rterter
tertertert
ert)
How do i replace the STRING with $a?
I try this:
sed -i 's/STRING/'"$a"'/g' filename.ext
but this don' t work (2 Replies)
I have a list of files all over a file system e.g.
/home/1/foo/bar.x
/www/sites/moose/foo.txtI'm looking for strings in these files and want to replace each occurrence with a replacement string, e.g.
if I find: '#@!^\&@ in any of the files I want to replace it with: 655#@11, etc.
There... (2 Replies)
Hello Guys,
I need to replace a string with multiple lines.
For eg:-
ABC,DEF,GHI,JKL,MNO,PQR,STU
need to convert the above as below:-
ABC,DEF,
GHI1
GHI2
GHI3,
JKL,MNO,
PQR1
PQR2
PQR3,
STU
i have tried using code as:- (2 Replies)
Discussion started by: jassi10781
2 Replies
LEARN ABOUT ULTRIX
lookbib
lookbib(1) General Commands Manual lookbib(1)Name
indxbib, lookbib - build inverted index for a bibliography, lookup bibliographic references
Syntax
indxbib database...
lookbib database
Description
The makes an inverted index to the named databases (or files) for use by and These files contain bibliographic references (or other kinds
of information) separated by blank lines.
A bibliographic reference is a set of lines, constituting fields of bibliographic information. Each field starts on a line beginning with
a ``%'', followed by a key-letter, then a blank, and finally the contents of the field, which may continue until the next line starting
with ``%''.
The command is a shell script that calls and The first program, truncates words to 6 characters, and maps upper case to lower case. It
also discards words shorter than 3 characters, words among the 100 most common English words, and numbers (dates) < 1900 or > 2000. These
parameters can be changed. The second program, inv, creates an entry file (.ia), a posting file (.ib), and a tag file (.ic), all in the
working directory.
The command uses an inverted index made by to find sets of bibliographic references. It reads keywords typed after the ``>'' prompt on the
terminal, and retrieves records containing all these keywords. If nothing matches, nothing is returned except another ``>'' prompt.
It is possible to search multiple databases, as long as they have a common index made by In that case, only the first argument given to is
specified to
If does not find the index files (the .i[abc] files), it looks for a reference file with the same name as the argument, without the suf-
fixes. It creates a file with a '.ig' suffix, suitable for use with It then uses this fgrep file to find references. This method is sim-
pler to use, but the .ig file is slower to use than the .i[abc] files, and does not allow the use of multiple reference files.
Files
x.ia, x.ib, x.ic, where x is the first argument, or if these are not present, then x.ig, x
See Alsoaddbib(1), lookbib(1), refer(1), roffbib(1), sortbib(1),
lookbib(1)