Hi @sundar !
Hope this will get you started.
If you make a file called
list.txt like this:
Then running the script below like this
./loopOverFileLines.sh list.txt will produce the output:
register tp2.nrrd to tp1.nrrd
register tp3.nrrd to tp2.nrrd
register tp4.nrrd to tp3.nrrd
I’ve left some work for you to do, because from our talk offline, I think you can fill
in what’s missing. But please ask questions if something is unclear.
# the input to this script should be a text file, with the path to a file on each line, in order
# Make sure there's exactly one input
if [[ "$#" -ne 1 ]]; then
echo "Must provide a file" >&2
for t in `cat $list`
# do nothing when $i equals zero, since we work on pairs.
if (( $i > 0 ));
# In here, the "$current" variable stores whatever is on line (i) of the input
# the "$previous" variable stores whatever is on line (i-1) of the input
echo "register $current to $previous"