[UPHPU] Re: Bash scripting question (solved)

Richard K Miller richardkmiller at gmail.com
Fri Jul 11 10:27:43 MDT 2008


On Jul 11, 2008, at 9:42 AM, Richard K Miller wrote:

> I've created a Bash script to copy a WordPress plugin to every  
> WordPress installation on our server:
>
> http://pastebin.com/f191ee2b9
>
> On line 13, the cp command uses the -n flag to not overwrite  
> existing files. I'd prefer to use the -i flag so that I'm prompted  
> whether I want to overwrite existing files. However, the -i flag  
> doesn't work in the xargs loop. It simply loops through each file  
> and answers with the default "no" for each prompt.
>
> Can I make the xargs/cp loop actually ask me whether I want to  
> overwrite existing files?
>


Daniel helped me discover the xargs "-o" flag:

-o "Reopen stdin as /dev/tty in the child process before executing the  
command.  This is useful if you want xargs to run an interactive  
application."

Here's the updated, working script:
http://pastebin.com/f755b2cd2




More information about the UPHPU mailing list