File: find_stray_empty_lines

package info (click to toggle)
busybox 1%3A1.30.1-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 26,768 kB
  • sloc: ansic: 182,637; sh: 8,979; cpp: 1,428; makefile: 1,023; yacc: 570; lex: 355; perl: 312; python: 109; awk: 29
file content (19 lines) | stat: -rwxr-xr-x 554 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

grep -n -B1 -r $'^\t*}$' . | grep -A1 '.[ch]-[0-9]*-$'
grep -n -A1 -r $'^\t*{$' . | grep -B1 '.[ch]-[0-9]*-$'
# or (less surefire ones):
grep -n -B1 -r $'^\t*}' . | grep -A1 '.[ch]-[0-9]*-$'
grep -n -A1 -r $'^\t*{' . | grep -B1 '.[ch]-[0-9]*-$'

# find trailing empty lines
find -type f | while read file; do
        test x"$file" = x"" && continue
        tail -n1 $file | while read lastline
        do
          #echo "|$file|$lastline"
          if test x"$lastline" = x""; then
                echo "$file"
          fi
        done
done