Actually i am telling you to use only absoulte paths in all your scripts.
Yes, it should. I looked at your script in post #1 and there it reads:
I take it that has already been dealt with, yes?
OK. What i suggest you should do is to give the directory you would go as parameter to the script. The script itself would then go to the directory, do what it has to do, and so on. I would write your script this way (all the seds put together, not used "-i" because it is not portable):
#! /bin/bash
typeset WDir="$1"
typeset WorkFile1="${WDir}/input"
typeset WorkFile2="${WDir}/temp"
typeset WorkFile3="${WDir}/mols"
# a little check up front:
if [ ! -d "$WDir" ] ; then
echo "ERROR: $WDir is not a directory, exiting..." >&2
exit 1
fi
mv "${WDir}*.cell" "$WorkFile1"
dos2unix -q "$WorkFile1" >/dev/null 2>/dev/null
sed '1,7 d
/%ENDBLOCK POSITIONS_FRAC/,$ d
/Ru/,$ d' "$WorkFile1" > "${WorkFile1}.tmp"
mv "${WorkFile1}.tmp" "${WorkFile1}"
grep C "$WorkFile1" > "$WorkFile2"
grep O "$WorkFile1" >> "$WorkFile2"
sed '/C/,$d' "${WorkFile1}" > "${WorkFile1}.tmp"
mv "${WorkFile1}.tmp" "${WorkFile1}"
cat "$WorkFile2" "$WorkFile1" > "$WorkFile3"
rm "$WorkFile2" "$WorkFile1"
....
etc., etc.. Notice that the names of the 3 files you use are defined only once in the whole script, so it is easy to change them. Also notice, that because they are all declared with a full path the script only uses absolute paths now.
/PS: Furthermore, the script now understands the directory to work on as a parameter, so instead of the (inherently error-prone)
for dir in (...some list...) ; do
cd $dir
script
done
you can do the (much cleaner)
for dir in (...some list...) ; do
script $dir
done
You might post an example for the ".cells"-files you work on because i sense that for what you do there should be an easier solution than the one you found. Most probably some lines of awk will do everything your script does but ten times faster.
My suggestion regarding shells is: NEVER EVER USE CSH - it can't be stressed enough. csh is unpredictable as hell and strongly discouraged for interactive use, for scripting it is outright verboten!
If you want to write shell scripts use a POSIX-compatible shell. There are two: Korn shell (ksh) and Bourne-Again-Shell (bash). IMHO Korn Shell is better suited for scripting, but this may be personal taste as much as professional opinion. Any of the two will be suited for what your needs seem to be. It should be mentioned that the two shells languages differ only in details and if you know one you know most of the other. For what i think you want to do they are almost identical.
I do not know any bash books. For Korn Shell i can wholeheartedly recommend Barry Rosenbergs book "Hands-On KornShell93 Programming".
I hope this helps.
bakunin