In a Putty remote connection, I am trying to read a file line by line, cut each line by delimiter (";"), and run a command if the variables satisfy a condition. However, I get "not a valid identifier" upon reading the file.
Just some simple logic in the test.sh file:
while read download.archive
do
likes = $(echo cut -d ";" -f 1 $line)
echo $likes
dislikes = $(echo cut -d ";" -f 2 $line)
dislikes = $((dislikes * 95))
url = $(echo cut -d ";" -f 3 $line)
if [$likes -gt $dislikes]
then
youtube-dl --config-location youtube-dl-3.conf url
fi
done < download.archive
The download.archive file reads as follows-
9873;354;https://www.youtube.com/watch?v=0fd56CGnVRU
3267;54;https://www.youtube.com/watch?v=Mq4jAwPdCMw
25411;871;https://www.youtube.com/watch?v=PcSBOUpgngM
2829;44;https://www.youtube.com/watch?v=S-rj8m7Ssow
921;303;https://www.youtube.com/watch?v=JchVQMuxRVA
2014;32;https://www.youtube.com/watch?v=H8Y_ZfNViPU
Yet when I try to run ./test.sh, I get "./test.sh: line 4: read: 'download.archive': not a valid identifier". If the file is valid, why is it throwing an error?
read download.archivewill not work because you can't use.in variable names. Tryawk -F';' '$1 > $2 {system("youtube-dl --config-location youtube-dl-3.conf "$3)}' download.archive.read foo.bar:not a valid identifier."./test.sh: line 4: read:download.archive': not a valid identifier"`while read lineinstead ofwhile read download.archive. There are more errors in your script. Use shellcheck.net to find errors.