Skip to content

bash Cookbook

View CSV File

The following bash function uses the cat, sed, column and less commands to pretty print a CSV file to the screen:

csview() 
{ 
  cat "$1" | sed -e 's/,,/, ,/g' | column -s, -t | less -#5 -N -S 
}

Get Date Details into Variables

eval "$(date "+year=%Y month=%m day=%d hour=%H minute=%M second=%S")"

The output of the date command is executed by eval:

e.g. year=2024 month=05 day=12 hour=11 minute=22 second=5