Sponsored Content
Top Forums Shell Programming and Scripting Script to find & replace a multiple lines string across multiple php files and subdirectories Post 302604309 by spfc_dmt on Sunday 4th of March 2012 10:22:53 AM
Old 03-04-2012
Hi. When i execute the script it keeps saying:

No such file or directory cd: /directory/path/where/you/want/to/start (i did replaced this with the full path of the directory i wanted it to start)

BTW, when i execute it just by typing
Code:
delete_frm_php.ksh

it says :
Code:
-bash Command not found: delete_frm_php.ksh: Command not found

when i execute it typing
Code:
bash delete_frm_php.ksh

it says:

Code:
: command not found line 2:
: No such file or directory cd: /directory/path/where/you/want/to/start
delete_frm_php.ksh: line 32: unexpected EOF while looking for matching `''
delete_frm_php.ksh: line 41: syntax error: unexpected end of file

I also a few tweaks in the path, no success

Any clues ? Thank you!

Last edited by spfc_dmt; 03-04-2012 at 11:29 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find and Replace in multiple files (Shell script)

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)
Discussion started by: jatins_s
13 Replies

2. UNIX for Dummies Questions & Answers

Find and replace a string in multiple files

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)
Discussion started by: pharos467
2 Replies

3. Shell Programming and Scripting

replace multiple lines in multiple files

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)
Discussion started by: unihp1
1 Replies

4. Shell Programming and Scripting

shell script to find and replace string in multiple files

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)
Discussion started by: pharos467
11 Replies

5. Shell Programming and Scripting

Find & Replace string in multiple files & folders using perl

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)
Discussion started by: Zaheer.mic
0 Replies

6. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

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)
Discussion started by: r_sarnayak
0 Replies

7. Shell Programming and Scripting

how can i find number of lines in files & subdirectories

how can i find number of lines in files & subdirectories ? (3 Replies)
Discussion started by: pcbuilder
3 Replies

8. Shell Programming and Scripting

replace (sed?) a string in file with multiple lines (string) from variable

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)
Discussion started by: jforce
2 Replies

9. Shell Programming and Scripting

Search & Replace: Multiple Strings / Multiple Files

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)
Discussion started by: spacegoose
2 Replies

10. Shell Programming and Scripting

Replace a string with multiple lines

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
QSUBST(1)						    BSD General Commands Manual 						 QSUBST(1)

NAME
qsubst -- query-replace strings in files SYNOPSIS
qsubst str1 str2 [flags] file [file [...]] DESCRIPTION
qsubst reads its options (see below) to get a list of files. For each file on this list, it then replaces str1 with str2 wherever possible in that file, depending on user input (see below). The result is written back onto the original file. For each potential substitution found, the user is prompted with a few lines before and after the line containing the string to be substi- tuted. The string itself is displayed using the terminal's standout mode, if any. Then one character is read from the terminal. This is then interpreted as follows (this is designed to be like Emacs' query-replace-string): space Replace this occurrence and go on to the next one. . Replace this occurrence and don't change any more in this file (i.e., go on to the next file). , Tentatively replace this occurrence. The lines as they would look if the substitution were made are printed out. Then another character is read and it is used to decide the result as if the tentative replacement had not happened. n Don't change this one; just go on to the next one. ^G Don't change this one or any others in this file, but instead simply go on to the next file. ! Change the rest in this file without asking, then go on to the next file (at which point qsubst will start asking again). ? Print out the current filename and ask again. The first two arguments to qsubst are always the string to replace and the string to replace it with. The options are as follows: -w The search string is considered as a C symbol; it must be bounded by non-symbol characters. This option toggles. ('w' for 'word'.) -! -go -noask Enter ! mode automatically at the beginning of each file. -nogo -ask Negate -go, that is, ask as usual. -cN (Where N is a number.) Give N lines of context above and below the line with the match when prompting the user. -CAN (Where N is a number.) Give N lines of context above the line with the match when prompting the user. -CBN (Where N is a number.) Give N lines of context below the line with the match when prompting the user. -f filename The filename argument is one of the files qsubst should perform substitutions in. -F filename qsubst reads filename to get the names of files to perform substitutions in. The names should appear one to a line. The default amount of context is -c2, that is, two lines above and two lines below the line with the match. Arguments not beginning with a - sign in the options field are implicitly preceded by -f. Thus, -f is really needed only when the file name begins with a - sign. qsubst reads its options in order and processes files as it gets them. This means, for example, that a -go will affect only files named after the -go. The most context you can get is ten lines each, above and below. str1 is limited to 512 characters; there is no limit on the size of str2. Neither one may contain a NUL. NULs in the file may cause qsubst to make various mistakes. If any other program modifies the file while qsubst is running, all bets are off. AUTHORS
der Mouse <mouse@rodents.montreal.qc.ca> BSD
September 4, 1999 BSD
All times are GMT -4. The time now is 01:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy