bash
Simple bash calculator
Put the following little snippet in your .bashrc/.bash_profile and you'll have a handy little calculator:
? () { echo "$*" | bc -l; }
Use like this:
bash$ ? 2*2
4
Thanks textsnippets.com
How to list duplicate lines in a text file, with counts next to each unique line
from:
How to list duplicate lines in a text file, with counts next to each unique line - [spugbrap's random notes geek blog] [del.icio.us (bash)]
At some point, last year (it's been in my 'toblog' file all this time), I needed to analyze the lines in a text file, removing duplicate lines, while counting how many times each duplicated line occurred within the file, and sorting from most common to least common.
Unlimited Loop
Generate an infinite loop in the shell
while true ; do date ; sleep 5 ; done
"Leggi Argomenti" template per script
Template per script che legge argomenti da riga di comando:
#!/bin/bash
# FUNCTIONS
function help () {
cat <
Syntax: `basename $0` [ -h ]
Description: Descrizione script
Options: -h help (questo help)
-a Opzione "A"
-b Opzione "B"
EOF
}
# VARIABILI
# OPZIONI
while getopts ha:b: var
do
case $var in
h) help; exit
;;
a) echo "Opzione "-a" con argomento $OPTARG";
;;
b) echo "Opzione "-b" con argomento $OPTARG";
esac
done
shift ` expr $OPTIND - 1 `
passless users
Volete vedere quali utenti nel vostro sistema NON hanno una password?
cat /etc/passwd |cut -f1,2 -d:| grep -v :x |cut -f1 -d:
Whoix

