Remove exact matching word using sed [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
-1
down vote

favorite












I want to remove word 'foggy' from the string. It fails. Why?



echo 'foggy light' | sed 's/<foggy>//g'









share|improve this question















closed as off-topic by muru, pa4080, karel, Zanna, Eric Carvalho Feb 18 at 18:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, pa4080, karel, Zanna, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.












  • What version of Ubuntu? What's the output of sed --version?
    – muru
    Feb 18 at 11:39










  • @userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
    – muru
    Feb 18 at 12:24











  • For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
    – user unknown
    Feb 18 at 12:33










  • sed version 4.0
    – Josef Klimuk
    Feb 18 at 13:13










  • Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
    – muru
    Feb 18 at 13:18














up vote
-1
down vote

favorite












I want to remove word 'foggy' from the string. It fails. Why?



echo 'foggy light' | sed 's/<foggy>//g'









share|improve this question















closed as off-topic by muru, pa4080, karel, Zanna, Eric Carvalho Feb 18 at 18:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, pa4080, karel, Zanna, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.












  • What version of Ubuntu? What's the output of sed --version?
    – muru
    Feb 18 at 11:39










  • @userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
    – muru
    Feb 18 at 12:24











  • For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
    – user unknown
    Feb 18 at 12:33










  • sed version 4.0
    – Josef Klimuk
    Feb 18 at 13:13










  • Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
    – muru
    Feb 18 at 13:18












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I want to remove word 'foggy' from the string. It fails. Why?



echo 'foggy light' | sed 's/<foggy>//g'









share|improve this question















I want to remove word 'foggy' from the string. It fails. Why?



echo 'foggy light' | sed 's/<foggy>//g'






sed






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 11:39









muru

130k19275470




130k19275470










asked Feb 18 at 10:49









Josef Klimuk

542112




542112




closed as off-topic by muru, pa4080, karel, Zanna, Eric Carvalho Feb 18 at 18:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, pa4080, karel, Zanna, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by muru, pa4080, karel, Zanna, Eric Carvalho Feb 18 at 18:42


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – muru, pa4080, karel, Zanna, Eric Carvalho
If this question can be reworded to fit the rules in the help center, please edit the question.











  • What version of Ubuntu? What's the output of sed --version?
    – muru
    Feb 18 at 11:39










  • @userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
    – muru
    Feb 18 at 12:24











  • For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
    – user unknown
    Feb 18 at 12:33










  • sed version 4.0
    – Josef Klimuk
    Feb 18 at 13:13










  • Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
    – muru
    Feb 18 at 13:18
















  • What version of Ubuntu? What's the output of sed --version?
    – muru
    Feb 18 at 11:39










  • @userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
    – muru
    Feb 18 at 12:24











  • For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
    – user unknown
    Feb 18 at 12:33










  • sed version 4.0
    – Josef Klimuk
    Feb 18 at 13:13










  • Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
    – muru
    Feb 18 at 13:18















What version of Ubuntu? What's the output of sed --version?
– muru
Feb 18 at 11:39




What version of Ubuntu? What's the output of sed --version?
– muru
Feb 18 at 11:39












@userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
– muru
Feb 18 at 12:24





@userunknown of course: GNU sed, installed by default on all versions of Ubuntu, has < and > for matching start-of-word and end-of-word. I suspect this is yet another Android question. OP has been know to post a number of questions about some Android app that provides Unix commands, while pretending it is Ubuntu OP is using.
– muru
Feb 18 at 12:24













For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
– user unknown
Feb 18 at 12:33




For removing the word foggy in above scenario, you don't need start-of-word/end-of-word-markers.
– user unknown
Feb 18 at 12:33












sed version 4.0
– Josef Klimuk
Feb 18 at 13:13




sed version 4.0
– Josef Klimuk
Feb 18 at 13:13












Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
– muru
Feb 18 at 13:18




Which it is not on any current version of Ubuntu: packages.ubuntu.com/search?keywords=sed, so yet again an off-topic question.
– muru
Feb 18 at 13:18










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










In the above string, you don't need start-of-word/end-of-word markers and you may use:



echo 'foggy light' | sed 's/foggy//g'


For the additional question in the comment:



Indeeed, my sed version



sed --version
sed (GNU sed) 4.2.2


supports the Syntax with <...>



echo 'foggy foggylight' | sed 's/<foggy>//g'
foggylight


If it doesn't work for you, report your sed version and read its manpage. For my sed, this syntax works too:



echo 'foggy foggylight' | sed 's/bfoggyb//g'
foggylight


b can be memorized as boundary.






share|improve this answer


















  • 1




    It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
    – muru
    Feb 18 at 12:26










  • Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
    – Josef Klimuk
    Feb 18 at 13:11







  • 1




    @JosefKlimuk: Added extension
    – user unknown
    Feb 18 at 13:35

















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










In the above string, you don't need start-of-word/end-of-word markers and you may use:



echo 'foggy light' | sed 's/foggy//g'


For the additional question in the comment:



Indeeed, my sed version



sed --version
sed (GNU sed) 4.2.2


supports the Syntax with <...>



echo 'foggy foggylight' | sed 's/<foggy>//g'
foggylight


If it doesn't work for you, report your sed version and read its manpage. For my sed, this syntax works too:



echo 'foggy foggylight' | sed 's/bfoggyb//g'
foggylight


b can be memorized as boundary.






share|improve this answer


















  • 1




    It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
    – muru
    Feb 18 at 12:26










  • Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
    – Josef Klimuk
    Feb 18 at 13:11







  • 1




    @JosefKlimuk: Added extension
    – user unknown
    Feb 18 at 13:35














up vote
2
down vote



accepted










In the above string, you don't need start-of-word/end-of-word markers and you may use:



echo 'foggy light' | sed 's/foggy//g'


For the additional question in the comment:



Indeeed, my sed version



sed --version
sed (GNU sed) 4.2.2


supports the Syntax with <...>



echo 'foggy foggylight' | sed 's/<foggy>//g'
foggylight


If it doesn't work for you, report your sed version and read its manpage. For my sed, this syntax works too:



echo 'foggy foggylight' | sed 's/bfoggyb//g'
foggylight


b can be memorized as boundary.






share|improve this answer


















  • 1




    It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
    – muru
    Feb 18 at 12:26










  • Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
    – Josef Klimuk
    Feb 18 at 13:11







  • 1




    @JosefKlimuk: Added extension
    – user unknown
    Feb 18 at 13:35












up vote
2
down vote



accepted







up vote
2
down vote



accepted






In the above string, you don't need start-of-word/end-of-word markers and you may use:



echo 'foggy light' | sed 's/foggy//g'


For the additional question in the comment:



Indeeed, my sed version



sed --version
sed (GNU sed) 4.2.2


supports the Syntax with <...>



echo 'foggy foggylight' | sed 's/<foggy>//g'
foggylight


If it doesn't work for you, report your sed version and read its manpage. For my sed, this syntax works too:



echo 'foggy foggylight' | sed 's/bfoggyb//g'
foggylight


b can be memorized as boundary.






share|improve this answer














In the above string, you don't need start-of-word/end-of-word markers and you may use:



echo 'foggy light' | sed 's/foggy//g'


For the additional question in the comment:



Indeeed, my sed version



sed --version
sed (GNU sed) 4.2.2


supports the Syntax with <...>



echo 'foggy foggylight' | sed 's/<foggy>//g'
foggylight


If it doesn't work for you, report your sed version and read its manpage. For my sed, this syntax works too:



echo 'foggy foggylight' | sed 's/bfoggyb//g'
foggylight


b can be memorized as boundary.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 18 at 13:35









muru

130k19275470




130k19275470










answered Feb 18 at 12:18









user unknown

4,80622151




4,80622151







  • 1




    It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
    – muru
    Feb 18 at 12:26










  • Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
    – Josef Klimuk
    Feb 18 at 13:11







  • 1




    @JosefKlimuk: Added extension
    – user unknown
    Feb 18 at 13:35












  • 1




    It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
    – muru
    Feb 18 at 12:26










  • Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
    – Josef Klimuk
    Feb 18 at 13:11







  • 1




    @JosefKlimuk: Added extension
    – user unknown
    Feb 18 at 13:35







1




1




It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
– muru
Feb 18 at 12:26




It's not < and > but < and>. See gnu.org/software/sed/manual/sed.html#regexp-extensions
– muru
Feb 18 at 12:26












Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
– Josef Klimuk
Feb 18 at 13:11





Ok. And how to drop just the word foggy alone, not touching foggylight? echo 'foggy foggylight' | sed 's/foggy//g'
– Josef Klimuk
Feb 18 at 13:11





1




1




@JosefKlimuk: Added extension
– user unknown
Feb 18 at 13:35




@JosefKlimuk: Added extension
– user unknown
Feb 18 at 13:35


Popular posts from this blog

Which professions warranted travel in Medieval times?

How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

Trouble downloading packages list due to a “Hash sum mismatch” error