0

If this is the wrong stack* site, I apologize, but I'm trying how to send the results from find to another app? what I'm trying to do is find all *.plist files and send them to plutil to convert them to the binary format. But I don't know how to "pipe" (I know, wrong terminology, but it works.) them into plutil.

No, I'm trying to batch convert them, using the input from find, because it recursively searches for every plist, then I want to pipe ALL of the found plists in a given folder into plutil.

2 Answers 2

2

This bears repeating. If you want to act on a set of files…

You never need to pipe the output of find to something else.

Piping the output from a command that gives you a list of files is often done wrong. You don't need a for loop for this, and you shouldn't need a find … | xargs either.

To act on a set of files found by find, use the -exec option.

find /some/path -iname '*.plist' -exec plutil -convert xml1 '{}' \;

Here, the '{}' is replaced with the name of each file found.

If you want a robust way of piping find output to act on the found files in a loop, consider this:

find … -print0 | while IFS= read -r -d '' file
do
    plutil -convert xml1 "$file"
done
2
  • Thank you, the first command worked, I am getting a permission error, but sudo should fix that.
    – MarcusJ
    Jan 23, 2013 at 17:42
  • Sudo did fix it, incase you were wondering, thanks again. :)
    – MarcusJ
    Jan 23, 2013 at 18:03
-2

Are there permission issues getting in the way of you doing it?

Otherwise try this:

https://discussions.apple.com/thread/2344258?start=0&tstart=0

OR

looping through `ls` results in bash shell script

-Justin

EDIT - Added another link so you can click on it.

6
  • No, I'm trying to batch convert them, using the input from find, because it recursively searches for every plist, then I want to pipe ALL of the found plists in a given folder into plutil.
    – MarcusJ
    Jan 23, 2013 at 17:27
  • Well, you could right a script to loop thru the files in the folder and do the conversion. I don't think you need to pipe them all. Do you want one file in the end or keep them individual?
    – manumoomoo
    Jan 23, 2013 at 17:32
  • I want to keep them individual, I just don't know the context of piping them into plutil :/
    – MarcusJ
    Jan 23, 2013 at 17:39
  • 2
    Links only aren't considered helpful answers. Moreover, posting links to LMGTFY is quite rude. Please remove this.
    – slhck
    Jan 23, 2013 at 17:39
  • 1
    I have researched it, you misread my question then ironically added a LMGTFY link.
    – MarcusJ
    Jan 23, 2013 at 17:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .