Regarding Searching Pattern

Hi Guys,

Can you help with the shell script:
I would like to search a fixed width pattern from a file
say for each line from a fixed position and lenght it has to return all rows from the file.

Example:
To search the third column for "def" it has to return 1 and 4th rows only

1|abc|def|hgd|sda|XYZ|sdd
2|FSD|sdf|fds|def|ads|XYZ
3|has|sdg|ret|def|asd|SDF
4|fsd|def|gsh|def|hjf|6545
5|sdf|hdf|def|fdg|8747389|736
6|def|dfs|dsg|def|837|dsg"|388

I have tried using "awk"
is there a way we can combine substr and awk.

Thanks in advance. :slight_smile:
Sat.

awk -F"|" ' $3 == "def" { print $0 }' f

Great!!!

Thank you very much

Sat.