Single character wildcard for SED


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Single character wildcard for SED
# 8  
Old 02-15-2006
Question

Thanks matrixmadhan and vino!
Regarding vino's code it worked great but I'm not quite sure what the "^" character inside the brakets mean. Does it mean Not Equal To (!=) ? If this is ture is it also true that "^" character will be ignored if the "^" character is not used straight after the first braket "[" ?
# 9  
Old 02-16-2006
Code:
sed -e 's#/[^/ ]*##g'

This is what the sed does. Look for lines that have a / followed by any non / character or a non-whitespace character.

^ as the first character in [] means, ignore all the other characters in that charatcer-class set. [AB^] means match any of these characters. Either A or B or ^.

You should read the sed book given in How to delete a particular text without opening the file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to repeat a character in a field if it's a single character?

I have a csv dataset like this : C,rs18768 G,rs13785 GA,rs1065 G,rs1801279 T,rs9274407 A,rs730012 I'm thinking of use like awk, sed to covert the dataset to this format: (if it's two character, then keep the same) CC,rs18768 GG,rs13785 GA,rs1065 GG,rs1801279 TT,rs9274407... (7 Replies)
Discussion started by: nengcheng
7 Replies

2. Shell Programming and Scripting

WildCard character - not able to understand

Hello, I have one script which looks as given below , . ${0%/*}/init && init_job || exit 1 what I understood is , 1. above syntax has three commands, two on left of || and one on right of ||. 2. ${0%/*} would generate some path. Question. A. What is the meaning of ${0%/*} ,... (2 Replies)
Discussion started by: ParthThakkar
2 Replies

3. Shell Programming and Scripting

sed using wildcard

Hi Folks, I had a requirement to replace a pattern a.*a with 'a' alone. I'm writing a sed command to do that. But I'm not able to work this out. Pls help me. echo 'a123a456a789' | sed 's/a.*a/a/' Expected o/p : a456a789 But actual o/p is a789. :confused: how can write that... (6 Replies)
Discussion started by: poova
6 Replies

4. Shell Programming and Scripting

Sed Wildcard

Hello, I apologize for asking what is probably a simple question but I have been unable to understand the other posts on the topic. I have a file that has the following several lines: ABC DEF GH:IJKLMNOP_QRS_TUV_11112012_ABCL5 ABC DEF GH:IJKLMNOP_QRS_TUV_11112013_ABCL4 ABC DEF... (4 Replies)
Discussion started by: MolecularToast
4 Replies

5. UNIX Desktop Questions & Answers

How to squeeze multiple pipe character '|' into single '|' using sed?

Hi, I am trying to convert multiple Unix pipe symbol or bar into single |. I have tried with the following sed statements, but, no success :(. I need it using sed only echo "sed 's/\|\+/\|/g' sed 's/*/\|/' sed 's/\|*/|/' sed -r 's/\|+/\|/' However, the below awk code is working fine.... (4 Replies)
Discussion started by: royalibrahim
4 Replies

6. Shell Programming and Scripting

Replace multiple occurances of same character with a single character.

Hi all, Greetings, I have the following scenario, The contents of main file are like : Unix|||||forum|||||||||||||||is||||||the||best so||||||be|||||on||||||||||||||||||||||||||||||||||||||||||||it And i need the output in the following form: Unix=forum=is=the=best so=be=on=it ... (3 Replies)
Discussion started by: dipanchandra
3 Replies

7. UNIX for Dummies Questions & Answers

how to search and list file with wildcard character

hi, I want to search all files in the current working direcotry and to print in comma (,) seperated output. But I have two patterns to search for. Files will be in ABC20100508.DAT format. Search should happen on the format (ABC????????.DAT) along with date(20100508). I can do a ls... (2 Replies)
Discussion started by: anandapani
2 Replies

8. UNIX for Advanced & Expert Users

Unix wildcard character question

1. Is . wildcard? , the documented wildcard are "*", "?", and "" . seems mean everything, the follwing cmd will copy everything cp -r /tmp/test1/. /tmp/test2/ However it doesn't work for rm, why? $ ls -a . .. .a .aa aa t2 $ rm -rf . $ ls -a . .. .a .aa ... (3 Replies)
Discussion started by: honglus
3 Replies

9. Shell Programming and Scripting

Matching multiples of a single character using sed and awk

Hi, I have a file 'imei_01.txt' having the following contents: $ cat imei_01.txt a123456 bbr22135 yet223 where I want to check whether the expression 'first single alphabet followed by 6 digits' is present in the file (here it is the first record 'a123456') I am using the following... (5 Replies)
Discussion started by: royalibrahim
5 Replies

10. Shell Programming and Scripting

sed help/wildcard substitution

I need to perform the following substitutions and have been struggling to determine if or how I can do this with sed or perl. I need to change the string foo(bar) to moo(bar,0) wherever this occurs in a file. Is there a way to do this? I'm thinking there might be a wildcard of some sort that... (4 Replies)
Discussion started by: Mike@NZ
4 Replies
Login or Register to Ask a Question