In one of my programs I call a bash
command to remove all files in the directory, but some:
bash -c
shopt -s extglob
shopt -s nullglob
rm /path/to/directory/!("file1" | "file2")
Which for what I understand mean "Use bash on this command, use the extended pattern, remove all files but those"
It works good, but deletes every file but the ones put in the command.
What I would like is to remove all .mp4 and .zip in the directory but the ones I put in the command.
I think I'll have to add *.mp4 and *.zip somewhere in the command, but I have no idea where.
EDIT: For clarity, what I need is "Delete all .mp4 and .zip files, but keep thoses"
rm /path/to/directory/{*.zip,*.mp4}
?rm /path/to/directory/{*.zip, *.mp4, !("file1" | "file2")
rm: missing operand