samayo
samayo

Reputation: 16495

appening recursive command for a Linux STDIN

When moving / copying contents from one folder to another. I get asked if I want to overwrite files sharing identical names. As in this example:

[root@public/]# sudo mv * /var/www/public/html/

For example, if public has 100 files that exist in html it will ask if I want to overwrite each file by name 100 time. Is there a way to append the y command?

I am a linux newbie. I know we can STDIN, STDOUT and STDERR. I though I could append it doing something like < "echo y"; but it ain't working.

Upvotes: 1

Views: 66

Answers (2)

hek2mgl
hek2mgl

Reputation: 158090

Basically you can use the program yes for such purposes:

yes | mv ...

yes called without any arguments repeats the string "y" forever but if you pass an argument it will ouput the argument. This leads to the nice call

yes no | program

which can be used to repeatedly say "no" :)

However, in this case mv itself has the option -f wich would suppress questions and enforce actions. But I would use it with care as questions are meant to help you prevent data loss.

Upvotes: 3

cheezsteak
cheezsteak

Reputation: 2923

Your solution seems to just be a work around. You should use mv -f to disable the prompt.

Upvotes: 1

Related Questions