Hi guys,
Am using lipo to merge ppc and i386 version of a static/dylib file based on "file type to load". I am working on Mac OS 10.5.6 and new to shell scripting. Please help me out.
This is my code.
echo "This file combine ppc and i386 file to form universal library"
echo "source Path: "
read path
echo "source Path1: "
read path1
echo "destination : "
read dest
echo "file type to load"
read exten
for iFile in `find $path -type f -name $exten`
do
echo $iFile
iFile1="${path1}${iFile##*/}"
echo $iFile1
destFile="${dest}${iFile##*/}"
lipo -create $iFile $iFile1 -output destFile
done
echo "*** Done ***"
It's say lipo can't load the file in iFile. I am trying to run lipo command.
Does the file in $iFile exist?
Your script will fail if any of the filenames contain spaces.
Is $exten a complete file name or an extension? Could it contain wildcards?
find $path -type f -name "*$exten" |
while read iFile
do
echo $iFile
iFile1=${path1%/}/${iFile##*/}
echo $iFile1
destFile="${dest%/}/${iFile##*/}"
lipo -create "$iFile" "$iFile1" -output destFile
done
find $path -type f -name "*$exten" |
while read iFile
do
echo $iFile
iFile1=${path1%/}/${iFile##*/}
echo $iFile1
destFile="${dest%/}/${iFile##*/}"
lipo -create "$iFile" "$iFile1" -output "$destFile" # changed the last line
done
I figured out the problem in my script ,
It generated this path
"/sw/lib/ImageMagick-6.5.4/modules-Q16/codersycbcr.a"
which should have been
"/sw/lib/ImageMagick-6.5.4/modules-Q16/coders/ycbcr.a"
Thank you very much. I normally feed exten wildcards ".a" or ".dylib". I need to make checks for file existence.
I have faced that problem too. How should I handle white spaces in file paths?
Always quote variables.
Never use:
for file in $( some_command )
Always pipe the output of the command into a loop instead:
some_command |
while read file
do
: do whatever with "$file" (not $file)
done