Matching '/' in SED


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Matching '/' in SED
# 1  
Old 07-19-2005
Matching '/' in SED

Hello,

I have a list of filename is a file called list.dat.
The filenames appear in the list.dat file as this:

Code:
./set.class
./one.class


I want to delete these file names from the list file using sed. To test I was trying to match just the set.class. Eventually I want to delete all the filenames that appear in the file with this match.
The command I am executing is:

Code:
cat list.dat| sed -n -e /^.\/set*/d

I am receiving a "command garbled". Can anyone see a problem with this command? Thank you.
# 2  
Old 07-19-2005
Did you forget the '

Code:
sed -n -e '/^.\/set*/d' list.dat

Vino

Last edited by vino; 07-19-2005 at 12:55 PM..
# 3  
Old 07-19-2005
Rookie Mistake

Thanks Vino. That worked. I used

Code:
sed -n -e '/\.\/\.*\./p'

to find the filenames that have the hidden filename convention like:

Code:
./.webappCorpActions.java
./.webappGtp.docs

How can I exclude files that do not end in a .'ext'? I have some files that have names like this that I do not want to delete

Code:
./.hidden
./.iwantthisfile

I tried these...
Code:
sed -n -e '/\.\/\.*\.[a-z]/p'
sed -n -e '/\.\/\.*\.*$/p'

but they still return a file like ./.file.. Any suggestions?

Thanks
# 4  
Old 07-19-2005
sed -n '/^\.\/\.[^.]*\./p'
# 5  
Old 07-19-2005
Instead of the previous post

sed -n '/^\.\/\.[^.][^.]*\./p'

The repeated [^.] is to ensure at least one non '.' char.

Last edited by reborg; 07-19-2005 at 05:37 PM.. Reason: add missing quote
# 6  
Old 07-19-2005
MySQL

Thank you very much!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed matching

I need to extract text between numerous story-title=" " <trending-story id="US_lnk_swT_mwAwAABMLM_en" sparkline="story.sparkline" story-index="(pageIndex * ctrl.trendingStoriesPerPage) + storyIndex + 1" story-title="Vaccine, Zika virus" story-title-array="story.entityNames"... (2 Replies)
Discussion started by: p1ne
2 Replies

2. Shell Programming and Scripting

Use sed to get first matching pattern

HI, I have a file: listenerport: - 1521 - 10520 - 10521 - 10522 - 10523 instances: listenerport: listenerport: - 1521 - 10540 - 10541 - 10542 - 10543 instances: ... (5 Replies)
Discussion started by: netbanker
5 Replies

3. Shell Programming and Scripting

Help with sed pattern matching

Hi My log file is Testtmp2 cat Testtmp2 12:12:38 12:14:29 12:17:34 12:19:08 12:20:10 12:21:35 12:22:20 12:22:26 12:22:34 12:22:38 12:28:14 12:31:35 12:32:50 12:33:04 (3 Replies)
Discussion started by: rahkumar
3 Replies

4. Shell Programming and Scripting

help! Pattern Matching in vi or sed

I have a bunch of conf files, that contain the fully qualified names of servers. I would like to be able to use some sort of pattern matching with sed or vi, or whatever, to pull out the fully qualified server names, and dump them in a file. It just needs to work across several unix os. So, I... (4 Replies)
Discussion started by: tabini
4 Replies

5. Shell Programming and Scripting

SED pattern matching help

Hello All, I have the following lines in a file <address location="test" ConnectionName="test" /> I want to replace the above lines by <address location="test123" /> I am usind SED and not able to remove the new line characters between the two lines. Can anyone please help... (4 Replies)
Discussion started by: ramk
4 Replies

6. Shell Programming and Scripting

sed pattern matching

Unfortunately this chap has been banned for some reason and I was looking forward to the resolution of his question: - https://www.unix.com/shell-programming-scripting/123118-append-position-28-33-a.html He was asking if you can use sed to match a pattern you want to replace within a... (6 Replies)
Discussion started by: steadyonabix
6 Replies

7. Shell Programming and Scripting

sed pattern matching

Hi all, if I have the following piece (repeating) of text within a file and I wish to delete it via sed a b c d e <tr> <td><img alt="" height="1" width="3" src="/testweb/view/browser/images/shim.gif"></td><td><img alt="" height="1" ... (4 Replies)
Discussion started by: srage
4 Replies

8. Shell Programming and Scripting

matching ' in sed

Hi, I need to match some text in sed that contains the ' character. I have tried a escaped character but it doesn't work (that is, something like sed 's/\'/whatever/g') Does anyone know how to specify the ' character in the left part of sed? Thanks in advance. (2 Replies)
Discussion started by: luisrr
2 Replies

9. Shell Programming and Scripting

Matching everything on a line using sed

I having a little trouble. I want to substitute whatever is on the first line no matter what is on it with the word BEGINNING. So on the first line, the only word on it is BEGINNING I tried the following: sed '1,1s/^ *.*$/BEGINNING/g' $FILE It works only if the 1st line starts with a... (2 Replies)
Discussion started by: quixoticking11
2 Replies

10. Shell Programming and Scripting

Pattern matching sed

MSG="THERE WERE XX RECORDS IN ERROR TABLE,AAAA, WHEN LOADING THE BBBB TABLE WITH EXTRACT FROM CCCC INTO TABLES FOR , DATABASE DDDD." echo "$MSG" > /tmp/mplanmsg.$$.out I wan to replace XX with the content in $recordXX cat /tmp/mplanmsg.$$.out|sed 's/XX/\$recordXX/g'| sed... (3 Replies)
Discussion started by: leemjesse
3 Replies
Login or Register to Ask a Question