[英]Unix Shell Scripting
我已經看到了進程替換的概念。 但是下面的代碼仍然給我語法錯誤
script.sh: syntax error at line 44: `<' unexpected
script.sh: syntax error at line 44: `<' unexpected
這是代碼:
#!/bin/bash
count=1
FILENAME=$1
JUDGE="YATES"
echo "VALUE OF JUDGE IS $JUDGE"
STATUS=""
#The file is read using while loop , file being supplied as cmd line arg , file simply contains the list of courts .
#cat $FILENAME | while read LINE
while read LINE
do
#Selecting the filepath here $LINE contains the court every time it iterates
FILEPATH=/elFZ/dZcollection/$LINE/DETER_JUDGE
#Checking whether the DETER_JUDGE exists or not ,
cat $FILEPATH >> yatisawhney.txt 2>> yati_errors.txt
#if the DETER_JUDGE file exists then
if [ $? = 0 ]
then
echo "INSIDE IF"
STATUS="Yes"
#cat $FILEPATH | while read -r JUDGELINE
#open the DETER JUDGE file and read the values and updating the JUDGE variable.
while read JUDGELINE
do
line_length=$JUDGELINE
JUDGE=$JUDGE$line_length"||||||"
#JUDGE=1000
done < < ( $FILEPATH )
echo "Value of judge is $JUDGE"
else
FILEPATH="N.A."
STATUS="No"
JUDGE="N.A."
fi
#here I am not getting the updated value
echo $JUDGE >> JUDGE_NAME
echo $count","$LINE","$STATUS","$JUDGE","$FILEPATH >> judgeData.csv
count=`expr "$count" + 1`
JUDGE=""
done < < ( $FILENAME )
我無法從內部 while 循環中獲取值。 但是我能夠在循環內獲取它們,一旦我離開值就會丟失。
進程替換使用<(...)
構造, <
和左括號之間不應有空格。
要從文件中讀取,您根本不需要進程替換:
done < "$FILENAME"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.