1 #!/bin/bash
2 # idelete.sh: Deleting a file by its inode number.
3
4 # This is useful when a filename starts with an illegal character,
5 #+ such as ? or -.
6
7 ARGCOUNT=1 # Filename arg must be passed to script.
8 E_WRONGARGS=70
9 E_FILE_NOT_EXIST=71
10 E_CHANGED_MIND=72
11
12 if [ $# -ne "$ARGCOUNT" ]
13 then
14 echo "Usage: `basename $0` filename"
15 exit $E_WRONGARGS
16 fi
17
18 if [ ! -e "$1" ]
19 then
20 echo "File \""$1"\" does not exist."
21 exit $E_FILE_NOT_EXIST
22 fi
23
24 inum=`ls -i | grep "$1" | awk '{print $1}'`
25 # inum = inode (index node) number of file
26 # Every file has an inode, a record that hold its physical address info.
27
28 echo; echo -n "Are you absolutely sure you want to delete \"$1\" (y/n)? "
29 # The '-v' option to 'rm' also asks this.
30 read answer
31 case "$answer" in
32 [nN]) echo "Changed your mind, huh?"
33 exit $E_CHANGED_MIND
34 ;;
35 *) echo "Deleting file \"$1\".";;
36 esac
37
38 find . -inum $inum -exec rm {} \;
39 echo "File "\"$1"\" deleted!"
40
41 exit 0
Subscribe to:
Post Comments (Atom)
Quick HTTP to HTTPS - Apache2
There are several methods for redirecting your Apache-based website visitors who might type your servers URL using the plain (non-secure) HT...
-
This is to resolve auditd warning asking to specify an arch type for syscall events Sample auditd warning message: WARNING - 32/64 bit s...
-
Problem: RPM package removal error msg "Error: ... Specifies Multiple Packages" Solution: Run rpm -ev with the --allmatches opti...
-
I got a VBE6EXT.OLB could not be loaded error when I wanted to install this really great tool-set for Excel that I've been using for ye...
No comments:
Post a Comment