Reputation: 63
I'm looking for files that end in ".jar" and using Mac OSX. This script must do a search strictly comparing dir1 to dir2 recursively since paths can change.
dir1 = "/apollo/pkg"
dir2 = "/apollo/env"
Let's say
jar1 = "/apollo/pkg/2/3/4/same1.jar"
jar2 = "/apollo/env/8/1/3/5/2/3/same1.jar"
jar3 = "/apollo/pkg/7/2/6/same2.jar"
jar4 = "/apollo/env/1/3/same2.jar"
I'm new to writing scripts and need to write a bash script that would result in echoing to cmd line
"/apollo/pkg/2/3/4/target.jar"
"/apollo/env/8/1/3/5/2/3/target.jar"
"/apollo/pkg/7/2/6/same2.jar"
"/apollo/env/1/3/same2.jar"
Please help.
Upvotes: 1
Views: 290
Reputation: 5095
Try using find
, where you specify the place to start the recursive search ('/apollo'
) and all jar
files with -name '*.jar'
.
find '/apollo' -name '*.jar' -print
Edit: You could also try the command below, but it should be equivalent.
find /apollo -name *.jar
Upvotes: 1
Reputation: 411
If you're using linux, you could try something like this:
find /apollo -iname "*.jar"
If you want to search everywhere, try this:
find / -iname "*.jar"
Upvotes: 0