Tuesday, June 1, 2021

awk - Exclude or Include Records from a fixed-width file

The below command gets the records that have a value "new" in the given position (in this case the file was fixed-width). All other records which do not have the value "new" are ignored.

 awk '{if (substr($0, 7, 3) == "new") print $0}' file1.txt

substr 7, 3 is the starting position 7 with 3 characters

No comments:

Post a Comment