A collection of helpful bash scripts.
File Name | Description |
---|---|
mkdirandmove.sh | Creates a new folder in the current directory and then moves everything into that folder |
rename-part-of-file-script.sh | Rename part of a file in a directory matching a given extension |
restore ll
command
sudo echo -e "#! /bin/bash\nls -alF" > /bin/ll ; sudo chmod +x /bin/ll
Delete all files within a directory except for one
The following deletes all files contained within a directory except the file you pass it as a parameter.
First cd
into the directory you want to delete the files. Then run the following command:
ls | grep -v "${file-to-keep}" | xargs rm
${file-to-keep}
is the name of the file you want keep. E.g. ls | grep -v "backup.tar.gz" | xargs rm