I am trying to create a zsh script to test my project. The teacher supplied us with some input files and expected output files. I need to diff the output files from myExecutable with the expected output files.
Question: Does $iF
contain a string in the following code or some kind of bash reference to the file?
#!/bin/bash inputFiles=~/project/tests/input/* outputFiles=~/project/tests/output for iF in $inputFiles do ./myExecutable $iF > $outputFiles/$iF.out done
Note:
Any tips in fulfilling my objectives would be nice. I am new to shell scripting and I am using the following websites to quickly write the script (since I have to focus on the project development and not wasting time on extra stuff):
Advertisement
Answer
As your code is, $iF
contains full path of file as a string.
N.B: Don’t use for iF in $inputFiles
use for iF in ~/project/tests/input/*
instead. Otherwise your code will fail if path contains spaces or newlines.