deleting multiple accourances of a pattern from a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting deleting multiple accourances of a pattern from a file
# 8  
Old 04-21-2009
got it ..soory for the dupsed thing Smilie
# 9  
Old 04-21-2009
can you tell me where can i read more about sed
# 10  
Old 04-21-2009
Quote:
Originally Posted by lassimanji
can u expalin alitlle about dupsed. what does it do
sorry, it is just the filename. In this case, it will be your filename.


cheers,
Devaraj Takhellambam
# 11  
Old 04-21-2009
if abc.sh is
192.168.1.41

then the output that i get is v5c01

my code is
sed 's/192.168.1.4/v5c0/g
s/192.168.1.41/acc1/g' abc.sh 2>&1 | tee abc.sh

i want to find 192.168.1.4 and replace it with v5c0
and find 192.168.1.41 and replace it with acc1

and i want to do it using sed
# 12  
Old 04-22-2009
Quote:
Originally Posted by lassimanji
if abc.sh is
192.168.1.41

then the output that i get is v5c01

my code is
sed 's/192.168.1.4/v5c0/g
s/192.168.1.41/acc1/g' abc.sh 2>&1 | tee abc.sh

i want to find 192.168.1.4 and replace it with v5c0
and find 192.168.1.41 and replace it with acc1

and i want to do it using sed
u meant to say you want to replace two different ips with different names????

Code:
sed -e 's/\<192.168.1.4\>/v5c0/g'  -e 's/192.168.1.41/acc1/g'  filename


If you want to read about sed search for sed 1 liner in this forum itself... you will get the link...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Deleting a pattern in UNIX without deleting the entire line

Hi I have a file: r58778.3|SOURCES={KEY=f665931a...,fw,221-705}|ERRORS={16_1:T,30_1:T,56_1:C,57_1:T,59_1:A,101_1:A,115:-,158_1:C,186_1:A,204:-,271_1:T,305:-,350_1:C,368_1:G,442_1:C,472_1:G,477_1:A}|SOURCE_1="Contig_1092402550638"(f665931a359e36cea0976db191ff60ff09cc816e) I want to retain... (15 Replies)
Discussion started by: Alyaa
15 Replies

2. Shell Programming and Scripting

awk - writing matching pattern to a new file and deleting it from the current file

Hello , I have comma delimited file with over 20 fileds that i need to do some validations on. I have to check if certain fields are null and then write the line containing the null field into a new file and then delete the line from the current file. Can someone tell me how i could go... (2 Replies)
Discussion started by: goddevil
2 Replies

3. UNIX for Dummies Questions & Answers

Deleting Multiple Lines in Hosts File

Hello all, I'm using the Bash shell on Solaris 8. Please can someone tell me how I can delete multiple lines in the hosts file? I have a list of hosts that I want to quickly delete in the hosts file, but I'm looking for a quicker way than using VI to delete the lines one by one. Regards,... (4 Replies)
Discussion started by: wthomas
4 Replies

4. Shell Programming and Scripting

deleting lines in a file that match a pattern without opening it

In Unix, how do I delete lines in a file that match a particular pattern without opening it. File contents are foo line1 misc whatever foo line 2 i want to delete all lines that have the pattern "foo" without opening the file. File should eventually contain misc whatever (1 Reply)
Discussion started by: osbourneric
1 Replies

5. Shell Programming and Scripting

pattern matching over multiple lines and deleting the first

I've got a longish log file with content such as Uplink traffic: Downlink traffic: I want to parse the log file and remove any line that contains the string "Uplink traffic:" at the beginning of the line, but only if the line following it beginnings with the string "Downlink traffic:" (in... (7 Replies)
Discussion started by: Yorkie99
7 Replies

6. Shell Programming and Scripting

Searching a pattern in file and deleting th ewhole line containing the pattern

Hi All, Please can someone assist in the script I have made that searches a pattern in a file and delete the whole line containing the pattern. #!bin/sh # The pattern that user want to add to the files echo "Enter the pattern of the redirect" read value # check if the user has... (1 Reply)
Discussion started by: Shazin
1 Replies

7. Shell Programming and Scripting

deleting a pattern from a file

say i have a file with the following contents 0x20 0x20 0xc23886 > 0xc12354 > 0xc567555555 i want to delete "> " pattern and keep the rest of the file (6 Replies)
Discussion started by: lassimanji
6 Replies

8. Shell Programming and Scripting

Deleting multiple lines from file

Hi, I have 10 different strings. I have to delete the whole line matching with any one string. I can use sed like below sed '/$keyword1/d' fileList.txt > temp_fileList.txt sed '/$keyword2/d' temp_fileList.txt > temp_fileList1.txt . . . Here is the problem i do not have fixed number... (9 Replies)
Discussion started by: shekhar_v4
9 Replies

9. UNIX for Dummies Questions & Answers

Checking for a file in file pattern before deleting it

Hi, I need a script where I have delete all the files of type abc*.* from the directory /lmn/opq (passed as parameter to script) But I need to check if there is file of type abc*.* existing in the directory or not before I use the rm abc*.* command. Thanks (1 Reply)
Discussion started by: dsrookie
1 Replies

10. Shell Programming and Scripting

deleting multiple records from a huge file at one time

I have a very big file of 5gb size and there are about 50 million records in there. I have to delete the records based on recrord number that I know fromoutside with out opening the file. The record numbers are very random like 5000678, 7890005 etc. Can somebody let me know how i can... (5 Replies)
Discussion started by: dsravan
5 Replies
Login or Register to Ask a Question