You are not logged in.
I have this as an executable Bash script in my bin directory and have called it `rmx':
#!/bin/bash
shopt -s extglob
rm !($@)
shopt -u extglobThe extglob bits turn on/off respectively extended globbing, which is necessary to use "!" (as in, do the command on everything except the following) and "$@" (as in, what you enter after typing, in my case, 'rmx').
Naturally you can simply have extended globbing turned on and do this every time, instead:
rm !(file_to_delete)
I just find putting the script in bin marginally easier.
Of course this script is perfectly transferable.
Last edited by crunchgargoyle (2011-09-23 14:26:07)
I am error
Offline
i have no knowledge of how shopt and extglob work, so i need to check that out. but i get the gist, and it is a nice little script.
Offline
i have no knowledge of how shopt and extglob work, so i need to check that out. but i get the gist, and it is a nice little script.
Thank you
.
I just think of globbing in terms of wildcards.
I am error
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.