I have a variable that has several items in it seperated by a space:
JUNK="item1 item2 item3"
echo $JUNK
item1 item2 item3
Depending on input from the user (via a script), I may need to remove any number of those "items" AND still leave once space between them:
echo $JUNK | *** magical sed command that is eluding me ***
item1 item2 or output could be
item1 item3 or
item2 item3 or
item3 etc. depending what what as entered via the user.
I have been able to match and remove beginning, middle and end leaving 1 space between (if needed), but not all of the above. To restate that in another way - I need to be able to find itemX anywhere in the string and remove it.
Any help would be greatly appreciated.
JUNK="item1 item2 item3"
echo $JUNK
item1 item2 item3
Depending on input from the user (via a script), I may need to remove any number of those "items" AND still leave once space between them:
echo $JUNK | *** magical sed command that is eluding me ***
item1 item2 or output could be
item1 item3 or
item2 item3 or
item3 etc. depending what what as entered via the user.
I have been able to match and remove beginning, middle and end leaving 1 space between (if needed), but not all of the above. To restate that in another way - I need to be able to find itemX anywhere in the string and remove it.
Any help would be greatly appreciated.