Results 1 to 3 of 3
I have a problem where I need to examine files like the one below. I need to find the text "GCH:GCH" and return the next 2 characters, in this case ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-16-2011 #1Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
Bash problem, returning data from a file
I have a problem where I need to examine files like the one below. I need to find the text "GCH:GCH" and return the next 2 characters, in this case I need to return "L1" ("GCHL1" would be fine also). Any idea how I can do this in bash?
Any help would be appreciated.
Thanks,
Tim J.
*******************************
^FO 65,126,^AD ^FDURCUL ^FS
^FO 65,143,^AD ^FD^FS
^FO355,154,^A0,25,25 ^FD^FS
^FO345,161, ^GB80,30^FS
^FO100,160,^AF ^FDJ815^FS
^FO165,160,^A0,30,30 ^FD0026^FS
^FX under Peel Line ^FS
^LH0,0^FS
^FO430, 76,^A0R,30,25 ^FDGCH:GCHL1^FS
^FO25,60,^ADR ^FDSTAFF M,M^FS
^LH0,0^FS
^XZ
************************************
- 06-16-2011 #2I tried to write that regex greedy, but it seems it's already too late this dayCode:
sed -n 's/\(.*\)GCH:GCH\(..\)\(.*\)/\2/p' <TEXTFILE>
You must always face the curtain with a bow.
- 06-16-2011 #3Just Joined!
- Join Date
- Jun 2011
- Posts
- 2
Thank you! That's perfect.


Reply With Quote
