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 "沒有參數(shù)"
else
echo "有參數(shù)"
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 "是偶數(shù)"
else
echo "不是偶數(shù)"
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 "是質(zhì)數(shù)"
else
echo "不是質(zhì)數(shù)"
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