Dividere una stringa in base ad un pattern

Per estrarre un singolo blocco: nx71@iNuvoPro% echo “u d t q c” | cut -f 2 -d ” “ d Per estrarre due blocchi anche non consecutivi: nx71@iNuvoPro% echo “u d t q c” | cut -f 2,3 -d ” “ d t Per estrarre una serie di blocchi consecutivi: nx71@iNuvoPro% echo “u d t …
Continua a leggere Dividere una stringa in base ad un pattern

Elenco utenti

Per ottenere un elenco dei ruoli su PostgreSQL usare il comando \du da psql postgres=# \duList of rolesRole name | Attributes | Member of————–+————————————————————————-+———–pippo_test | | {}postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

Macchina virtuale o fisica

Per capire se si tratta di una macchina virtuale o fisica usare il comando: hostnamectl [pippo@SERVER ~]$ hostnamectlStatic hostname: SERVERIcon name: computer-vmChassis: vmMachine ID: ea218db025cf41eea3a33dc0aa52bd66Boot ID: 3f58b58c4d434f3a90d62e716a3997b5Virtualization: vmwareOperating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 3.10.0-1127.el7.x86_64Architecture: x86-64

Variabili bash

$0 – The name of the Bash script. $1 – $9 – The first 9 arguments to the Bash script. (As mentioned above.) $# – How many arguments were passed to the Bash script. $@ – All the arguments supplied to the Bash script. $? – The exit status of the most recently run process. $$ – The process ID of …
Continua a leggere Variabili bash

Convertire case nomi file

Per cambiare il case dei nomi dei file usare i seguenti comandi: Da maiuscolo a minuscolo: for nomefile in $(ls <nome del file>); do mv $nomefile $(echo $nomefile | tr “[:upper:]” “[:lower:]”); done Da minuscolo a maiuscolo: for nomefile in $(ls <nome del file>); do mv $nomefile $(echo $nomefile | tr “[:lower:]” “[:upper:]”); done