Reputation: 161
I have a multiple strings in a file that looks like this
TXT 20131101 094502,20131101 094502,Fri Nov 1 09:45:02 UTC 2013;
I want a regex that will get everything after TXT and only display that up until the ; using sed or awk
I have tried many ways but I cant seem to get it to stop at the ;
Thanks for any help
Upvotes: 1
Views: 1523
Reputation: 10039
sed "s/TXT\([^;]*\);.*/\1/"
between TXT (so also first space if any) and first ; (not included)
reply from devnull include the "TXT" in the output
Upvotes: 0
Reputation: 123608
I want a regex that will get everything after TXT and only display that up until the ;
grep -oP 'TXT[^;]*' filename
Using awk
:
awk -F';' '{print $1}' filename
Using sed
:
sed 's/\([^;]*\).*/\1/' filename
Upvotes: 6