Bash Syntax
by TBotNik from LinuxQuestions.org on (#5FX3E)
All,
Quick Q:
Have this code reading file listings from a source file:
Code:i=0;
while read -r file; do
nfil=${file:7} # Eliminate 1st 7 chars "file://"
if {grep -i '/etc/' <<< $nfil} then; continue; fi
array[ $i ]="${nfil}"
(( i++ ))
echo "N=> $i F=> $nfil"
done < "${src_fil}"The "grep" line is to eliminate any "/etc/" files from processing.
Always getting these 2 error lines but no HOWTO explains these errors:
Code:script.sh: line 34: syntax error near unexpected token `fi'
script.sh: line 34: ` if grep -i '/etc/' <<< $nfil then; continue; fi'So why does it think the "fi" which is mandatory, unexpected?
Do you know why or is it actually something else, which BASH lies about constantly?
Cheers!
TBNK


Quick Q:
Have this code reading file listings from a source file:
Code:i=0;
while read -r file; do
nfil=${file:7} # Eliminate 1st 7 chars "file://"
if {grep -i '/etc/' <<< $nfil} then; continue; fi
array[ $i ]="${nfil}"
(( i++ ))
echo "N=> $i F=> $nfil"
done < "${src_fil}"The "grep" line is to eliminate any "/etc/" files from processing.
Always getting these 2 error lines but no HOWTO explains these errors:
Code:script.sh: line 34: syntax error near unexpected token `fi'
script.sh: line 34: ` if grep -i '/etc/' <<< $nfil then; continue; fi'So why does it think the "fi" which is mandatory, unexpected?
Do you know why or is it actually something else, which BASH lies about constantly?
Cheers!
TBNK