Text file manipulation: alphanumeric strings
Hi,
I am just getting to grips with writing my first shell script, but have got stuck on what is probably something fairly straightforward. Hopefully you can help. I have a text file which contains some lines of interest and many lines which are not required, so I've been using egrep and awk to create a new output file containing only the lines of interest. The problem I have is that I would like my file to include lines which contain alphanumeric codes like 'AB1r' but not 'AB1'. I have many different alphanumeric combinations in the same format, but am only interested in the lines that contain an alphanumeric code ending in lower-case r . Note, it is important that the whole line in which the alphanumeric code sits is selected, not just the alphanumeric code itself. Can you help please? Thanks, Charlotte |
Code:
grep -E '[a-zA-Z]{2}[0-9]r' abc.txt Forgot: welcome to LQ |
Thank you Wim Sturkenboom, that works perfectly!
Best wishes to you. |
All times are GMT -5. The time now is 06:33 AM. |