#!/bin/bash
echo " Enter the name of your directory. You should enter the absolute path to the directory if it is not found in the current directory!"
read location
echo $location
filecount=$( find $location –type f –name "*.txt" -size -4K)
echo $filecount
ベストアンサー1
echo " Enter the name of your directory. You should enter the absolute path to the directory if it is not found in the current directory!"
- テキスト印刷read location
- テキストを入力して変数に保存することを期待します。$location
echo $location
- 変数の印刷$location
filecount=$(...)
- コマンドの出力を変数に保存する$filecount
find $location –type f –name "*.txt" -size -4K
- フォルダ内の名前が「.txt」で終わり、サイズのあるファイルを検索します$location
(注:スクリプトにエラーがあります。小文字でなければなりません)。type f
-name "*.txt"
-size 4
-size 4k
k
echo $filecount
- 結果の印刷
TL; DRはフォルダパスを尋ね、長さ4 KBのファイルを探します。そして印刷してみてください
変数名で判断すると、filecount
作成者はおそらく複数のファイルをインポートしたいので、次のようにコマンドを更新する必要があります。
filecount=$(find $location –type f –name "*.txt" -size 4k | wc -l)
だから私は試験に合格したのだろうか?