I've a bash file on my project root with this line
$ ls | grep -P '^some_pattern_matching_regex_goeshere.txt$' | xargs rm -f
The above line removes all the .txt
files from the project root but when I push all the .txt files to another folder e.g process_logs/ and try the same commands with ls
, grep
and rm
its doesn't work.
This is what I tried but not worked to removed files on the process_logs directory.
$ ls process_logs/ | grep -P '^some_pattern_matching_regex_goeshere.txt$' | xargs rm -f
N.B: I've also tried the command with simple regex pattern like
ls process_logs/ | grep -P '^*.txt$' | xargs rm -f
to remove files from directory but It doesn't work though.
ls
? – Cyrus Apr 28 '18 at 08:51