Q: Access to a resource fork from command-line
How do I do a command-line hexdump or grep on the data contained in the resource fork of a file?
Mac OS X (10.6.7)
Posted on Apr 6, 2011 6:34 AM
by BobHarris,Solvedanswer
Mac OS X
If the file is named Fred, then you can access the resource fork using
If you need to process a bunch of files you can not use wildcards, but you can use something like:
or maybe
If you need to set shell variables along the way, then
The < space <(...) is called process substitution and is specific to the 'bash' shell, but it allows you to set variables in the 'while' loop. The previous 'find | while' combination would put the 'while' loop in a subprocess and all variable set in that 'while' loop would have been losts as soon as the loop finished.
Enjoy.
ls -l Fred/rsrc
If you need to process a bunch of files you can not use wildcards, but you can use something like:
for file in /path/to/some/directory/*
do
ls -l ${file}/rsrc
done
or maybe
#!/usr/bin/env bash
find /start/dir -iname "*.jpg" | while read file
do
ls -l ${file}/rsrc
done
If you need to set shell variables along the way, then
#!/usr/bin/env bash
while read file
do
ls -l ${file}/rsrc
done < <(find /start/dir -iname "*.jpg")
The < space <(...) is called process substitution and is specific to the 'bash' shell, but it allows you to set variables in the 'while' loop. The previous 'find | while' combination would put the 'while' loop in a subprocess and all variable set in that 'while' loop would have been losts as soon as the loop finished.
Enjoy.
Posted on Apr 6, 2011 7:15 AM