~ubuntu-branches/ubuntu/natty/abs-guide/natty

« back to all changes in this revision

Viewing changes to abs/idelete.sh

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-05-09 17:49:52 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100509174952-1s583w0zbh7rl1po
Tags: 6.2-1
* New upstream release; Closes: #441278
* debian/control
  - adopting package; Closes: #577181
  - removed bzip2 from b-d-i, no more needed
  - debhelper has to be in b-d
  - bump Standards-Version to 3.8.4 (no changes needed)
  - added Homepage field
  - added misc:Depends to Depends
  - added Vcs-{Browser, Git} field
* debian/rules
  - removed the unpacking stuff, we now use an alrqady unpacked source
  - added more example scripts to fix
* debian/{compat, control, rules}
  - switched to debhelper 7
* debian/watch
  - updated to new upstream location; thanks to Raphael Geissert for the
    report; Closes: #453596
* debian/copyright
  - updated with new location and copyright/license notices
* debian/source/format
  - set source package format to 1.0 explicitly
* debian/abs-guide.doc-base
  - set Section field correctly
* debian/{copyright, abs-guide.doc-base}
  - updated upstream email
* debian/abs-guide.lintian-overrides
  - added override for "known syntax-errored" scripts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
# -----------------------------------------------------------------------
 
27
# Every file has an inode, a record that holds its physical address info.
 
28
# -----------------------------------------------------------------------
 
29
 
 
30
echo; 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]) echo "Changed your mind, huh?"
 
35
      exit $E_CHANGED_MIND
 
36
      ;;
 
37
*)    echo "Deleting file \"$1\".";;
 
38
esac
 
39
 
 
40
find . -inum $inum -exec rm {} \;
 
41
#                           ^^
 
42
#        Curly brackets are placeholder
 
43
#+       for text output by "find."
 
44
echo "File "\"$1"\" deleted!"
 
45
 
 
46
exit 0