Skip to main content
added 162 characters in body
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

You don't have to cut by -character count. Instead, you can cut on a specified -delimiter.

grep '^<gc type="global"' <infile | cut -d\" -f4 

80 81 82 

That gets only the 4th "-delimited field on a line. And so that field can be as many characters - or digits if you prefer - as you like, so long as none of them are double-quotes.

But you don't have to do that either if you want the whole line.

sed -e'/^<gc type="global"/!{g;/./q;d;}' -e'h;$!d' <infile 

You don't have to cut by -character count. Instead, you can cut on a specified -delimiter.

grep '^<gc type="global"' <infile | cut -d\" -f4 

80 81 82 

That gets only the 4th "-delimited field on a line. And so that field can be as many characters - or digits if you prefer - as you like, so long as none of them are double-quotes.

You don't have to cut by -character count. Instead, you can cut on a specified -delimiter.

grep '^<gc type="global"' <infile | cut -d\" -f4 

80 81 82 

That gets only the 4th "-delimited field on a line. And so that field can be as many characters - or digits if you prefer - as you like, so long as none of them are double-quotes.

But you don't have to do that either if you want the whole line.

sed -e'/^<gc type="global"/!{g;/./q;d;}' -e'h;$!d' <infile 
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

You don't have to cut by -character count. Instead, you can cut on a specified -delimiter.

grep '^<gc type="global"' <infile | cut -d\" -f4 

80 81 82 

That gets only the 4th "-delimited field on a line. And so that field can be as many characters - or digits if you prefer - as you like, so long as none of them are double-quotes.