#!/bin/sh
# This is comment!
echo Hello World
for file1 in /C:/Users/shubham.tomar/Desktop/Shell/Test1/*;
do
filename1=$(basename "$file1")
echo $filename1
echo "------------------------"
for file2 in /C:/Users/shubham.tomar/Desktop/Shell/Test2/*;
do
filename2=$(basename "$file2")
echo $filename2
if [["filename1" = "filename2"]]; then
echo "---File matched---"
else
mv -f /C:/Users/shubham.tomar/Desktop/Shell/Test2/$filename2 /C:/Users/shubham.tomar/Desktop/Shell/Moved/
fi
echo "--------------File Moved-----------"
done
done
**
NOTE ABOUT PROBLEM
**
There are some files in a particular path for ex: Desktop/Test1 and Downloads/Test2 I want to write a shell script to move all the files present in Test2 and not in Test1 to a path for ex: Documents/MovedFiles files may be of any type
Test2that are not inTest1(or vice versa?) toMoved. Please add some explanating text that describes what you want to do. You could also add some examples what might be inTest1andTest2and what you want to be the result inMoved. Nesting twoforloops is probably wrong. I guess you don't want to comparefilename1with every file name inTest2but only check if a file with the same name is present inTest2. – Bodo Jan 22 '19 at 09:43Test2and not present inTest1? – Bodo Jan 22 '19 at 10:15