Shell script to delete some lines...
I have a text file as follows :
7294 S/3529/1994() 7295 S/3540/1994() 7296 S/3545/1994() A. 7297 S/3546/1994() 7298 S/3548/1994() "," 7299 S/3551/1994() & 7300 S/3557/1994() CHOL The first column is the serial no. I want to delete all the lines which does not start with the serial number. How can it be done using shell script or sed ? Jagdish |
Assuming your serial number is exactly 4 digits - if it isn't, you'll need to explain the rules
Code:
sed -r '/^[0-9]{4}/!d' yourfile |
Or use the same regex, but instead extract all the wanted lines with grep.
Code:
grep -E '^[0-9]{4}' infile >outfile |
All times are GMT -5. The time now is 02:08 AM. |