source:
BOOK/editor-tools/Clean-spaces.sh@
dc4f9f2
Last change on this file since dc4f9f2 was 67300de, checked in by , 16 years ago | |
---|---|
|
|
File size: 700 bytes |
Rev | Line | |
---|---|---|
[67300de] | 1 | #!/bin/bash -e |
2 | ||
3 | # This script will clean the trailing spaces on the given file | |
4 | # or in all XML files under the given directory. | |
5 | ||
6 | NAME=`basename $0` | |
7 | ||
8 | if [ -z "$1" ]; then | |
9 | echo "USAGE: $NAME -d directory" | |
10 | echo " $NAME -f file" | |
11 | exit; | |
12 | fi | |
13 | ||
14 | case "$1" in | |
15 | -d ) | |
16 | ||
17 | if [ -z "$2" ]; then | |
18 | echo "A directory is needed" | |
19 | exit | |
20 | fi; | |
21 | ||
22 | for filename in `find $2 -name "*.xml"`; do | |
23 | sed -i -e "s/[[:space:]]\+$//" "${filename}" | |
24 | done; | |
25 | exit;; | |
26 | ||
27 | -f ) | |
28 | ||
29 | if [ -z "$2" ]; then | |
30 | echo "A filename is needed" | |
31 | exit | |
32 | fi | |
33 | ||
34 | sed -i -e "s/[[:space:]]\+$//" $2 | |
35 | exit;; | |
36 | ||
37 | * ) | |
38 | ||
39 | echo "USAGE: $NAME -d directory" | |
40 | echo " $NAME -f file" | |
41 | exit;; | |
42 | ||
43 | esac |
Note:
See TracBrowser
for help on using the repository browser.