When I run the following command:
> mkdir some_dir
> find /foo/bar/ -name '*.csv' -print0 | xargs -0 mv {} some_dir
I get hundreds of lines that say:
mv: target `/foo/bar/XX.csv` is not a directory
Why? I thought xargs would execute:
mv /foo/barXX.csv some_dir
for every file that find finds. What's going on? By the way, this is with zsh
Update:
Update1:
I tried:
find /foo/bar/ -name '*.csv' -print0 | xargs -0 mv {} -t some_dir
but then I got a few lines like:
mv: cannot stat `{}': No such file or directory
although I think the command is moving my files correctly.
Update2:
I don't seem to need the -t option when using mv alone. For example
> touch file1.txt
> touch file2.txt
> mkdir my_dir
> mv file1.txt file2.txt my_dir
works well. Why do I need -t when using xargs?