Directory check

How can i check in shell script if the file is coming from same directory as previous file.

Do files remember their Last Directory :confused: .....

It may be possible to note the file Directory inside the file that can be verified by the Script

You can write the directory of a file that is processed by the script to a temporary file. When the next file is processed you can compare its directory to the previously recorded one.

You could also keep it in memory but you lose that information when the script stops, which may or may not be objectionable.

you can compare the paths of files, example:

if [ pathOfFile1 = pathOfFile2 ];then yourTreatment;fi
1 Like