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!

Remove all but the contents between [********]

Status
Not open for further replies.

mrgulic

Technical User
Sep 18, 2001
248
US
I have some output that can be either:

Medium label : CS7009
or
Medium label : [CS7324D] CS7324

The code I have works good until the 2nd type of output appears.

I want to be able to either remove the "[CS7324D]" or just grab the contents in between the "[ ]".

This is on a "while......do" loop with an array so it has be able to also work with the first output.

Thanks
 
I'm not 100% clear on what you want, but you could just use $NF to grab the last field on the line? Can you post some of your existing code?

Or if you just want to strip out anything between square brackets you could use sed 's/\[.*\]//g' on the output first.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top