]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/port.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 19:39:49 +0000 (19:39 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 9 Jan 2018 19:39:49 +0000 (19:39 +0000)
etc/profile.d/functions
lib/postgres/port.sql [new file with mode: 0644]

index 1f343d87515d2239ad2b717fccaf8a993bb1b9d9..4e71e329dac9ecc2352d5de4d0cf23a01e9719b9 100644 (file)
@@ -171,6 +171,15 @@ shell_functions() {
        (declare -f || typeset -f) 2> /dev/null | awk '/^[a-z]+[a-zA-Z0-9_]+ \(\)/{print $1}'
 }
 
+shell_functions_csv() {
+       local i
+       for i in $(shell_functions); do
+               printf '%s\t' "$i"
+               type "$i" | tail -n +2 | tr -d "\n" | sed -e 's/\\/\\\\/g' -e 's/\t/\\t/g'
+               printf '\n'
+       done
+}
+
 shell_ssh() {
        local ssh_opt; case "$1" in -*) ssh_opt="$1"; [ "$#" -gt 0 ] && shift ;; esac
        local server; server="$1"; shift
diff --git a/lib/postgres/port.sql b/lib/postgres/port.sql
new file mode 100644 (file)
index 0000000..741e3d8
--- /dev/null
@@ -0,0 +1,14 @@
+DROP TABLE IF EXISTS port;
+CREATE TABLE IF NOT EXISTS port (
+  port INT,
+  proto VARCHAR(3),
+  name VARCHAR(100),
+  PRIMARY KEY (port,proto,name)
+);
+
+BEGIN TRANSACTION;
+DELETE FROM port;
+COPY port FROM PROGRAM '\
+perl -ne "m,^(\w+)\s+(\d+)/(\w+)\s+#\s*(.*?)$, && print join(qq|\t|,map(/^\s*(.*?)\s*$/,\$2,\$3,\$1)).qq|\n|" /etc/services \
+' WITH (format 'text', NULL ''); 
+COMMIT;