2
# idelete.sh: Deleting a file by its inode number.
4
# This is useful when a filename starts with an illegal character,
7
ARGCOUNT=1 # Filename arg must be passed to script.
12
if [ $# -ne "$ARGCOUNT" ]
14
echo "Usage: `basename $0` filename"
20
echo "File \""$1"\" does not exist."
21
exit $E_FILE_NOT_EXIST
24
inum=`ls -i | grep "$1" | awk '{print $1}'`
25
# inum = inode (index node) number of file
26
# -----------------------------------------------------------------------
27
# Every file has an inode, a record that holds its physical address info.
28
# -----------------------------------------------------------------------
30
echo; echo -n "Are you absolutely sure you want to delete \"$1\" (y/n)? "
31
# The '-v' option to 'rm' also asks this.
34
[nN]) echo "Changed your mind, huh?"
37
*) echo "Deleting file \"$1\".";;
40
find . -inum $inum -exec rm {} \;
42
# Curly brackets are placeholder
43
#+ for text output by "find."
44
echo "File "\"$1"\" deleted!"