面试题答案
一键面试#!/bin/bash
if [ -z "$1" ]; then
echo "文件路径参数未设置"
exit 1
fi
file_path="${1:-}"
if [ -f "$file_path" ]; then
cat "$file_path"
else
echo "文件 $file_path 不存在"
fi
#!/bin/bash
if [ -z "$1" ]; then
echo "文件路径参数未设置"
exit 1
fi
file_path="${1:-}"
if [ -f "$file_path" ]; then
cat "$file_path"
else
echo "文件 $file_path 不存在"
fi