I never do bash scripts so I have no clue the most efficient way to do this and quickly. I know how I would do it in something like python or c++.
I have a file structure like the one below:
-parentDir --subDir1 ---file1.txt ---file2.txt ---file3.txt ---file4.txt --subDir2 ---file1.txt ---file2.txt ---file3.txt ---file4.txt There could be any number of subdirectories and text files.
Basically I would like to create a bash script that goes into each subdirectory and then compares using file1.txt and file2.txt using diff and then compare file2.txt and file3.txt and so on outputting the difference to the end of a txt file.
I know how to use diff to compare files and then outputting the difference to a txt file I just do not know how to do what I envision as a double for loop.
Any ideas?
forloop. You're just comparing each file to the next file, not to all the other files. Or did you describe it wrong?diff ${array[$i]} ${array[$i+1]}