これらのファイルの特定の列に対してコマンドを実行しながら、ディレクトリ内のすべてのファイルを1行ずつ読み取ることができるスクリプトを作成しようとしています。私が扱っているファイルは、コンマで区切られた値を持つ .txt ファイルです。テキストファイルをスクリプトに入力してから値を出力することで、単一のファイルでコードを実行できますが、複数のファイルでは実行できません。これが私の目標です。ファイルがディレクトリにある順序で読み取られるようにします。これが私がこれまでに持っているものです。
directory=$(/dos2unix/*.txt)
file=$(*.txt")
IFS=","
for "$file" in "$directory";
do
while read -ra line;
do
if [ "${line[1]}" != "" ]; then
echo -n "${line[*]}, Hash Value:"; echo "${line[1]}" | openssl dgst -sha1 | sed 's/^.* //'
else
if [ "${line[1]}" == "" ]; then
echo "${line[*]}, Hash Value:None";
fi
fi
done
done
私が得ているエラーのいくつかは次のとおりです。
$ ./orange2.sh
/dos2unix/test1.txt: line 1: hello: command not found
/dos2unix/test1.txt: line 2: goodbye: command not found
/dos2unix/test1.txt: line 4: last: command not found
./orange2.sh: line 28: unexpected EOF while looking for matching `"'
./orange2.sh: line 33: syntax error: unexpected end of file
ヒント、提案、または例はありますか?
皆さんありがとう
アップデート
また、最終的にすべてのファイルをコピーして、最初の if ステートメントに表示されるコマンドを含めたいと考えているため、a.) ファイルを個別に保持し、b.) 更新された値を含むコピーを作成します。