How to run grep on a single column?

One more time awk saves the day!

Here's a straightforward way to do it, with a relatively simple syntax:

ls -l | awk '{if ($3 == "rahmu") print $0;}'

or even simpler: (Thanks to Peter.O in the comments)

ls -l | awk '$3 == "rahmu"' 

If you are looking to match only part of the string on a given column, you can use advice from https://stackoverflow.com/questions/17001849/awk-partly-string-match-if-column-partly-matches

some_command | awk '$6 ~ /string/'

If by column, you mean fixed-size column, you could:

ls -l | grep "^.\{15\}rahmu"

where ^ means the beginning of the line, . means any character and \{15\} means exactly 15 occurrences of the previous character (any character in this case).

Tags:

Grep

Awk