Hi all,
Given here under a section of a script I am using.
SIMDIR="/home/Ins/forces"
cd $SIMDIR
for file in `ls *.forces`
do
basename=`echo $file | sed 's/\.[^.]*$//'`
extname=`echo $file | sed 's/[^0-9]*\([0-9]*\)\.\(.*\)/\2\1/'`
echo "Processing file: "$basename
python convert.py $basename.forces > $extname.vtk
done
exit 0
As is, the convert.py is in the directory with files *.forces.
I want to read convert.py from a different location (directory) say my home directory i.e $HOME
Thank you for your help.
vbe
August 31, 2017, 10:43am
2
??
python $HOME/convert.py $basename.forces > $extname.vtk
Not sure I understood what you want...
1 Like
Hello Theo Score,
You need not to mention python
in front of python script to execute it if you have put shebang eg--> #!/usr/bin/env python
in your python script, so it will know which complier to call.
Thanks,
R. Singh
A simplification
for file in *.forces
Variables in command arguments should be in "quotes" to avoid potential problems with special characters, for example
extname=`echo "$file" | sed 's/[^0-9]*\([0-9]*\)\.\(.*\)/\2\1/'`
echo "Processing file: $basename"
And in the next line, go for
"$basename.forces"
or "$basename".forces
or "$file"
.