| View previous topic :: View next topic |
| Author |
Message |
Cpuswe

Joined: 15 Mar 2005 Posts: 2214 Location: Karlskrona, Sweden
|
Posted: Fri Nov 10, 2006 6:56 pm Post subject: Help with *nix command SED? |
|
|
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 |
|
 |
Cpuswe

Joined: 15 Mar 2005 Posts: 2214 Location: Karlskrona, Sweden
|
Posted: Fri Nov 10, 2006 7:35 pm Post subject: |
|
|
| chiptalk wrote: | Use perl.
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 . 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 |
|
 |
gshv

Joined: 01 Feb 2003 Posts: 7898 Location: Fairfax, VA USA
|
Posted: Fri Nov 10, 2006 8:08 pm Post subject: |
|
|
This should work in perl:
| Code: | | cat you_file | perl -n -e '/(\d+)/; print $1, "\n"' |
Gennadiy |
|
| Back to top |
|
 |
Cpuswe

Joined: 15 Mar 2005 Posts: 2214 Location: Karlskrona, Sweden
|
Posted: Sat Nov 11, 2006 4:07 am Post subject: |
|
|
| 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 |
|
 |
Cpuswe

Joined: 15 Mar 2005 Posts: 2214 Location: Karlskrona, Sweden
|
Posted: Sat Nov 11, 2006 12:59 pm Post subject: |
|
|
| 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 |
|
 |
|