]> git.nbdom.net Git - nb.git/commitdiff
csv2human
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 13:20:32 +0000 (14:20 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 7 Apr 2016 13:20:32 +0000 (14:20 +0100)
etc/profile.d/functions

index ed704b8952b8ef94838abe2f30fc6bffaca81933..807ddcda5a537078e9be709e2ba08a53f72798d1 100644 (file)
@@ -412,24 +412,38 @@ csv2human() {
     declare sep noheader;
     sep='\t';
     noheader=0;
+    declare files=''
+
     while [ $# -gt 0 ]; do
-        case "$1" in 
-            --sep|-s)
-                sep=$2;
-                shift
-            ;;
-            --noheader|-nh)
-                noheader=1
-            ;;
-            *)
-                echo "Unknow option: $1 at $0!";
-                return -1
-            ;;
-        esac;
-        shift;
-    done;
+
+      if [ -e "$1" ]; then
+        files="$files $1"
+        shift
+        continue
+      fi
+
+      case "$1" in
+        --sep|-s)
+            sep=$2;
+            shift
+        ;;
+        --noheader|-nh)
+            noheader=1
+        ;;
+        *)
+            echo "Unknow option: $1 at $0!";
+            return 1
+        ;;
+
+      esac
+
+      shift
+
+    done
+
     [ -z "$@" ] || sep="$@";
-    cat | perl -MEncode -F"$sep" -ane 'BEGIN {
+
+    cat $files | perl -MEncode -F"$sep" -ane 'BEGIN {
   $noheader = shift @ARGV;
   @len = (); @lines = (); 
   binmode( STDOUT, "utf8:" );