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=="'$USER'" {print $NF}'
ls -al /tmp | awk '$3=="'$USER'" {print $NF}'
这样做的正确方法:
ls -al /tmp | awk '$3==u {print $NF}' u="$USER"
或者
ls -al /tmp | awk -v u="$USER" '$3==u {print $NF}'