qfedu-linux-advanced-level/day1/homework/h4.sh

13 lines
349 B
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 编写一个Shell脚本接受一个目录名作为参数并列出该目录下的所有文件和子目录并人性化显示文件的大小
if [ -d $1 ]; then
echo "目录名:$1"
echo "文件列表:"
# 也可以直接写成 ls -lh $1
output=`ls -lh $1`
echo "$output"
else
echo "目录不存在"
fi