Sponsored Content
Top Forums Shell Programming and Scripting sed - search and replace whole string which contains dot Post 302942891 by jcdole on Sunday 3rd of May 2015 08:25:25 AM
Old 05-03-2015
sed - search and replace whole string which contains dot

Hello.

I would like to search exactly "string1.string2.string3" and replace it by "new_string1.new_string2.new_string3"
And
I would like to search exactly "string2.string3" and replace it by "new_string2.new_string3"
And
I would not found in the result : "string1.new_string2.new_string3" because "string2.string3" is different from "string1.string2.string3"

"string1.string2.string3" are email address like firstname_1.firstname_2.name@subdomain.domain.ext

"string2.string3" are email address like firstname.name@subdomain.domain.ext

So if size is different, a match should not apply in "string1.string2.string3" when search is done with "string2.string3"

How to do that ?
Code:
sed '/\<tring1.string2.string3\>/something_else/g'    # dose not work.
sed '/\btring1.string2.string3\b/something_else/g'     # dose not work.
sed '/\<tring1\.string2\.string3\>/something_else/g'  # dose not work.

Any help is welcome

Last edited by vbe; 05-03-2015 at 09:53 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to replace all occurences of a search string using sed

All, Here is what I am searching for using sed. 1 00640000106798 I want to replace that with the following. 8 0064B0000106798 I can do this easy enough from the command line using sed but I need to put the search string in a file and then execute the sed command within a... (2 Replies)
Discussion started by: mjs3221
2 Replies

2. Shell Programming and Scripting

Perl: Search for string on line then search and replace text

Hi All, I have a file that I need to be able to find a pattern match on a line, search that line for a text pattern, and replace that text. An example of 4 lines in my file is: 1. MatchText_randomNumberOfText moreData ReplaceMe moreData 2. MatchText_randomNumberOfText moreData moreData... (4 Replies)
Discussion started by: Crypto
4 Replies

3. UNIX for Dummies Questions & Answers

Search for a string and replace the searched string in the same position in samefile

Hi All, My requisite is to search for the string "0108"(which is the year and has come in the wrong year format) in a particular column say 4th column in a tab delimited file and then replace it with 2008(the correct year format) in the same position where 0108 was found in the same file..The... (27 Replies)
Discussion started by: ganesh_248
27 Replies

4. Shell Programming and Scripting

Search, replace string in file1 with string from (lookup table) file2?

Hello: I have another question. Please consider the following two sample, tab-delimited files: File_1: Abf1 YKL112w Abf1 YAL054c Abf1 YGL234w Ace2 YKL150w Ace2 YNL328c Cup9 YDR441c Cup9 YDR442w Cup9 YEL040w ... File 2: ... ABF1 YKL112W ACE2 YLR131C (9 Replies)
Discussion started by: gstuart
9 Replies

5. Shell Programming and Scripting

awk - replace number of string length from search and replace for a serialized array

Hello, I really would appreciate some help with a bash script for some string manipulation on an SQL dump: I'd like to be able to rename "sites/WHATEVER/files" to "sites/SOMETHINGELSE/files" within the sql dump. This is quite easy with sed: sed -e... (1 Reply)
Discussion started by: otrotipo
1 Replies

6. Shell Programming and Scripting

awk/sed string search and replace

Need help with either sed or awk to acheive the following file1 ----- In the amazon forest The bats eat all the time... mon tue wed they would eat berries In the tropical forest The bats eat all the time... on wed bats eat nuts In the rain forest The bats eat all the time... on... (2 Replies)
Discussion started by: jville
2 Replies

7. Shell Programming and Scripting

How to use SED or AWK to search and replace an exact string

I have a file DS1 DDS DS I want to replace only "DS" to "DSmail.blah.com" in a lot of files. I tried sed 's/DS/DSmail.blah.com' but it changes all the lines . thanks in advance (2 Replies)
Discussion started by: gubbu
2 Replies

8. Shell Programming and Scripting

sed or awk command to replace a string pattern with another string based on position of this string

here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb cat dump.sql INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Discussion started by: vivek d r
10 Replies

9. Shell Programming and Scripting

How to search and replace string in column in file with command sed?

how to search and replace string in column in file with command sed or other search "INC0000003.in" and replace column 4 = "W" $ cat file.txt INC0000001.in|20150120|Y|N|N INC0000002.in|20150120|Y|N|N INC0000003.in|20150120|Y|N|N INC0000004.in|20150120|Y|N|Noutput... (4 Replies)
Discussion started by: ppmanja3
4 Replies

10. UNIX for Dummies Questions & Answers

Search for a string,delete the line and replace with new string in a file

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
CTYPE_SPACE(3)								 1							    CTYPE_SPACE(3)

ctype_space - Check for whitespace character(s)

SYNOPSIS
bool ctype_space (string $text) DESCRIPTION
Checks if all of the characters in the provided string, $text, creates whitespace. PARAMETERS
o $text - The tested string. RETURN VALUES
Returns TRUE if every character in $text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters. EXAMPLES
Example #1 A ctype_space(3) example <?php $strings = array('string1' => " ", 'string2' => " arf12", 'string3' => ' '); foreach ($strings as $name => $testcase) { if (ctype_space($testcase)) { echo "The string '$name' consists of all whitespace characters. "; } else { echo "The string '$name' does not consist of all whitespace characters. "; } } ?> The above example will output: The string 'string1' consists of all whitespace characters. The string 'string2' does not consist of all whitespace characters. The string 'string3' does not consist of all whitespace characters. NOTES
Note If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative val- ues have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string contain- ing the decimal digits of the integer. SEE ALSO
ctype_cntrl(3), ctype_graph(3), ctype_punct(3). PHP Documentation Group CTYPE_SPACE(3)
All times are GMT -4. The time now is 08:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy