Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field removal query

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
[tt]

Hi, I would like to remove the "/bin/oops" entry from the comma separated input file. The script should be capable of removing "/bin/oops" regardless of its position in the string, examples are below.

Input file:
shells = /bin/oop,/bin/sh,/bin/bsh,/bin/ksh,/bin/tsh
shells = /bin/sh,/bin/bsh,/bin/ksh,/bin/tsh,/bin/oop
shells = /bin/sh,/bin/bsh,/bin/oop,/bin/ksh,/bin/tsh

Desired output:
shells = /bin/sh,/bin/bsh,/bin/ksh,/bin/tsh
shells = /bin/sh,/bin/bsh,/bin/ksh,/bin/tsh
shells = /bin/sh,/bin/bsh,/bin/ksh,/bin/tsh

Thanks in advance




[/tt]
 
A starting point:
sed 's!/bin/oop!!g;s! ,! !;s!,,!,!g;s!,$!!' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top