문제

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?

도움이 되었습니까?

해결책

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}'

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top