forked from john-b-schneider/uFDTD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
number-stripper
36 lines (29 loc) · 968 Bytes
/
number-stripper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash -norc
#
# A script to remove the line numbers that I have been adding to the
# code. Specifically, this removed the lines added by 'code-liner'.
# Use this since I'm now using 'listings' to put code into the notes.
#set -x
MATLAB=0
while getopts "m" opt; do
case $opt in
m ) MATLAB=1 ;;
\? ) echo "usage: $COMMAND [-n NUM | -c] file_name"
echo " where \"file_name\" has the form base.extension (with no version)"
echo " -n option forces a link to base-vNUM.extension"
echo " -c create a new version and updates link accordingly"
exit -1 ;;
esac
done
if [ "$1" = "" -o "$1" = "-h" -o "$1" = "-?" ]; then
echo usage: ${0##*/} [-h] file_name
echo " Strip any trailing line numbers from file_name"
exit
fi
if [ $MATLAB -eq 0 ]; then
sed 's| *// *[0-9][0-9]*$||' $1 > /tmp/junk-$$
mv /tmp/junk-$$ $1
else
sed 's| *\% *[0-9][0-9]*$||' $2 > /tmp/junk-$$
mv /tmp/junk-$$ $2
fi