LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 09-11-2008, 09:41 AM   #1
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Rep: Reputation: 30
using sed to remove a strange token


How would one use sed to go about removing a token like: &word;

I've tried:

1. sed 's/&word;/ /'
2. sed 's/\&word\;/ /'

things like that.

Any suggestions?
 
Old 09-11-2008, 09:45 AM   #2
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 31
Umm, they both worked for me exactly as you have typed them
 
Old 09-11-2008, 09:49 AM   #3
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
weird...

do you think it may be a problem if they are not separated by a space? For example, what if you have asghasgpn&word;asdgnapsd as your input. Will it still remove it?

Thanks.
 
Old 09-11-2008, 09:52 AM   #4
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 31
yep, sure does
 
Old 09-11-2008, 09:54 AM   #5
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
good grief this is weird
 
Old 09-11-2008, 10:04 AM   #6
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 31
certainly. Do you have any aliases set up for the sed command?

Code:
alias | grep sed
and what distro you running and what version of sed?

EDIT: nevermind version, I see it's probably ubuntu from your profile
 
Old 09-11-2008, 10:15 AM   #7
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
actually, I just ssh'd to my school's server and I'm running it from there... so I'm not sure of the details. When I run the alias command as suggested, I get nothing.
 
Old 09-11-2008, 10:19 AM   #8
jacksmash
Member
 
Registered: Nov 2003
Location: Ontario, Canada
Distribution: Ubuntu
Posts: 269

Original Poster
Rep: Reputation: 30
oh.. and I'm not sure what version of sed either. I would use another tool like 'tr', but I don't think you can remove specific words with 'tr'.
 
Old 09-11-2008, 10:20 AM   #9
CRC123
Member
 
Registered: Aug 2008
Distribution: opensuse, RHEL
Posts: 374
Blog Entries: 1

Rep: Reputation: 31
Well if it's a school server, ask the system administrator what the heck is going on . Have you tried the commands on your home box? Do you get different results?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
strange SED question pixellany Linux - Software 8 12-02-2007 05:04 AM
using sed to remove all but ip addresses chess Programming 10 07-02-2007 01:54 AM
help with sed to remove all text except for some Benanzo Linux - Software 7 01-04-2007 06:21 AM
how to remove path using sed dtcs Programming 2 12-25-2006 04:29 PM
Remove string in sed twantrd Programming 7 09-13-2006 02:28 PM


All times are GMT -5. The time now is 07:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration