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: $FIND can contain one or multiple lines along with special characters
print $REPLACE gives
#Hi How r $u
#Rahul()
i am $fine
thanks()
Note: $REPLACE can contain one or multiple lines along with special characters
Now, I want to replace $FIND with $REPLACE in "introduction.sh". Can anyone help me in achieving this? i have gone through lot of threads and forums but no success.
I have tried below command but it did not work
Also tried below command
Also, tried awk
But this gave an error as below
awk: syntax error near line 1
awk: illegal statement near line 1
Last edited by r_sarnayak; 06-02-2010 at 05:56 AM..
Reason: adding code tags
Hi,
following Perl code i used for finding multiple strings and replace with single string.
code:
#!/usr/bin/perl
my @files = <*.txt>;
foreach $fileName (@files) {
print "$fileName\n";
my $searchStr = ',rdata\)' | ',,rdata\)' | ', ,rdata\)';
my $replaceStr =... (2 Replies)
Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ?
The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories.
So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Hi Gurus,
I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name.
I have a dir. in which... (20 Replies)
Hi, I wish to replace a new line with br (html) but it doesn't seem to work
message=$(echo ${FORM_message} | tr '\r' '<br \/>' )
what it gives me seems to be ... b...?
I am also having problem escaping hash sign in cut command:
list=$(echo "$line" | cut -d'\#;\#' -f1) ;
my intention is... (2 Replies)
Dear all
I need a script for multiple find and replace in a single file.
For example input file is -
qwe wer ert rty tyu
asd sdf dgf dfg fgh
qwe wer det rtyyui
jhkj ert asd asd dfgd
now
qwe should be replace with aaaaaa
asd should be replace with bbbbbbbb
rty should be replace... (6 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)
I have 100 files, where i want to search a set of strings and make the replacement by other strings
In the first case I want to include a parameter in the name of a file
LOG_DCT = $ LOG_DIR/DCT_GERAL_"$DATAINI".log
replace to : LOG_DCT = $ LOG_DIR / DCT_GERAL_ $ 1_ "$ DATAINI". log
I did... (1 Reply)
HI All
I need a shell script ehich removes all special characters from file and converts the file to UTF-* format
Specail characters to be removed must be configurable.
strIllegal = @"?/><,:;""'{|\\+=-)(*&^%$#@!~`";
Please help me in getting this script as my scripting skilla are... (2 Replies)
Can I get some help on this please, I have looked at the many post with similar questions and have tried the solutions and they are not working for my scenario which is:
I have a text file (myfile) that contains
b_log=$g_log/FILENAME.log
echo "Begin processing file FILENAME " >> $b_log
... (4 Replies)
Hi,
Please find the Question Summary below-
In our email template document(.txt) bullets and Apostrophe are getting replaced by the string "£" in our Live environment.We are using sun solaris 8 in live.
Can anybody let me know why this happens and how to prevent this .
Thanks... (0 Replies)