Scripts: removed useless functions in stdin/files scripts
parent
25a49b7661
commit
c6bfd146d7
|
@ -6,7 +6,7 @@ _printhelp ()
|
|||
cat<<EOF
|
||||
Usage: \${1##*/} [OPTIONS] FILES
|
||||
|
||||
Synopsis:
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
# name: help
|
||||
# key: help
|
||||
# --
|
||||
printhelp()
|
||||
{
|
||||
echo "Synopsis:"
|
||||
echo -e " \$1 [-n] PACKAGES"
|
||||
echo
|
||||
echo "Usage:"
|
||||
echo -e " -h:\t\tDisplay this help."
|
||||
}
|
||||
$0
|
117
.scripts/asciify
117
.scripts/asciify
|
@ -11,68 +11,59 @@ EOF
|
|||
exit
|
||||
fi
|
||||
|
||||
_asciify()
|
||||
{
|
||||
unset OPT
|
||||
if [ $# -ge 1 ]; then
|
||||
OPT=-i
|
||||
fi
|
||||
|
||||
sed $OPT \
|
||||
-e 's/[áàâä]/a/g' \
|
||||
-e 's/[éèêë]/e/g' \
|
||||
-e 's/[íìîï]/i/g' \
|
||||
-e 's/[óòôö]/o/g' \
|
||||
-e 's/[úùûü]/u/g' \
|
||||
-e 's/[ýỳŷÿ]/y/g' \
|
||||
-e 's/[ÁÀÂÄ]/A/g' \
|
||||
-e 's/[ÉÈÊË]/E/g' \
|
||||
-e 's/[ÍÌÎÏ]/I/g' \
|
||||
-e 's/[ÓÒÔÖ]/O/g' \
|
||||
-e 's/[ÚÙÛÜ]/U/g' \
|
||||
-e 's/[ÝỲŶŸ]/Y/g' \
|
||||
-e 's/[ñ]/n/g' \
|
||||
-e 's/[œ]/oe/g' \
|
||||
-e 's/[Œ]/Oe/g' \
|
||||
-e 's/[æ]/ae/g' \
|
||||
-e 's/[Æ]/Ae/g' \
|
||||
-e 's/[ç]/c/g' \
|
||||
-e 's/[Ç]/C/g' \
|
||||
-e 's/[ß]/ss/g' \
|
||||
-e 's/[«»„“”‚‘’]/"/g' \
|
||||
-e 's/[©]/(C)/g' \
|
||||
-e 's/[®]/(R)/g' \
|
||||
-e 's/[™]/(TM)/g' \
|
||||
-e 's/[¥]/Y/g' \
|
||||
-e 's/[Ð]/D/g' \
|
||||
-e 's/[ŀ]/l/g' \
|
||||
-e 's/[Ŀ]/L/g' \
|
||||
-e 's/[€]/euro/g' \
|
||||
-e 's/[¢]/cent/g' \
|
||||
-e 's/[£]/pound/g' \
|
||||
-e 's/[µ]/mu/g' \
|
||||
-e 's/[²]/^2/g' \
|
||||
-e 's/[³]/^3/g' \
|
||||
-e 's/[¡]/!/g' \
|
||||
-e 's/[¿]/?/g' \
|
||||
-e 's/[–‑]/-/g' \
|
||||
-e 's/[…]/.../g' \
|
||||
-e 's/[≤]/<=/g' \
|
||||
-e 's/[≥]/>=/g' \
|
||||
-e 's/[±]/+\/-/g' \
|
||||
-e 's/[≠]/!=/g' \
|
||||
-e 's/[⋅]/./g' \
|
||||
-e 's/[×]/x/g' \
|
||||
-e 's/[÷]/\//g' \
|
||||
-e 's/[↓]/|/g' \
|
||||
-e 's/[↑]/^/g' \
|
||||
-e 's/[←]/<=/g' \
|
||||
-e 's/[→]/=>/g' \
|
||||
"$@"
|
||||
}
|
||||
|
||||
unset OPT
|
||||
if [ $# -ge 1 ]; then
|
||||
_asciify "$@"
|
||||
else
|
||||
_asciify
|
||||
OPT=-i
|
||||
fi
|
||||
|
||||
sed $OPT \
|
||||
-e 's/[áàâä]/a/g' \
|
||||
-e 's/[éèêë]/e/g' \
|
||||
-e 's/[íìîï]/i/g' \
|
||||
-e 's/[óòôö]/o/g' \
|
||||
-e 's/[úùûü]/u/g' \
|
||||
-e 's/[ýỳŷÿ]/y/g' \
|
||||
-e 's/[ÁÀÂÄ]/A/g' \
|
||||
-e 's/[ÉÈÊË]/E/g' \
|
||||
-e 's/[ÍÌÎÏ]/I/g' \
|
||||
-e 's/[ÓÒÔÖ]/O/g' \
|
||||
-e 's/[ÚÙÛÜ]/U/g' \
|
||||
-e 's/[ÝỲŶŸ]/Y/g' \
|
||||
-e 's/[ñ]/n/g' \
|
||||
-e 's/[œ]/oe/g' \
|
||||
-e 's/[Œ]/Oe/g' \
|
||||
-e 's/[æ]/ae/g' \
|
||||
-e 's/[Æ]/Ae/g' \
|
||||
-e 's/[ç]/c/g' \
|
||||
-e 's/[Ç]/C/g' \
|
||||
-e 's/[ß]/ss/g' \
|
||||
-e 's/[«»„“”‚‘’]/"/g' \
|
||||
-e 's/[©]/(C)/g' \
|
||||
-e 's/[®]/(R)/g' \
|
||||
-e 's/[™]/(TM)/g' \
|
||||
-e 's/[¥]/Y/g' \
|
||||
-e 's/[Ð]/D/g' \
|
||||
-e 's/[ŀ]/l/g' \
|
||||
-e 's/[Ŀ]/L/g' \
|
||||
-e 's/[€]/euro/g' \
|
||||
-e 's/[¢]/cent/g' \
|
||||
-e 's/[£]/pound/g' \
|
||||
-e 's/[µ]/mu/g' \
|
||||
-e 's/[²]/^2/g' \
|
||||
-e 's/[³]/^3/g' \
|
||||
-e 's/[¡]/!/g' \
|
||||
-e 's/[¿]/?/g' \
|
||||
-e 's/[–‑]/-/g' \
|
||||
-e 's/[…]/.../g' \
|
||||
-e 's/[≤]/<=/g' \
|
||||
-e 's/[≥]/>=/g' \
|
||||
-e 's/[±]/+\/-/g' \
|
||||
-e 's/[≠]/!=/g' \
|
||||
-e 's/[⋅]/./g' \
|
||||
-e 's/[×]/x/g' \
|
||||
-e 's/[÷]/\//g' \
|
||||
-e 's/[↓]/|/g' \
|
||||
-e 's/[↑]/^/g' \
|
||||
-e 's/[←]/<=/g' \
|
||||
-e 's/[→]/=>/g' \
|
||||
"$@"
|
||||
|
|
|
@ -7,7 +7,7 @@ Usage: ${1##*/} [OPTIONS] FILES
|
|||
|
||||
Dump optical disc to ISOFILE (without extension).
|
||||
|
||||
Synopsis:
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
-d DRIVE: Set optical drive to use (e.g. 'sr1').
|
||||
|
|
|
@ -11,9 +11,10 @@ and output to stdout.
|
|||
Note: GNU 'head' has the '-n -10' option to do this. This program is only useful
|
||||
for non-GNU systems.
|
||||
|
||||
Synopsis:
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
-i: Replace file content instead of writing to stdout.
|
||||
-t: Cut head instead of the tail. Like 'tail -n +11' with GNU tail (11
|
||||
because the limit line is included).
|
||||
-n N: Cut N lines instead of 10.
|
||||
|
@ -23,8 +24,11 @@ EOF
|
|||
|
||||
OPT_TAIL=true
|
||||
OPT_LINES=10
|
||||
while getopts ":hn:t" opt; do
|
||||
OPT_INPLACE=""
|
||||
while getopts ":ihn:t" opt; do
|
||||
case $opt in
|
||||
i)
|
||||
OPT_INPLACE="-i"
|
||||
h)
|
||||
_printhelp "$0"
|
||||
exit 1 ;;
|
||||
|
@ -44,7 +48,7 @@ done
|
|||
shift $(($OPTIND - 1))
|
||||
|
||||
if $OPT_TAIL; then
|
||||
sed -n -e ":begin ; 1,${OPT_LINES}!{P;N;D} ; N ; b begin" $1
|
||||
sed $OPT_INPLACE -n -e ":begin ; 1,${OPT_LINES}!{P;N;D} ; N ; b begin" $1
|
||||
else
|
||||
sed -n -e "1,${OPT_LINES}!p" "$@"
|
||||
sed $OPT_INPLACE -n -e "1,${OPT_LINES}!p" "$@"
|
||||
fi
|
||||
|
|
|
@ -19,7 +19,7 @@ the Bourne Shell.
|
|||
|
||||
WARNING: this script is rather weak, most notably regarding existing files.
|
||||
|
||||
Synopsis.
|
||||
Options.
|
||||
|
||||
-f: Remove archive if extraction was succesful.
|
||||
-p: Ask for password.
|
||||
|
|
|
@ -7,7 +7,7 @@ Usage: ${1##*/} [OPTIONS] REPOS
|
|||
|
||||
Clone multiple git repos from \$DOMAIN:\$USER.
|
||||
|
||||
Synopsis:
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
-d DOMAIN: Set domain.
|
||||
|
|
|
@ -92,7 +92,7 @@ Usage: ${1##*/} FILES
|
|||
Mount image files using CDEmu or fall back to fuseriso if available. It will
|
||||
not mount an image if already mounted.
|
||||
|
||||
Synopsis:
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
-u: Unmount folders.
|
||||
|
|
|
@ -4,23 +4,14 @@ if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
|||
cat <<EOF
|
||||
Usage: ${0##*/} [FILES]
|
||||
|
||||
Shuffle letters randomly. If no file is provided, stdin is used.
|
||||
Shuffle letters randomly and print result to stdout. If no file is provided,
|
||||
stdin is used.
|
||||
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
_shuffle()
|
||||
{
|
||||
fold -w 1 "$@" | shuf | tr -d '\n' && echo
|
||||
fold -w 1 "$@" | shuf | tr -d '\n' && echo
|
||||
|
||||
## Interesting AWK alternative, much slower however.
|
||||
# awk -F'\n' 'BEGIN {srand()} {input=input $0} END {count = split(input,a,""); while(count >= 1) {i = (int(rand()*count) % count)+1; printf("%s", a[i]); a[i]=a[count];delete a[count]; count--} print ""}' "$@"
|
||||
|
||||
}
|
||||
|
||||
if [ $# -ge 1 ]; then
|
||||
_shuffle "$@"
|
||||
else
|
||||
_shuffle
|
||||
fi
|
||||
## Interesting AWK alternative, much slower however.
|
||||
# awk -F'\n' 'BEGIN {srand()} {input=input $0} END {count = split(input,a,""); while(count >= 1) {i = (int(rand()*count) % count)+1; printf("%s", a[i]); a[i]=a[count];delete a[count]; count--} print ""}' "$@"
|
||||
|
|
|
@ -15,7 +15,7 @@ the input content.
|
|||
|
||||
When omitting the text, standard input is read.
|
||||
|
||||
Synopsis.
|
||||
Options:
|
||||
|
||||
-h: Show this help.
|
||||
-i: Input language (optional).
|
||||
|
|
Loading…
Reference in New Issue