0

Using this question I've tried to match whole words with awk.

In my homerdir there's a file called .bashrc, but when I try to use:

ls -la | awk '$9 ~ /\<.bashrc\>/'

It doesn't show anything.

Also tried:

ls -la | awk '{if($9 ~ "^.bashrc" && $9 ~ "$.bashrc") echo $0}'

Still doesn't work.

What am I doing wrong?

asaf92
  • 101

1 Answers1

2

~ is used for string comparison, it is not for exact match.

You could use ==. Your command should be:

ls -la | awk '$9 == ".bashrc"'