Help with *nix command SED?

Post new topic   Reply to topic    CPU-World.com forums Forum Index -> Off Topic
View previous topic :: View next topic  
Author Message
Cpuswe



Joined: 15 Mar 2005
Posts: 2214
Location: Karlskrona, Sweden

PostPosted: Fri Nov 10, 2006 6:56 pm    Post subject: Help with *nix command SED? Reply with quote

Hi!

I am fooling around trying to automatically create a google sitemap (an xml file describing the site.)

I am going to generate this with a simple script using a sql dump as input, but i need to trim some stuff before generating.

I have managed to grep/awk out a textfile with page numbers looking like this

('323',
('400',
('243',
...

I have used SED to trim various ( and , but i cant get rid of the single qoute '. The syntax i used to get rid of the ( is sed 's/(//' but as you can see sed uses a ' in the command syntax.

What is the right syntax to get rid of both ' ? I have tried \ " but to no luck. I just want the numbers, nothing else.

/T

_________________
My collection: http://www.cpucollection.se :::::: http://www.chipdb.org Photos of chips you never knew existed. Now over 6000 different chips in the database.
Back to top
View user's profile Send private message [ Hidden ] Visit poster's website
Cpuswe



Joined: 15 Mar 2005
Posts: 2214
Location: Karlskrona, Sweden

PostPosted: Fri Nov 10, 2006 7:35 pm    Post subject: Reply with quote

chiptalk wrote:
Use perl. Wink

You should be able to do sed 's/\'//g'


My knowledge in perl or any other programming language is zero so i go with the first that worked, this time sed,grep and some awk Wink. But i would love to learn any of these programming languages out there.

sed 's/\'//g' does not work. Just getting a >

_________________
My collection: http://www.cpucollection.se :::::: http://www.chipdb.org Photos of chips you never knew existed. Now over 6000 different chips in the database.
Back to top
View user's profile Send private message [ Hidden ] Visit poster's website
gshv



Joined: 01 Feb 2003
Posts: 7898
Location: Fairfax, VA USA

PostPosted: Fri Nov 10, 2006 8:08 pm    Post subject: Reply with quote

This should work in perl:

Code:
cat you_file | perl -n -e '/(\d+)/; print $1, "\n"'


Gennadiy
Back to top
View user's profile Send private message [ Hidden ] Visit poster's website
Cpuswe



Joined: 15 Mar 2005
Posts: 2214
Location: Karlskrona, Sweden

PostPosted: Sat Nov 11, 2006 4:07 am    Post subject: Reply with quote

chiptalk wrote:
Try sed "s/\'//g"


That did it. Double quotes. But with no \ before '. sed "s/'//g"

Will try the perl way too!

Thanks!

_________________
My collection: http://www.cpucollection.se :::::: http://www.chipdb.org Photos of chips you never knew existed. Now over 6000 different chips in the database.
Back to top
View user's profile Send private message [ Hidden ] Visit poster's website
Cpuswe



Joined: 15 Mar 2005
Posts: 2214
Location: Karlskrona, Sweden

PostPosted: Sat Nov 11, 2006 12:59 pm    Post subject: Reply with quote

chiptalk wrote:
Perl is a lot more powerful, and easy to learn.


Yes, it seem so. It looks like i have to do some perl when converting unix timestamp to ordinary date/time.

/T

_________________
My collection: http://www.cpucollection.se :::::: http://www.chipdb.org Photos of chips you never knew existed. Now over 6000 different chips in the database.
Back to top
View user's profile Send private message [ Hidden ] Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    CPU-World.com forums Forum Index -> Off Topic All times are GMT - 5 Hours
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Powered by phpBB © 2001 phpBB Group