daniel294
October 4th, 2015, 08:57 AM
I need help in writing a BASH script that is called from another BASH script to delete certain files according to a pattern in a text file.
I have a text file containing names or numbers. And I have a directory (with sub directories) that contains many files.
I need to go over all files in my directory (and its sub directories) and delete these files that have any of the strings in my text file in their names.
For example:
Text file:
John
Dan
Ella
34567433
98844566
Test
And I have these files:
C_John_5453454.mp4
C_Dan_lastv_45435455.mp4
C_98844566_rrr.mp4
C_hello.mp4
C_hello_45354.mp4
In this case the first 3 files will be deleted.
I have a text file containing names or numbers. And I have a directory (with sub directories) that contains many files.
I need to go over all files in my directory (and its sub directories) and delete these files that have any of the strings in my text file in their names.
For example:
Text file:
John
Dan
Ella
34567433
98844566
Test
And I have these files:
C_John_5453454.mp4
C_Dan_lastv_45435455.mp4
C_98844566_rrr.mp4
C_hello.mp4
C_hello_45354.mp4
In this case the first 3 files will be deleted.