UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 26th, 2004, 09:38 AM
gtsjames gtsjames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 gtsjames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question sed help needed

I am trying to write a script that will parse a listing that I get from grep. The problem I am running into is that I cannot figure out how to get sed to remove a / from the line. I would appreciate any pointers on looking for the / or removing a whole path such as /usr/share/ or some like listing.
-SJ

Reply With Quote
  #2  
Old October 26th, 2004, 11:03 AM
satyap satyap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 210 satyap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 49 sec
Reputation Power: 4
sed "s/\///;"

Reply With Quote
  #3  
Old October 27th, 2004, 04:36 AM
andyb1ack andyb1ack is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 60 andyb1ack User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 14 sec
Reputation Power: 4
you might want to check out commands basename and dirname

Reply With Quote
  #4  
Old October 27th, 2004, 05:55 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,089 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 3 h 40 m 34 sec
Reputation Power: 9
satyap is correct, that is the elegant way to do it
(only the ';' is superflous (in this exemple)) and
pay attention " is not '
an other way, tell sed to use an other field-sep, so
s/abc/qwe/g
is the same as
s,abc,qwe,g
but now 'abc' could be 'ab/c'
do you see ?
an other Q is: why sed the output of grep ?
why not just let sed do the whole job ? (it sure can it!!)

Reply With Quote
  #5  
Old October 28th, 2004, 12:02 AM
gtsjames gtsjames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 gtsjames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Re: sed help needed

Reason I a, using grep to get initial out is that I am generating a PPD file and model name lising on the fly by using grep and the ModelName as my search term. This keeps me from having to update a file manually with the name of a model and the associated PPD.
Ok, the "sed "s/\///;" option seems like it should do the trick, but is there anyway to do it with a regexp?? Dont mean to be be choosy, but I thought about it afterwards and now I cant seem to let it go.
I will however use the initial solution as soon as I get into office in the morning

Reply With Quote
  #6  
Old October 28th, 2004, 07:12 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,089 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 3 h 40 m 34 sec
Reputation Power: 9
the reason why you use grep and sed is
you never checked: grep can a lot
and sed a lot more. so
a well constructed grep OR sed easy can replace a grep|sed
what is 's/\///' when NOT a regexpr ???

Reply With Quote
  #7  
Old October 28th, 2004, 11:06 AM
gtsjames gtsjames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 gtsjames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

Quote:
Originally Posted by guggach
the reason why you use grep and sed is
you never checked: grep can a lot
and sed a lot more. so
a well constructed grep OR sed easy can replace a grep|sed
what is 's/\///' when NOT a regexpr ???

I guess I may not have clearly stated what I was trying to accomplish. What I am looking at now is having to have 's/\///' for each "/" character that I want to remove, I was hoping there may have been a more elegant solution to remove multiples at the same time instead of a single, or remove a "/" followed by a text string.
PS if you know how to get sed to seach each file in a specified directory for a particular string and and return the entire line I'm game for knowing. I'm a newbie to sed so please forgive my ignorance of its capabilities

Reply With Quote
  #8  
Old October 28th, 2004, 02:36 PM
satyap satyap is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 210 satyap User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 49 sec
Reputation Power: 4
sed "s/\///g"

(see, guggach, I removed the ; :-) )

Reply With Quote
  #9  
Old October 28th, 2004, 03:57 PM
gtsjames gtsjames is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 gtsjames User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by satyap
sed "s/\///g"

(see, guggach, I removed the ; :-) )

I appreciate it tons.....

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > sed help needed


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway