unix - Bash script to compare/search two directories using file list as variable -


i trying write bash script allow me grab names of files on dir1 example, , use each file name search string in find command, , run find command on dir2. then, output search results text file.

so, example, when runs will:

get files in dir1:

  • file1.txt
  • file2.txt
  • file3.txt
  • file4.txt

find files in dir2 "file1" in name

file1 exists in dir2 "file1-extrafile.txt"

write result text file

repeat using "file2" search string.

how can this? diff me? for loop?

try this:

for f in /dir1/*;   n=$(basename "$f")   ls -1 /dir2/*${n%.*}*.${n##*.} done > result.txt 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -