There are two problems with your regex. "." is a special character meaning "any single character", ergo, the regex "192.168.0.126" would also match "1912168Q0126"!
Fixing your particular problem depends on having a modern enough sed it supports extended regexes and backreferences.
I usually do something like this:
The red (^| ) matches either "beginning of the line" or "space", and the red \1 - just as importantly - puts it back in the output. The green does the same for end-of-line or space. Matching [.] between numbers forces it to take the . literally. '\.' probably also works but strikes me as harder to read.
I wish to use sed -f. Also, if you can ignore the decimal issue will you be able to tell me how the simplified sed would look like where it ignore matching strings immediately followed by a numeric digit ?
---------- Post updated at 12:03 PM ---------- Previous update was at 12:00 PM ----------
Quote:
Originally Posted by vgersh99
one way - not fool-proof:
Sorry, i am not looking for this solution as my command runs across thousands of files. It may encounter an IP followed by any character which i m not sure.
Hence i m looking to ignore the sed whenever the matching string is followed by a numeric digit else the sed should do the replacement action..
Last edited by mohtashims; 07-12-2018 at 01:16 PM..
I am really need help with the regular expression in SED. From input file, I need to extract lines that have the port number (sport or dport) as defined. The input file is something like this
time=1209515280-1209515340 dst=192.168.133.202 src=208.70.8.23 bytes=2472 proto=6 sport=80 dport=1447... (6 Replies)
Hi experts,
As i am a novice unix player...so need help for the below query...banged my head from quite a while...:confused:
i have a set of html files, in which i need to search for string "Page"(case sensitive) and then replace the same with some numeric code ,say, "XXX1234".
Here in... (1 Reply)
Hello Everyone,
Im trying to run a search and replace of exact strings and the strings that im using variables that are passed through an array in a while loop. Here is a snip of my code:
USEROLD=`cat oldusers`
USERNEW=`cat newusers`
USEROLDARRAY=( $USEROLD )
USERNEWARRAY=( $USERNEW )... (4 Replies)
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)
Hi,
how to figure out script name from a file which are having pattern .ksh. So wherever i have .ksh in a file i should get complete name of the file along with its extension as well. (7 Replies)
QUESTION1:
How do you grep only an exact string. I am using Solaris10 and do not have any GNU products installed.
Contents of car.txt
CAR1_KEY0
CAR1_KEY1
CAR2_KEY0
CAR2_KEY1
CAR1_KEY10
CURRENT COMMAND LINE: WHERE VARIABLE CAR_NUMBER=1 AND KEY_NUMBER=1
grep... (1 Reply)
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)
I have text file which is a tab delimited one. Sample data from the file is shown below:
unix is\ great\ os
linux\ is superb
I want to replace that backslash with empty string preserving the tab delimiter. Output should be
unix is great os
linux is ... (3 Replies)
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)
I have a workaround to the problem i m posting, however if someone wants to look at my query and respond ... i will appreciate.
This is in reference to this thread -> https://www.unix.com/shell-programming-and-scripting/267630-extract-between-two-exact-matched-strings.html
I have data.txt as... (11 Replies)