Sponsored Content
Top Forums Shell Programming and Scripting Help needed with shell script to search and replace a set of strings among the set of files Post 302890464 by Amulya on Thursday 27th of February 2014 01:07:06 AM
Old 02-27-2014
getting same error

$ bash testsync
testsync: line 28: declare: -A: invalid option
declare: usage: declare [-afFirtx] [-p] [name[=value] ...]
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

set password using a shell script

Hi All How can I set password in linux.It is OK if it display password in plain text in script. manually i can set: #passwd Changing password for root Enter new password: Bad password: too weak. Re-enter new password: Password changed. # I want this to be done by script.Please let me... (2 Replies)
Discussion started by: tannu
2 Replies

2. Shell Programming and Scripting

Ksh script - Design ? - Search file and set variables

Hi - I'm trying to think of a clever way to write a shell script (trying to stay w/ ksh as that's what I know the best...) that will resolve the following problem: Problem - On a daily basis I have to email folks who are on-call to remind them. I was hoping to script this out so I could have... (9 Replies)
Discussion started by: littlefrog
9 Replies

3. UNIX for Dummies Questions & Answers

vi search/replace using a set

Hi, I'm trying to do a global search/replace in vi using a set - I want to find every occurance of a carriage return followed by a character and replace it with a space. I've tried the following: :%s/\n/ /g It does the search ok, but it replaces the characters with the literal value ""... (2 Replies)
Discussion started by: HudZo
2 Replies

4. Shell Programming and Scripting

search of common words in set of files

Hi, I have a set of simple, one columned text files (in thousands). file1: a b c d file 2: b c d e and so on. There is a collection of words in another file: b d b c d e I have to find out the set of words (in each row) is present or absent in the given set of files. So, the... (4 Replies)
Discussion started by: mala
4 Replies

5. Shell Programming and Scripting

Complex Search/Replace Multiple Files Script Needed

I have a rather complicated search and replace I need to do among several dozen files and over a hundred occurrences. My site is written in PHP and throughout the old code, you will find things like die("Operation Aborted due to....."); For my new design skins for the site, I need to get... (2 Replies)
Discussion started by: UCCCC
2 Replies

6. UNIX for Dummies Questions & Answers

Loop through Sub Directories and search for set of files

I have the below directory in unix environment /home/bkup/daily: ls -lrt drwxrwx--x 2 user user 256 Jan 12 18:21 20110112/ drwxrwx--x 2 user user 256 Jan 13 17:06 20110113/ drwxrwx--x 2 user user 256 Jan 14 16:44 20110114/ drwxrwx--x 2 user user ... (2 Replies)
Discussion started by: prasannarajesh
2 Replies

7. Shell Programming and Scripting

Finding compound words from a set of files from another set of files

Hi All, I am completely stuck here. I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these: computer random access memory computer networking mouse terminal windows All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

8. Shell Programming and Scripting

search and replace, when found, delete multiple lines, add new set of lines?

hey guys, I tried searching but most 'search and replace' questions are related to one liners. Say I have a file to be replaced that has the following: $ cat testing.txt TESTING AAA BBB CCC DDD EEE FFF GGG HHH ENDTESTING This is the input file: (3 Replies)
Discussion started by: DeuceLee
3 Replies

9. Shell Programming and Scripting

Search for a value and replace other field in the same set

Hello friends, I have huge file with many sets where each "set" has few lines and each set always begins with "Set" in Sq brackets as shown above. # cat file1 (2 Replies)
Discussion started by: magnus29
2 Replies
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)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy