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!

String awk

Status
Not open for further replies.

ranjit

Technical User
Apr 14, 2000
131
GB
What is the best way to awk out the line of text between <>

Input file:

DataLine756<TRANS:6707,Bank of America,INV.7868467>#L$T

Desired output:

TRANS:6707,Bank of America,INV.7868467
 
Try

{
sub(/^[^<]*</,"")
sub(/>.*$/,"")
print
}


CaKiwi
 
Code:
BEGIN {
  FS="(<)|(>)"
}
{
  for (i=0; i<=NF; i=i+2)
    print $i
}

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
don't forget [bold]multiples[/b]

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
And the sed way:
sed -e 's!.*<!!;s!>.*!!' /path/to/input >output

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

Part and Inventory Search

Sponsor

Back
Top