Add vco and source-code-stats scripts
[hvutilities.git] / scripts / source-code-stats
diff --git a/scripts/source-code-stats b/scripts/source-code-stats
new file mode 100755 (executable)
index 0000000..6f8ea86
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Comptage des lignes de code.
+
+# find $1 -print0 | xargs -0 touch
+# That terminates each filename with \000 (character 0) and instructs xargs to expect the filenames terminated by \000
+#
+#   -print0
+#          True; print the full file name on the standard output,  followed
+#          by  a  null  character  (instead  of  the newline character that
+#          -print uses).  This allows file names that contain  newlines  or
+#          other  types  of white space to be correctly interpreted by pro‐
+#          grams that process the find output.  This option corresponds  to
+#          the -0 option of xargs.
+
+echo -n "Lignes de code: "
+find . \
+    \( \
+    -name '*.c' -o \
+    -name '*.C' -o \
+    -name '*.h' -o \
+    -name '*.H' -o \
+    -name '*.cxgate' \
+    \) \
+    -print0 | xargs -0 cat | wc -l
+
+echo -n "Fichiers:       "
+find . \
+    \( \
+    -name '*.c' -o \
+    -name '*.C' -o \
+    -name '*.h' -o \
+    -name '*.H' -o \
+    -name '*.cxgate' \
+    \) \
+    -print | wc -l