I am attempting to create a directory using the command mkdir. However, I would like to move a subset of files into that directory. I understand I can use xargs, however my attempts have failed. For example, I have tried mkdir test | xargs -i mv test.text {}. It creates the directory, but it does not move the file test.txt into it after it has been created.
|
|
||||
|
|
|
"would like to move a subset of files into that directory" -> do files in this subset share one or more traits? If yes, use the find command like this:
If you want to avoid typing the name of the directory twice, or if you are doing this from a script, you can do something like
|
||||
|
|
I don't think mkdir produces any output to pipe to xargs. Doing "mkdir test1 test2 testhello3 | grep hello" doesn't produce any output while doing "ls | grep hello" will show me "testhello3". Can you produce the folders first and then use ls then grep and then xargs to do it?
Maybe more information on criteria of moving files and such would be helpful. |
|||||
|
|
My guess, close to user49740's answer:
how many diferent directories do you want to create? |
|||||||||
|