scripts
How do you rename files with a certain pattern in bash?
How do you rename files with a certain pattern in bash?
for i in *ABC*
do
new=$ ( echo $i | sed ’s/ABC/DEF/’ )
mv $i $new
done
Thanks Live from Yokohama
Print all ANSI colors
(from http://wiki.splitbrain.org/shellsnippets)
for i in 30 31 32 33 34 35 36 37 39
do
for j in 40 41 42 43 44 45 46 47 49
do
# skip if same fore- and backgroundcolor
if [ $j -eq $[ i + 10 ] ]; then
continue
fi
echo -e $i $j "\033[${i};${j}mCOLOR\033[0m"
done
done
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.
Script per prelevare in automatico gli sms da un modem GSM
Riporto qui una richiesta di Mauro:
Ragazzi, ho un problema,
vorrei sapere come si fanno ad estrarre gli SMS da una sim card su un modem GSM.Il tutto deve essere fatto in automatico (che so, ad intervalli di un minuto).
Conoscete la risposta sia per Windows che per Linux?
GRazie Ciao
"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 `

