a quick SED question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting a quick SED question
# 1  
Old 09-22-2006
a quick SED question

I have a line

Code:
EXTDIR=`echo $i | sed 's/\-tar.gz//'`

which looks for files ending in -tar.gz, i would like to increase the functionality so that it looks for .tar.gz files as well as -tar.gz. Do i put the - in square brackets with a dot ? like this

Code:
EXTDIR=`echo $i | sed 's/\[-.]tar.gz//'`

unfortunately i dont have my box at hand to test this but i would love to know so i can be prepared

any help on this would be greatly appreciated
Gary
# 2  
Old 09-22-2006
almost - you don't need '\'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Quick sed/awk question

Hi fellow linux-ers, I have a quick question for you. I have the following text, which I would like to modify: 10 121E(121) 16 Jan 34S 132E 24 Feb 42 176E(176) 18 Sep 21S 164E 25 May 15 171W(-171) 09 Jul How can I do the following 2 modifications using sed and/or awk? 1. in 1st column,... (1 Reply)
Discussion started by: lucshi09
1 Replies

2. Shell Programming and Scripting

Quick Sed Question

Just want to know why when I do the following in sed, the required is not extracted. echo "ab01cde234" | sed 's/*$//' result: ab01cde (Which is correct) echo "ab01cde234" |sed 's/.*\(*\)$/\1/' result: blank (was expecting 234) or echo "ab01cde234" |sed 's/.*\(\)*$/\1/' result: blank... (6 Replies)
Discussion started by: eo29
6 Replies

3. Shell Programming and Scripting

Quick Question on sed command in shell script

Hello, I have the following line in one of my shell scripts. It works fine when the search string($SERACH_STR) exists in the logfile($ALERTLOG) but if the search string does not exist this line errors out at run time. Is there a way to make this line return 0 if it is not able to find the... (4 Replies)
Discussion started by: luft
4 Replies

4. Shell Programming and Scripting

quick sed question

hey, Im just wondering is there away to get sed to read from a variable eg it doesn't seem to work, i really need to be able to recursively change the same data set... (2 Replies)
Discussion started by: vbm
2 Replies

5. UNIX for Dummies Questions & Answers

quick question

from command prompt I did grep two words on a same line for eg: grep abc | grep xyz and I got tht particular line, but I want to know when I vi that file how to directly search for that particular line? I appreciate if any one can provide answer, thanks in advance (2 Replies)
Discussion started by: pkolishetty
2 Replies

6. UNIX for Dummies Questions & Answers

Another quick question

Hi guys sed -e "s/$<//g" the $< can allow me to assign an input value to the variable right? do the double quotes check the previous context? (1 Reply)
Discussion started by: hamoudzz
1 Replies

7. UNIX for Dummies Questions & Answers

quick question

hi guys trying to understand what this line means sed is a stream editor and i understand that, i have a file already selected i want to edit so i use -e sed -e the next stesp is s/$* s is a subsititute replacement sed -e s/$*//g $ is in reference of the last line /g makes it... (2 Replies)
Discussion started by: hamoudzz
2 Replies

8. UNIX for Advanced & Expert Users

Quick VI question

This "SHOULD" be a simple question, but looking through several books has turned up nothing, so I turn once again to the experts!! How do you vi a file so that you can see special characters. I believe my /etc/passwd file is being corrupted during an upgrade process, however the files... (6 Replies)
Discussion started by: Recon
6 Replies

9. UNIX for Dummies Questions & Answers

Quick Question

Hello There! I am trying to write this SIMPLE script in Bourne Shell but I keep on getting syntax errors. Can you see what I am doing wrong? I've done this before but I don't see the difference. I am simply trying to take the day of the week from our system and when the teachers sign on I want... (7 Replies)
Discussion started by: catbad
7 Replies

10. UNIX for Dummies Questions & Answers

A Quick Question

Wat is the difference between the cp mv ln etc in /usr/sbin/static and cp mv ln functions in /usr/bin (4 Replies)
Discussion started by: DPAI
4 Replies
Login or Register to Ask a Question