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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get info between ' '

Status
Not open for further replies.

Bootstrap

Technical User
Nov 9, 2001
12
US
Hello. I'm need help trimming of some single quotes. Not sure how to handle this. Here's what I'm doing.

file core|awk '{print $5}' > coreinfo.out

This leaves me with output similar to:

'name.1.0.0'

How can I further trim of the ticks? I just want the info in between the single quotes for use in another script.

Thanks in advance.

Robert
 
All awk solution:
BEGIN {
cc = sprintf("%c", 0x27)
}
{
gsub(cc,"",$5)
print $5
}'
 
Assuming your output looks like this:

dump 123456789 caused by 'name.1.0.0'

You can use 'cut' with the single quote as the field
separator and print field two:

file core | cut -d"'" -f2

This prints name.1.0.0

-jim

 
Thanks to all three of you. I was not using cut properly and didn't think to us tr. Thanks again.

Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top