Accessing SQLite with Bash, Perl and Python

Perl: #!/usr/bin/perl -w use DBI; use strict; my $db = DBI->connect("dbi:SQLite:test.db", "", "", {RaiseError => 1, AutoCommit => 1}); $db->do("CREATE TABLE n (id INTEGER PRIMARY KEY, f TEXT, l TEXT)"); $db->do("INSERT INTO n VALUES (NULL, 'john', 'smith')"); my $all = $db->selectall_arrayref("SELECT * FROM n"); foreach my $row (@$all) { my ($id, $first, $last) = @$row; […]

To print the first and last characters of a string in bash

The actual string: var="somebash" This outputs "some": echo ${var:0:4} echo $var | sed 's/\(.\{4\}\).*/\1/' echo $var | awk '{print substr($0,1,4)}' echo $var | cut -c1-4 printf "%.4s\n" "$var" echo "${var%${var#????}}" This outputs "bash": echo $var | cut -c4- echo "${var#????}" echo ${var:4} echo $var | awk '{print substr($0,5)}'