Удаление части имен файлов

Способ 1:с использованием./

rm -f./'file name'иrm -f./'file*name'

Способ 2:с использованием inode:

Получить индекс изls

ls -i "file name"

, затем

find. -inum "numberoofinode" -exec rm {} \;

0
24.02.2020, 14:00
1 ответ

Перл-версия утилиты renameможет это сделать (есть еще одна программа под названием rename, которая является частью util-linuxпакета ). Пример:

$ touch '1_this is_file one-xhdjsnsk.mp4' '2_this_is file two-hdksbdg.mp4' '3_this is_file three-hsislnsm.mp4' '4_this is file four-gwywkkd.mp4'
$ ls -l
total 0
-rw-r--r-- 1 ja users 0 Feb 24 12:43 1_this is_file one-xhdjsnsk.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 2_this_is file two-hdksbdg.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 3_this is_file three-hsislnsm.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 4_this is file four-gwywkkd.mp4
$ perl-rename 's,\-.+\.,.,' *                                                     
$ ls -l
total 0
-rw-r--r-- 1 ja users 0 Feb 24 12:43 1_this is_file one.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 2_this_is file two.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 3_this is_file three.mp4
-rw-r--r-- 1 ja users 0 Feb 24 12:43 4_this is file four.mp4
Программа

renameможет иметь другое имя в вашей системе, например, в Ubuntu это file-rename.

1
28.04.2021, 23:22

Теги

Похожие вопросы