Frage

I have the following command:

ls -l /tmp | awk '$3=="'$USER'" {print $NF}'

which is supposed to print the name of files and directories under /tmp which belongs to the $USER. It works fine for the normal files and directories but the output doesn't include hidden files and directories which belong to the $USER.

What is needed to fix it?

War es hilfreich?

Lösung

Correct way to do this:

ls -al /tmp | awk '$3==u {print $NF}' u="$USER"

or

ls -al /tmp | awk -v u="$USER" '$3==u {print $NF}'

Andere Tipps

Try: ls -al /tmp | awk '$3=="'$USER'" {print $NF}'

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top