Skip to content

Instantly share code, notes, and snippets.

@kevinhq
Forked from soxofaan/README.md
Created April 25, 2020 11:20
Show Gist options
  • Save kevinhq/bd285288b1c111cf510314891a7452f0 to your computer and use it in GitHub Desktop.
Save kevinhq/bd285288b1c111cf510314891a7452f0 to your computer and use it in GitHub Desktop.

Revisions

  1. @soxofaan soxofaan revised this gist Oct 21, 2016. 2 changed files with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    # pretty_csv/pretty_tsv
    These are some simple bash functions and scripts for making CSV/TSV files prettier on the command line

    see [http://stefaanlippens.net/pretty-csv.html](http://stefaanlippens.net/pretty-csv.html) for more information.
    File renamed without changes.
  2. @soxofaan soxofaan created this gist Oct 21, 2016.
    2 changes: 2 additions & 0 deletions pretty_csv.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #!/bin/bash
    perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' "$@" | column -t -s, | exec less -F -S -X -K
    19 changes: 19 additions & 0 deletions pretty_csv_bash_functions.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #####################################################
    # Bash functions to put in .bashrc or .bash_aliases #
    #####################################################

    # For Debian/Ubuntu
    function pretty_csv {
    column -t -s, -n "$@" | less -F -S -X -K
    }
    function pretty_tsv {
    column -t -s $'\t' -n "$@" | less -F -S -X -K
    }

    # For non-Debian systems
    function pretty_csv {
    perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' "$@" | column -t -s, | less -F -S -X -K
    }
    function pretty_tsv {
    perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | less -F -S -X -K
    }
    2 changes: 2 additions & 0 deletions pretty_tsv.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #!/bin/bash
    perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K