I have a simple code which is:
#!/bin/bash
#LaTex code generator for figures.
ls *.pdf > pdfs.file
ls *.ps > ps.file
pwd=$(pwd)
for i in {1..2}
do
# var=$(awk 'NR==$i' 'pdfs.file')
echo $pwd
echo $pwd > testfile
done
Why aren’t the commands in the for loop working?
The $pwd isnt echoed neither is the testfile created.
I tried these commands without the for loop in a terminal and they work fine.
My bash file is made executable by chmod +x bashfile.sh
What I am trying to do is this:
- Find pdfs or eps files and populate pdfs.file and eps.file with their file names.
- Step through row by row and grab these file names and append to $pwd.
- Then append $pwd$var to the include graphics command in latex.
I’m not sure what you’re doing wrong, but this works fine for me:
This successfully returns the following: