I am looking to run this script in a loop but add 1 to the pdf and text names each time until it reaches a certain number. So, in the end, I will change the initial range and conditional stop. I keep getting a line 11 and line 17 - [: missing "]". Please let me know what I am doing wrong or if I am going about this the wrong way.
Here is my code:
#!/bin/bash
echo "Let's Get This Started!"
n=1
for n in {1..45}
do
echo $n. "/$n"
if [ $n -ne "45"];
then
linkrot -c -v -o $n.txt '$n.pdf'
n=($n+1)
fi
if [ $n -eq "45"];
then
break
echo "All Done"
fi
done
#!/bin/bash
echo "Let's Get This Started!"
for n in {1..45}
do
echo $n. /$n
if [ $n -lt 45 ]
then
linkrot -c -v -o $n.txt $n.pdf
else
echo All Done
fi
done
These fixes appear to work great. Now my issue is that every time it is search for '$n.pdf' while I need the $n part to be the actual variable. Any advice there?
Better have it in normal (double) quotes: "$n.pdf"
These let the shell expand the variable but deny other expansions.
Also have "$n.txt" (to deny other expansions).