Skip to content

Instantly share code, notes, and snippets.

@jadaradix
Created November 14, 2016 19:02
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 jadaradix/83b3d3fe3e9b81ace7e0c337ee172681 to your computer and use it in GitHub Desktop.
Save jadaradix/83b3d3fe3e9b81ace7e0c337ee172681 to your computer and use it in GitHub Desktop.
sqlite-bash-list-columns.sh
#!/bin/bash
# output: id, name, age
DATABASE_PATH="database.db";
TABLE_NAME="table";
LIST=$(sqlite3 $DATABASE_PATH "PRAGMA table_info($TABLE_NAME)");
for ROW in $LIST; do
printf $ROW | awk '{split($0,a,"|"); printf "%s, ", a[2]}';
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment