Я пытаюсь скопировать файл «file.txt» во все каталоги.Почему я получаю ошибку «omitting directory» с помощью globbing в команде cp?
[[email protected]]# ls -lh
total 132K
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:47 ilo01
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo02
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo03
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo04
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo05
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo06
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo07
drwxr--r--. 2 postgres postgres 4.0K Jan 2 08:40 ilo08
drwxr--r--. 2 postgres postgres 4.0K Jan 2 10:03 ilo09
drwxr--r--. 11 postgres postgres 4.0K Jan 2 11:15 ilo10
-rw-r--r--. 1 postgres postgres 64K Jun 27 2016 file.txt
Используя TAB, чтобы увидеть поведение команды для запуска:
[[email protected]]# cp -p file.txt ilo[0-1][0-9]
ilo01/ ilo02/ ilo03/ ilo04/ ilo05/ ilo06/ ilo07/ ilo08/ ilo09/ ilo10/
Но я получаю эту ошибку:
[[email protected]]# cp -v -p file.txt ilo[0-1][0-9]*
`postgresTdas.txt' -> `ilo10/file.txt'
cp: omitting directory `ilo01'
cp: omitting directory `ilo02'
cp: omitting directory `ilo03'
cp: omitting directory `ilo04'
cp: omitting directory `ilo05'
cp: omitting directory `ilo06'
cp: omitting directory `ilo07'
cp: omitting directory `ilo08'
cp: omitting directory `ilo09'
То же самое происходит с:
[[email protected]]# cp -p file.txt ilo*
и
[[email protected]]# cp -p file.txt ilo*/
Я не понимаю, почему «[0-1] [0-9] не работает так, как мне нужно.
Я предполагаю, что копия будет помещать файл .txt в список, который показывает TAB.
Что мне не хватает?
'cp' может копировать один или несколько файлов в один целевой каталог или копировать файл в один целевой файл. Он не может копировать один файл более чем одной цели. Вам нужно создать цикл, чтобы скопировать файл во все эти каталоги. – codeforester
Вы можете найти свой ответ здесь: http://stackoverflow.com/questions/195655/how-to-copy-a-file-to-multiple-directories-using-the-gnu-cp-command – codeforester
Спасибо. Мне действительно стыдно за этот вопрос:/ – manuelc