if [ -f file.txt ]; then
echo "文件存在"
else
echo "文件不存在"
fi
mkdir -p /path/to/directory
cp file.txt /path/to/directory
rm file.txt
for file in *.txt; do
echo $file
done
echo $(date)
script_path=$(dirname "$(readlink -f "$0")")
if [ $# -eq 0 ]; then
echo "没有参数"
else
echo "有参数"
fi
command > output.txt
if [ -z "$string" ]; then
echo "字符串为空"
else
echo "字符串不为空"
fi
if [ "$string1" = "$string2" ]; then
echo "字符串相等"
else
echo "字符串不相等"
fi
line_count=$(wc -l < file.txt)
sed -i 's/old_word/new_word/g' file.txt
result=$(command)
read -p "请输入姓名:" name
sum=$((num1 + num2))
if ((num % 2 == 0)); then
echo "是偶数"
else
echo "不是偶数"
fi
is_prime=true
for ((i=2; i<=num/2; i++)); do
if ((num % i == 0)); then
is_prime=false
break
fi
done
if $is_prime; then
echo "是质数"
else
echo "不是质数"
fi
while ! command; do
sleep 1
done
for file in *.txt; do
mv "$file" "${file%.txt}.csv"
done
md5sum file.txt
tar -czvf archive.tar.gz file1.txt file2.txt
tar -xzvf archive.tar.gz