在此脚本中,第二个 echo 语句不执行任何操作。
#!/bin/bash
echo "Start folder create..."
find . -name "*.zip" | while read filename; do
foldername="${filename%.*}";
mkdir -p "$foldername";
mv "$filename" "$foldername";
echo "made directory $foldername" ;
done;
所有其他命令均有效。我做错了什么?
答案1
您已将其分散到多行,但有;
。
你的脚本看起来应该像这样:
#! /bin/bash
echo "Start folder create..."
find . -name "*.zip" | while read filename; do
foldername="${filename%.*}"
mkdir -p "$foldername"
mv "$filename" "$foldername"
echo "made directory $foldername"
done