Shell Script - Use variable in a for loop with directory path
I modified files in several directories, and need to run a diff on the backup I created before modifying the file.
I'm trying to compose a simple shell script to speed up the task, but getting a syntax error. Here is what I have: for i in DIR1 DIR2 DIR3 DIR4 DIR5 do; diff /maindir/subdir/subdir/$i/filename.txt.old /maindir/subdir/subdir/$i/filename.txt; done I know the paths are valid, and if I run just the diff command with the actual DIR1 instead of $i it works. Any suggestions as to what I'm missing? Thanks in advance. |
Posting the exact error text you get would help..
You have a misplaced semicolon. Code:
for i in DIR1 DIR2 DIR3 DIR4 DIR5; do |
Thanks much! I was initially entering this line by line and thought the problem was with using the variable in the middle of a path within the script.
Of course, as usual, when I am banging my head against the wall trying to figure out why something isn't working...turns out to be a simple oversight/sytnax error/typo! |
All times are GMT -5. The time now is 08:37 PM. |