tags:

views:

28

answers:

2

Hey Folks,

First, any support and help on this is largely appreciated.

I'm trying to write a simple Bash script (completely new to this) to replace a file in a given directory.

Basically, I need to write a script to replace the safari preference file, here's what I have..and what's not working for that matter:

#!/bin/bash
find /Files/ -iname "com.apple.Safari.plist" - print0 | xargs -I{} -0 -1 cp file /Users/{}/Library/Preferences

It errors out with the following:

find: -: unknown option
xargs: illegal option -- 1

Any thoughts, ideas, are greatly appreciated.

Thanks,

A: 

No space between - print0. and since -1 is not an option, remove it and see.

find /Files/ -iname "com.apple.Safari.plist" -print0 | xargs -I{} -0 cp file /Users/{}/Library/Preferences
ghostdog74
+1  A: 

I couldn't understand what exactly you want to accomplish with this. As I understand, you would have this "com.apple.Safari.plist" in /Files/, is that correct?

And then you want to get this file into some place that, I assume, overwrites Safari's current plist file. Assuming you take ghostdog74's correct advice and remove the space between - print0, thus turning it into -print0, and then remove the -1 from xargs, as it doesn't exist, this is what would happen:

find would find your file in /Files/, and xargs would run this: cp file /Users/com.apple.Safari.plist/Library/Preferences; It would then die, since it would not find a file called "file" or a directory named "/Users/com.apple.Safari.plist/".

That's most likely not what you want. :)

If you just want to copy the file to somewhere, why don't you just do cp /Files/com.apple.Safari.plist ~/Library/Preferences/ ?

Do you really need find and xargs in this case? Could you clarify?

malvim
welp..that did it, thanks a ton Malvin!
Jay
No problem, glad to be of help. You could accept the answer, though, so as to prevent other people from trying to post further answers when they're not needed. Thanks! :)
malvim