Here are 2 very short BASH scripts, they can be placed in /usr/local/bin under a suitably unique name and made executable.
The first takes all files containing a pattern given as an argument and moves them one directory up. The second just rm's all files in the PWD containing the pattern in the argument. Use with caution, possibly making a copy of the directory to be operated on first, as it might be easy to rapidly delete a lot of things by accident. It's a quick way to sort lots of files, and no doubt the scripts can be adapted for other situations.
/usr/local/bin/move-pattern-in-file :
#!/bin/bash
for file in $(grep -l -R --include="*" "$1"); do
mv $file ../;
done
/usr/local/bin/pattern-in-file-rm :
#!/bin/bash
for file in $(grep -l -R --include="*" "$1"); do
rm $file;
done
Usage:
move-pattern-in-file "123 some textpattern"
pattern-in-file-rm "some other text"
Tab completion makes long names easy to use, the length makes them difficult to confuse!
The first takes all files containing a pattern given as an argument and moves them one directory up. The second just rm's all files in the PWD containing the pattern in the argument. Use with caution, possibly making a copy of the directory to be operated on first, as it might be easy to rapidly delete a lot of things by accident. It's a quick way to sort lots of files, and no doubt the scripts can be adapted for other situations.
/usr/local/bin/move-pattern-in-file :
#!/bin/bash
for file in $(grep -l -R --include="*" "$1"); do
mv $file ../;
done
/usr/local/bin/pattern-in-file-rm :
#!/bin/bash
for file in $(grep -l -R --include="*" "$1"); do
rm $file;
done
Usage:
move-pattern-in-file "123 some textpattern"
pattern-in-file-rm "some other text"
Tab completion makes long names easy to use, the length makes them difficult to confuse!