delete_as_root.bash

 1 #!/bin/bash
 2 # delete_as_root.bash - This Nautilus script attempts to delete all the files 
 3 # given as parameters, if it fails it will ask for password and try again.
 4 #
 5 # WARNING: This script will quite certainly succeed in irreversibly deleting 
 6 #   _any_ file, that's a dangerous thing to have around in a much too easily 
 7 #   accessible right-click menu...
 8 #
 9 
10 # Use zenity to make this a little safer to click
11 /usr/bin/zenity --question \
12         --text "Are you sure you want to permanently delete the files: $* ?" \
13         || exit
14 
15 for arg
16 do
17         rm -rf "$arg" || rootargs[${#rootargs}]="$arg"
18 done
19 [[ ${#rootargs} -gt 0 ]] && \
20         gksudo rm -rf "${rootargs[@]}"
21  
Advertisements

2 thoughts on “delete_as_root.bash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s