スクリプト

スクリプト

tcsh シェルスクリプトを使用して input.txt ファイルの各行を読み込みます。

スクリプト

#!/bin/tcsh
set out_file_length=`wc -l<$1`
set i=1
while ( $i <= $out_file_length )
    set each_line = `head -$i input.txt | tail -1`
    echo $each_line
    @ i++
end

入力例: 入力ファイルの行に #{ または #} を含めることができ、これによりスクリプトがブロックされます。

入力.txt

welcome
to
#{
tcsh
#}
programming

これが私が得た結果です

welcome
to
Missing }.

この問題をどのように解決できますか?

ベストアンサー1

ありがとう、@Mark Plotnickに感謝します。

"`head -$i input.txt | tail -1`"
echo $each_line:q

これは機能し、欠落しているエラーは表示されません。変数に移動して文字列比較に使用できました。

おすすめ記事