cleanup
[cmdllinux.git] / scripts / _add_linefeed.sh
blob5c178298f1e5c959c21080509d194f7d3415465e
1 #add linefeed if there isn't
2 [ -z "$1" ] && exit 1
3 FILE="$1"
4 [ ! -f "$FILE" ] && touch "$FILE" && exit 0
6 SIZE=`stat -c '%s' "$FILE"`
7 retval=$?
8 [ "$retval" != 0 ] && exit $retval
10 [ "$SIZE" -lt 1 ] && exit 0
12 FEND=`od -v -A n -t x1 -N 1 -j $(expr $SIZE - 1) "$FILE"`
13 retval=$?
14 [ "$retval" != 0 ] && exit $retval
16 [ "$FEND" != " 0a" ] && echo >> "$FILE" || true