Sign in to follow this  

Help writing a bash script.

This topic is 3631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have three directories 'sourceA' 'sourceB' and 'destination' Directories 'sourceA' and 'sourceB' contain a large number of files which exist both directories -- meaning the files have the same filenames, but are actually different files. I want to iterate over every file name and execute a command on them of the form: lipo -create sourceA\FILE sourceB\FILE -output destination\FILE Help would be appreciated.

Share this post


Link to post
Share on other sites
If sourceA and sourceB have the exact same files, you can just do this on the command line in the dir that contains sourceA, sourceB, and destination (or make a script out of it):

for f in sourceA/*; do lipo -create sourceA/$f sourceB/$f -output destination/$f; done

If not, you'll have to find the intersection of sourceA and sourceB and iterate over that.

Share this post


Link to post
Share on other sites
outRider: your approach would prepend 'sourceA/' to all file names.

I would suggest something like:
for f in `ls sourceA`
do
if [ -e sourceB/$f ]
then
lipo -create sourceA/$f sourceB/$f -output destination/$f
fi
done

Share this post


Link to post
Share on other sites

This topic is 3631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this