Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のコマンドがあります。
ls -l /tmp | awk '$3=="'$USER'" {print $NF}'
/tmp$USERに属するファイルとディレクトリの名前を出力することになっています。通常のファイルとディレクトリでは正常に機能しますが、出力には $USER に属する隠しファイルとディレクトリは含まれません。
/tmp
それを修正するために何が必要ですか?
これを行う正しい方法:
ls -al /tmp | awk '$3==u {print $NF}' u="$USER"
また
ls -al /tmp | awk -v u="$USER" '$3==u {print $NF}'
試す:ls -al /tmp | awk '$3=="'$USER'" {print $NF}'
ls -al /tmp | awk '$3=="'$USER'" {print $NF}'