Substitution after using grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Substitution after using grep
# 1  
Old 07-18-2013
Substitution after using grep

Hallo Team,

I would like to edit my output(files) after using grep manipulation. this is how my code looks like:

Code:
 grep Originating *2013*|grep -v "ACCOUNT IN RECALC"|grep -v MOBIFIN-TRANSIT|grep -v ",Call Forward Not Reachable"|grep "Unclear scenario:On-net to Off-net PGW, On-net to Off-net Partner IP:BSO,PGWO"|cut -f24 -d"," | sort -u

The output looks like below:
Code:
10.0.108.11:5060
10.0.108.20:5060

I would to substitude 10.0.108.11 with 10.211.34.67 and 10.0.108.20 with
10.223.34.65.

Thank you for your help in advance.
# 2  
Old 07-18-2013
Code:
sed 's#10\.0\.108\.11#10\.211\.34\.67#;s#10\.0\.108\.20#10\.223\.34\.65#'

# 3  
Old 07-18-2013
Yoda thank but there is a short fall with your command i think. Wont it apply the change globally? I would like to apply changes to the files in question. Do you understand or should i explain in more detail?
# 4  
Old 07-18-2013
Pipe your grep command output or pass the file name as argument to sed.
# 5  
Old 07-18-2013
Just to corfirm you mean like below:

Code:
grep Originating *2013*|grep -v "ACCOUNT IN RECALC"|grep -v MOBIFIN-TRANSIT|grep -v ",Call Forward Not Reachable"|grep "Unclear scenario:On-net to Off-net PGW, On-net to Off-net Partner IP:BSO,PGWO" | sed 's#10\.0\.108\.11#10\.211\.34\.67#;s#10\.0\.108\.20#10\.223\.34\.65#

'
# 6  
Old 07-18-2013
Correct
# 7  
Old 07-18-2013
Eh Yoda Smilie have a look below :

Code:
-bash-3.2$ grep Originating *2013*|grep -v "ACCOUNT IN RECALC"|grep -v MOBIFIN-TRANSIT|grep -v ",Call Forward Not Reachable"|grep -v "Unclear scenario:On-net to Off-net PGW, On-net to Off-net Partner IP:BSO,PGWO"|grep -v "Y,Unknown called on-net party:"|grep -v "Unknown calling on-net party"|grep -v ",ACCOUNT NOT FOUND"|grep -v "Unclear scenario:On-net to Off-net PGW, On-net to On-net:BSO,PGWO"|grep -v "Destination prefix cannot be found in the tariff"|grep -v ",Unclear scenario:On-net to Off-net Partner IP On-net to On-net:BSO,BST"|grep -v FAIL|grep ",Unknown scenario:BSO" |sed 's#10\.0\.0\.103#196\.35\.130\.52#;s#10\.0\.80\.36#196\.35\.130\.52#;s#10\.0\84\.73#196\.35\.130\.52#'
sed: -e expression #1, char 100: Invalid back reference
-bash-3.2$

What am i missing?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

2. Shell Programming and Scripting

Substitution

I am trying to do some substitutions using the substitution operator (:%s) in a text file. I want to replace all A1, A2, A3.......A100 in my text file. I used :%s/A2/SAE/g successfully until A9 but when I use A1, all the A11 to A19 is changed. How do I specify the exact match here? (8 Replies)
Discussion started by: Kanja
8 Replies

3. Shell Programming and Scripting

vi substitution

Hello, I'm trying to do a substitution in vi. which adds a field for the year to a line. If the line doesnt include a year, it should still add a field (although empty) the fields are: Country:number:number:name(and sometimes year):place this is a desired in and output: Sweden:55:32:John... (2 Replies)
Discussion started by: drareeg
2 Replies

4. Shell Programming and Scripting

substitution help

How do i substitute ' with space in a file using sed or awk i am getting the following two scenarios 1) xyz'd with xyz d if i use sed 's/xyz\\\'d/xy z/g' it is taking ' after \ as closing expr for substitution 2) xyz';d with xyz d please advice (8 Replies)
Discussion started by: mad_man12
8 Replies

5. UNIX for Dummies Questions & Answers

help with substitution

Hello, I have a file with 10,000+ records which look like this: Image3992170.tif 4/21/200811:42:09AM 3,373.13KB Image3993265.tif 4/11/20087:17:58PM 2,369.72KB Image3996764.tif 5/2/200811:01:28AM 2,155.87KB Image3997700.tif ... (4 Replies)
Discussion started by: lotusdeva
4 Replies

6. Shell Programming and Scripting

Substitution

All, I have this text document that contains a listing(See below). What i would like to ask is how i could extract just the information i need which is the files name (CWS*****.***.gz) If anyone has any suggestions i would be very grateful. I am sure its relatively simple but i just... (6 Replies)
Discussion started by: Andyp2704
6 Replies

7. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

8. Shell Programming and Scripting

MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else

Hi Guys, I need to set the value of $7 to zero in case $7 is NULL. I've tried the below command but doesn't work. Any ideas. thanks guys. MEM=`ps v $PPID| grep -i db2 | grep -v grep| awk '{ if ( $7 ~ " " ) { print 0 } else { print $7}}' ` Harby. (4 Replies)
Discussion started by: hariza
4 Replies

9. Shell Programming and Scripting

command substitution problems with csh using grep

I am trying to set a command into a variable in a csh script using command substituion with ``. I am having a problem with ps command combined with grep. The command is as follows (shows processes running with the word gpts in them). /usr/ucb/ps axwww | grep gpts this works fine at the... (2 Replies)
Discussion started by: voodoo31
2 Replies

10. Shell Programming and Scripting

substitution

I am trying to substituted a variable to a file using sed. However, the value of that variable is not being substituted. Here is an example of my code. lf=' ' v_whole="${1} ${2} ${3} $lf" cp ${IPPDIR}/ctl/fax_sub_text_a.${4}.${5}.txt... (1 Reply)
Discussion started by: supercbw
1 Replies
Login or Register to Ask a Question