私はこの実行を助ける必要があります。ちょうど2つのセクション。固定する必要がある2つのbash関数
私は初心者のbashスクリプトです。 1つのファイル名が入力されるまでこれをどのように繰り返すのですか? PSそれdoens'tは今まで私が試したwhileループで動作するようです。
ifSpaces(){
#if more than one file name if statement(checks for spaces)
if [ "$#" -eq "$(echo "[email protected]" | wc -w)" ]
then
echo -n "Please enter a filename: ";
read filename
else
echo -n "Please enter a single filename! ";
fi
}
それは書くことができる場合は、この機能は、ファイルをテストすることになっています。それはそれを通過し、それを正しくテストしていないようです。しかし私は本当に確信していません。基本的に何が間違っているのか、人々が私に教えて、私にそれを見せないときにそれを得ないので、訂正をしてください。
#how do I get this to work?
testFiles(){
#loop through files and test each one
for filename in "[email protected]"
do
filename="[email protected]"
# put this in a loop that grabs all the values.
# test all the file names
while [ -f "$filename" ]
do
if [ -w $filename ]
then
echo "The file exists and is writable";
overWriteFile
saveResults
elif [ -d $filename ]
then
read filename
echo "$filename";
echo "The file you specified exists and is a directory".
saveResults
else
>$directory$filename;
fi
done
echo "$filename";
echo "The file you specified exists and is neither a regular file nor a directory.";
done
saveResults
}
コードに字下げを使用してください。あなたが書いたものの頭や尾を作るのに役立ちます。 –