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 06:56 AM..
Reason: adding code tags
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)
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 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)
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)
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)
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)
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)
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)
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,
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)
Discussion started by: chettyravi
2 Replies
LEARN ABOUT FREEBSD
atf-sh
ATF-SH(1) BSD General Commands Manual ATF-SH(1)NAME
atf-sh [-s shell] -- interpreter for shell-based test programs
SYNOPSIS
atf-sh script
DESCRIPTION
atf-sh is an interpreter that runs the test program given in script after loading the atf-sh(3) library.
atf-sh is not a real interpreter though: it is just a wrapper around the system-wide shell defined by ATF_SHELL. atf-sh executes the inter-
preter, loads the atf-sh(3) library and then runs the script. You must consider atf-sh to be a POSIX shell by default and thus should not
use any non-standard extensions.
The following options are available:
-s shell Specifies the shell to use instead of the value provided by ATF_SHELL.
ENVIRONMENT
ATF_LIBEXECDIR Overrides the builtin directory where atf-sh is located. Should not be overridden other than for testing purposes.
ATF_PKGDATADIR Overrides the builtin directory where libatf-sh.subr is located. Should not be overridden other than for testing purposes.
ATF_SHELL Path to the system shell to be used in the generated scripts. Scripts must not rely on this variable being set to select a
specific interpreter.
EXAMPLES
Scripts using atf-sh(3) should start with:
#! /usr/bin/env atf-sh
Alternatively, if you want to explicitly choose a shell interpreter, you cannot rely on env(1) to find atf-sh. Instead, you have to hardcode
the path to atf-sh in the script and then use the -s option afterwards as a single parameter:
#! /path/to/bin/atf-sh -s/bin/bash
ENVIRONMENT
ATF_SHELL Path to the system shell to be used in the generated scripts.
SEE ALSO atf-sh(3)BSD September 27, 2014 BSD