LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   using sed to remove a strange token (https://www.linuxquestions.org/questions/programming-9/using-sed-to-remove-a-strange-token-669227/)

jacksmash 09-11-2008 09:41 AM

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?

CRC123 09-11-2008 09:45 AM

Umm, they both worked for me exactly as you have typed them :)

jacksmash 09-11-2008 09:49 AM

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.

CRC123 09-11-2008 09:52 AM

yep, sure does

jacksmash 09-11-2008 09:54 AM

good grief this is weird :(

CRC123 09-11-2008 10:04 AM

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 ;)

jacksmash 09-11-2008 10:15 AM

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.

jacksmash 09-11-2008 10:19 AM

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'.

CRC123 09-11-2008 10:20 AM

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?


All times are GMT -5. The time now is 04:56 PM.