I have a perl function in my script that needs to replace an entire line in a file
sub changestate {
my $base = ();
my @base = ();
open(BASE, $file) || die("Could not open file!");
@base=<BASE>;
close (BASE);
foreach $base(@base)
{
if($base =~... (1 Reply)
i am very new to UNIX
plz help me in this scenario
i have two text files as below
file1.txt
name=Rajakumar.
Discipline=Electronics and communication.
Designation=software Engineer.
file2.txt
name=Kannan.
Discipline=Mechanical.
Designation=CADD Design Engineer.
... (6 Replies)
Dear All,
i want to search particular string and want to replance next line value.
following is the test file.
search string is
tmp,???
,10:1 "???" may contain any 3 character it should remain the same and next line replace with ,10:50
tmp,123 --- if match tmp,??? then... (3 Replies)
Hi,
I need to search for source path in file2 , as per file1 and if found get the next line and take the field value and put it in URL value of file1.
In file1, NF is not same for all the lines.
file1:
<type source="/home/USER/Desktop" Dest="/home/USER/DIR1/Desktop" URL="ssh/path"/>
<type... (8 Replies)
Dear all,
I have a number of files and each file has two sections separated by a blank line. At the top section, I have lines which describes the values of the alphabetical characters,
# s #; 0.123
# p #; 12.3
# d #; -2.33
# f #; 5.68
<blank line>
sssssss
spfdffff
sdfffffff
Now I... (4 Replies)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
Hi All,
i can replace a perticular value in sentence using perl.
perl -pi -e 's/old/new/' sample.txt
but i am not able to replace whole string by perl.
file1 contains "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.147.109.211)(PORT=1526))(CONNECT_DATA=(SID= MWDBD22)))". i... (3 Replies)
i am having text file below
System will display value URGENT and proceed
System will display value URGENT and proceed
System will display value URGENT and proceed
.................................................................. (1 Reply)
I have a file which requires modification via a shell script.
Need to do the following: 0. take input from user for new text. 1. search for a keyword in the file. 2. replace the line next to this to this keyword with user supplied input.
for e.g., my file has the following text:
(some... (7 Replies)
Hi Everyone,
I have a requirement in ksh where i have a set of files in a directory. I need to search each and every file if a particular string is present in the file, delete that line and replace that line with another string expression in the same file.
I am very new to unix. Kindly help... (10 Replies)
Discussion started by: Pradhikshan
10 Replies
LEARN ABOUT PHP
str_ireplace
STR_IREPLACE(3) 1 STR_IREPLACE(3)str_ireplace - Case-insensitive version ofstr_replace(3).
SYNOPSIS
mixed str_ireplace (mixed $search, mixed $replace, mixed $subject, [int &$count])
DESCRIPTION
This function returns a string or an array with all occurrences of $search in $subject (ignoring case) replaced with the given $replace
value. If you don't need fancy replacing rules, you should generally use this function instead of preg_replace(3) with the i modifier.
PARAMETERS
If $search and $replace are arrays, then str_ireplace(3) takes a value from each array and uses them to search and replace on $subject. If
$replace has fewer values than $search, then an empty string is used for the rest of replacement values. If $search is an array and
$replace is a string, then this replacement string is used for every value of $search. The converse would not make sense, though.
If $search or $replace are arrays, their elements are processed first to last.
o $search
- The value being searched for, otherwise known as the needle. An array may be used to designate multiple needles.
o $replace
- The replacement value that replaces found $search values. An array may be used to designate multiple replacements.
o $subject
- The string or array being searched and replaced on, otherwise known as the haystack. If $subject is an array, then the search
and replace is performed with every entry of $subject, and the return value is an array as well.
o $count
- If passed, this will be set to the number of replacements performed.
RETURN VALUES
Returns a string or an array of replacements.
EXAMPLES
Example #1
str_ireplace(3) example
<?php
$bodytag = str_ireplace("%body%", "black", "<body text=%BODY%>");
?>
NOTES
Note
This function is binary-safe.
Caution
Replacement order gotcha
Because str_ireplace(3) replaces left to right, it might replace a previously inserted value when doing multiple replacements.
Example #2 in the str_replace(3) documentation demonstrates how this may affect you in practice.
SEE ALSO str_replace(3), preg_replace(3), strtr(3).
PHP Documentation Group STR_IREPLACE(3)