Skip to content

Instantly share code, notes, and snippets.

@Ortega-Dan
Forked from soxofaan/README.md
Last active February 26, 2023 05:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ortega-Dan/1d1f8b1e55a18155c940de32c161d943 to your computer and use it in GitHub Desktop.
Save Ortega-Dan/1d1f8b1e55a18155c940de32c161d943 to your computer and use it in GitHub Desktop.
Simple pretty CSV and TSV file viewer.
#####################################################
# 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
}
#!/bin/bash
perl -pe 's/((?<=,)|(?<=^)),/ ,/g;' "$@" | column -t -s, | exec less -F -S -X -K
#!/bin/bash
perl -pe 's/((?<=\t)|(?<=^))\t/ \t/g;' "$@" | column -t -s $'\t' | exec less -F -S -X -K
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment