Permalink
Browse files

Added two tiny, but useful utility functions.

  • Loading branch information...
1 parent 7799685 commit a6670398da4ce1a0bd162596ad09396197783833 @seldon committed Nov 15, 2013
Showing with 19 additions and 0 deletions.
  1. +19 −0 shell/.bash.d/utils.sh
View
@@ -0,0 +1,19 @@
+## outputs the number of (regular) files contained within a given directory
+# if invoked without an argument, defaults to the current directory
+function count-files {
+dir=$1 || $CWD
+find $dir -type f |wc -l
+}
+
+## converts a man page to a PDF file
+# Usage: man2pdf <COMMAND> [OUTPUT_DIR]
+# where COMMAND is the shell command/program whose manual page is to be
+# converted and OUTPUT_DIR is the filesystem directory where to place the
+# generated PDF file (defaults to the current directory).
+
+function man2pdf {
+command=$1
+out_dir=$2 || $PWD
+out_fname=${command}_manpage.pdf
+man -Tps $command | ps2pdf - ${out_dir}/${out_fname}
+}

0 comments on commit a667039

Please sign in to comment.