Debian Codegraph @

idelete.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/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 [scip-shell system . . `[`. $# -ne "$ARGCOUNT" ]
13 then
14 echoscip-shell system . . echo. "Usage: `basenamescip-shell system . . basename. $0` filename"
15 exit $E_WRONGARGS
16 fi
17
18 if [scip-shell system . . `[`. ! -e "$1" ]
19 then
20 echoscip-shell system . . echo. "File \""$1"\" does not exist."
21 exit $E_FILE_NOT_EXIST
22 fi
23
24 inum=`lsscip-shell system . . ls. -i | grepscip-shell system . . grep. "$1" | awkscip-shell system . . 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 # -----------------------------------------------------------------------
29
30 echoscip-shell system . . echo.; echoscip-shell system . . echo. -n "Are you absolutely sure you want to delete \"$1\" (y/n)? "
31 # The '-v' option to 'rm' also asks this.
32 read answer
33 case "$answer" in
34 [nN]) echoscip-shell system . . echo. "Changed your mind, huh?"
35 exit $E_CHANGED_MIND
36 ;;
37 *) echoscip-shell system . . echo. "Deleting file \"$1\".";;
38 esac
39
40 findscip-shell system . . find. . -inum $inum -exec rm {} \;
41 # ^^
42 # Curly brackets are placeholder
43 #+ for text output by "find."
44 echoscip-shell system . . echo. "File "\"$1"\" deleted!"
45
46 exit 0