multipe pattern


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multipe pattern
# 1  
Old 12-02-2011
multipe pattern

Extract of configuration file.
Code:
members         server1.domain1.com,server2.domain2.com,server3.domain3.com

I am writing a script to remove the server members from a conf file. When I run the script the corresponding server should be removed from the file.

/root/server-remove.sh server1.domain1.com
or
/root/server-remove.sh server3.domain3.com

Both of the above commands should remove the corresponding server from file. As the server name can end in comma or without comma, I am not able to use pattern replacement using sed. Please help me.
# 2  
Old 12-02-2011
See if this "sed" works for you:
Code:
sed 's/server1.domain1.com[,]\{0,1\}//' Inp_File

# 3  
Old 12-02-2011
Quote:
Originally Posted by Shell_Life
See if this "sed" works for you:
Code:
sed 's/server1.domain1.com[,]\{0,1\}//' Inp_File

Might I suggest a minor improvement:
Code:
sed 's/server1\.domain1\.com[,]\{0,1\}//' Inp_File

so it doesn't match things like server1_domain.com by accident
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move multipe files to corresponding directories

Hi, In a parent directory there are several files in the form IDENTIFIER1x IDENTIFIER1.yyy IDENTIFIER1_Z, etc IDENTIFIER2x IDENTIFIER2.yyy IDENTIFIER2_Z, etc IDENTIFIER3x IDENTIFIER3.yyy, IDENTIFIER3_Z, etcIn the same parent directory there are corresponding directories named... (7 Replies)
Discussion started by: spirospap
7 Replies

2. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

3. Shell Programming and Scripting

Renaming multipe files

Hi, I have these list of files from with the following filename format (the last 3 characters are in julian days). I want the year info retained added with sequence number 01-12 to represent the month. any suggestion on how to automate the renaming process. many thanks. original filenames ... (3 Replies)
Discussion started by: ida1215
3 Replies

4. Shell Programming and Scripting

execute multipe commands

I would like to execute multipe commands in a shell script. Please provide the commands for the below scenario: Execute command1 if command1 is succesfull, then execute command2, command3,command4 in parallel if command2, command3,command4 are success then run command 5 (3 Replies)
Discussion started by: p_gautham12
3 Replies

5. Shell Programming and Scripting

Parsing multipe data entries

Hi I am using command awk '{printf $1 " "}' PMT_GGSN_WPP_APN-20110517* > outfile The * refers to 24 files (1 generated per hour per day) with each one having the output of A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 I need... (8 Replies)
Discussion started by: rob171171
8 Replies

6. UNIX for Dummies Questions & Answers

Reading only first record from the multipe directories

Hi All, I have a requirement, I had a parent directory Land under that we have sub directories Yesterday, Today and Tommorrow And we have a file test.txt under the above directories Yesterday, Today and Tommorrow The data in the file test.txt under Yesterday folder is ... (5 Replies)
Discussion started by: somu_june
5 Replies

7. Shell Programming and Scripting

Transpose multipe columns to rows and adding headers

Hi, I found the following awk script to transpose multiple (3) columns to multiple rows: #=== BEGIN {FS=","} { for (i=1;i<=NF;i++) { arr=$i; if(nf<= NF) nf=NF; } nr=NR } END { for(i=1;i<=nf;i++) { (8 Replies)
Discussion started by: Gery
8 Replies

8. Shell Programming and Scripting

Multipe conditions in if statement

I have a script that runs every 15 minutes in cron that builds a web page. It runs at 15, 28, 45 and 58 minutes past the hour. (pretty much evry 15 mins). Every 2 hours from 6:28 to 18:28 it sends out emails if it finds errors. I do not want it sending email every single time it runs, every 15... (5 Replies)
Discussion started by: spacemancw
5 Replies

9. Shell Programming and Scripting

multipe instance scenario in perl

letz say that my file has 7 records with only one field. So my file has: 11111111 000000000000000 1111 aaaabbbccc 1111111222000000 aaaaaaaa zz All i need is: 1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid.... (4 Replies)
Discussion started by: helengoldman
4 Replies

10. AIX

multipe shells spawned with "ps" command

I have a small function that I use to see if another version of the script is currently running. Occasionally, about 10% of the time, it reports that two instances of the script are currently running. Since I am using a unique name, I know that there is not another version running out there by... (0 Replies)
Discussion started by: johnnieb
0 Replies
Login or Register to Ask a Question