Commits

rsvp committed 06eab4c

linecol, reverse its argument order.

  • Participants
  • Parent commits 3ecde19

Comments (0)

Files changed (1)

 #!/usr/bin/env bash
-#              bash 4.1.5(1)     Linux Ubuntu 10.04           Date : 2012-03-26
+#              bash 4.1.5(1)     Linux Ubuntu 10.04           Date : 2012-04-06
 #
 # _______________|  linecol : convert regex delimited lines into single column.
 #
-#           Usage:  linecol  [delimiter regex]  [filename]
+#           Usage:  linecol  [filename]  [delimiter regex] 
 #
-#        Examples:  % head foo.csv | linecol ', *'
-#                   #                        ^use single quotes for regex.
+#        Examples:  % linecol foo.csv ', *'
+#                   #                 ^use single quotes for regex.
 #                   #  Each item on a CSV line will be on its own line.
 #
 #    Dependencies:  sed, awk 
 
 #  CHANGE LOG  LATEST version available:   https://bitbucket.org/rsvp/gists/src
 #
+#  2012-04-06  Reverse argument order, consistent with colline.
 #  2012-03-26  First version of an idiom. Leading and trailing blank
 #                 characters are removed.
 
 #   ^unassigned variables shall be errors.
 #    Example of default VARIABLE ASSIGNMENT:  arg1=${1:-'foo'}
 
-arg1=${1:-', *'}
+arg1=${1:-'-'}
+#          ^default: standard input. 
+arg2=${2:-', *'}
 #          ^default: CSV format. 
-#                    arg1 is the FS Field Separator passed to awk.
-arg2=${2:-'-'}
-#          ^default: standard input. 
+#                    arg2 is the FS Field Separator passed to awk.
 
 
 program=${0##*/}   #  similar to using basename
 #           Remove leading and trailing blanks...
 #
 sed -e 's/^[[:blank:]]*//' -e 's/[[:blank:]]*$//'   \
-                                            "$arg2"  >  $memf
-#      -e '/^[[:blank:]]*$/d'               "$arg2"  >  $memf
+                                            "$arg1"  >  $memf
+#      -e '/^[[:blank:]]*$/d'               "$arg1"  >  $memf
 #      ^decided: NO REMOVAL of BLANK LINES
 #       because they might be record separators!
 #       Due to the previous substitution, each 
 #                 Bash variables are recognized, so escape awk field numbers.
 #
 { awk -f - $memf <<EOHereDoc
-     BEGIN { FS = "$arg1" }
+     BEGIN { FS = "$arg2" }
      { for ( i = 1; i <= NF; ++i )
           print \$i }
      #    ^each field gets printed on its own line.