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.
我需要一个 shell 脚本来接受目录名并显示其内容。如果未给出输入,则应列出 HOME 目录的内容。(这应该使用命令行参数)
请给我一些提示和解决方案
if [ -z "$1" ] then ls ~ else ls $1 fi
在不显示当前目录而是主目录的情况下,这可能最容易在脚本中运行:
cd $1 && ls