heu
[dotfiles] / .bash_function
1 #!/bin/sh
2 # my weird function file
3 # lots of this coming from the internets
4
5 # _ssh_agent() {
6 # command -v ssh-agent >/dev/null || return
7 # [ "$SSH_CONNECTION" ] && return
8 # local info=$HOME/.cache/ssh-agent-info
9 # [ -f $info ] && . $info >/dev/null
10 # [ "$SSH_AGENT_PID" ] && kill -0 $SSH_AGENT_PID 2>/dev/null || {
11 # mkdir -p $(dirname $info)
12 # ssh-agent >$info
13 # . $info >/dev/null
14 # }
15 # } _ssh_agent
16
17 # http://uggedal.com/journal/lazy-ssh-add/
18 _ssh_add() {
19 local key=$1
20
21 [ "$SSH_CONNECTION" ] && return
22 ssh-add -l >/dev/null || ssh-add $key
23 }
24
25 ssh() {
26 local remote=$1
27
28 case $remote in
29 "vm1") _ssh_add $HOME/.ssh/id_rsa_kratos ;;
30 "phobos") _ssh_add $HOME/.ssh/id_rsa_phobos ;;
31 *) echo "valid key not found" && exit 1 ;;
32 esac
33 command ssh "$@"
34 }
35
36
37 scp() {
38 local file=$1
39 local remote=$2
40
41 case $remote in
42 "vm1:") _ssh_add $HOME/.ssh/id_rsa_kratos ;;
43 "phobos:") _ssh_add $HOME/.ssh/id_rsa_phobos ;;
44 esac
45
46 command scp "$@"
47 }
48
49
50 # git() {
51 # case $1 in
52 # push|pull|fetch) _ssh_add ;;
53 # esac
54 # command git "$@"
55 # }
56
57 my_up(){
58 ifup br0 &&
59 echo "nameserver 80.67.169.12" | sudo tee /etc/resolv.conf
60 }
61
62 my_dotargz(){
63 local tarfile=$1
64 local foldertobezipped=$2
65 tar -zcvf $1 $2
66 #tar -cvf - file1 file2 dir3 | gzip > archive.tar.gz
67 }
68
69 my_dotarbz2(){
70 local tarfile=$1
71 local foldertobezipped=$2
72 tar -jcvf $1 $2
73
74 }
75
76 # zip some files using python
77 my_zipit(){
78 local zipfile=$2
79 local tobezipped=$1
80 # call the zip module from python3
81 python3 -m zipfile -c $2 $1
82 }
83
84 # to unban an ip blocked because of fail ssh connection
85 my_fail2ban_unban_ip(){
86 local ip=$1
87 sudo fail2ban-client set ssh unbanip $ip
88
89 }
90
91 my_bak() { cp "$1" "$1_`date +%Y-%m-%d_%H-%M-%S`" ; }
92
93 my_whois_onport(){
94 # return the service on port
95 local port=$1
96 sudo lsof -i :$port
97 }
98
99 my_mount_set_of_partition(){
100 # Mount set of partitions for recovery.
101 for i in {1..12}; do
102 mkdir /media/sdd$i && mount -o ro /{dev,media}/sdd$i || rmdir /media/sdd$i ;
103 done
104 }
105
106 my_copy_file_to_clipboard() {
107 local filecontent=$1
108 [ -f $file ] && xclip -sel clip < $filecontent
109 }
110
111 my_usage() {
112
113 cat <<-EOF
114 usage: $PROGNAME options
115
116 Program deletes files from filesystems to release space.
117 It gets config file that define fileystem paths to work on, and whitelist rules to
118 keep certain files.
119
120 OPTIONS:
121 -c --config configuration file containing the rules. use --help-config to see the syntax.
122 -n --pretend do not really delete, just how what you are going to do.
123 -t --test run unit test to check the program
124 -v --verbose Verbose. You can specify more then one -v to have more verbose
125 -x --debug debug
126 -h --help show this help
127 --help-config configuration help
128
129
130 Examples:
131 Run all tests:
132 $PROGNAME --test all
133
134 Run specific test:
135 $PROGNAME --test test_string.sh
136
137 Run:
138 $PROGNAME --config /path/to/config/$PROGNAME.conf
139
140 Just show what you are going to do:
141 $PROGNAME -vn -c /path/to/config/$PROGNAME.conf
142
143 EOF
144 }
145
146 my_change_owner_of_files() {
147 local user=$1; shift
148 local group=$1; shift
149 local files=$@
150 local i
151
152 for i in $files
153 do
154 chown $user:$group $i
155 done
156 }
157
158
159 my_template_function() {
160 # local vars
161 local PROGNAME=$(basename $0)
162 local PROGDIR=$(readlink -m $(dirname $0))
163 local ARGS="$@"
164 local first_arg=$1
165
166 # readonly var
167 #readonly local second_arg=$2;
168
169 # if no args, print usage
170 is_empty_string $ARGS && my_usage
171
172
173 }
174
175 my_list_venv(){
176 ls $HOME"/envs"
177 }
178
179 my_goto_venv() {
180 local dir=$1
181 local env=$HOME"/envs/"$dir"/source/"
182 #if source dir not exists, create & cd
183 [ -d $env ] && cd $env || mkdircd -p $env
184 # activate virtualenv
185 source $HOME"/envs/"$dir"/bin/activate"
186 }
187
188 # Taken from http://aaroncrane.co.uk/2009/03/git_branch_prompt/
189 find_git_repo() {
190 local dir=.
191 until [ "$dir" -ef / ]; do
192 if [ -f "$dir/.git/HEAD" ]; then
193 GIT_REPO=`readlink -e $dir`/
194 return
195 fi
196 dir="../$dir"
197 done
198 GIT_REPO=''
199 return
200 }
201
202 find_git_branch() {
203 head=$(< "$1/.git/HEAD")
204 if [[ $head == ref:\ refs/heads/* ]]; then
205 GIT_BRANCH=${head#*/*/}
206 elif [[ $head != '' ]]; then
207 GIT_BRANCH='(detached)'
208 else
209 GIT_BRANCH='(unknown)'
210 fi
211 }
212
213 # Taken from https://github.com/jimeh/git-aware-prompt
214 find_git_dirty() {
215 local status=$(git status --porcelain 2> /dev/null)
216 if [[ "$status" != "" ]]; then
217 GIT_DIRTY='*'
218 else
219 GIT_DIRTY=''
220 fi
221 }
222
223 find_git_stash() {
224 if [ -e "$1/.git/refs/stash" ]; then
225 GIT_STASH='stash'
226 else
227 GIT_STASH=''
228 fi
229 }
230
231 cdls() { cd "$@" && clear && ls; }
232
233
234 cl(){
235 if [ -d "$1" ]; then
236 cd "$1"
237 clear
238 ls -lh
239 else
240 cd
241 clear
242 ls
243 fi
244 }
245
246
247 mkdircd(){
248 mkdir -p "$@" && eval cd "\"\$$#\"";
249 }
250
251 my_emacs_servers(){
252 local serverdir="${TMPDIR:-/tmp}/emacs${UID}"
253 local -a servers
254 for file in ${serverdir}/*; do
255 if [[ -S ${file} ]]; then
256 servers+=("${file##*/}")
257 fi
258 done
259
260 echo "${servers[@]}"
261 }
262
263 my_fib(){
264 x=${1:-1}
265 y=${2:-1}
266 echo $(($x + $y))
267 fib $y $(($x + $y))
268 }
269
270
271 my_recursiveFibo() {
272 local start=0;
273 n="$1";
274 inc="$2";
275 while ((n < $inc));
276 do
277 result=$((start+n));
278 start=$n;
279 n="$result";
280 printf '%s ' "$result";
281 done;
282 }
283
284 #recursivFibo 1 2048
285
286 my_err() {
287 echo "[$(date + '%Y-%m-%dT%H:%M:%S%z')]: $@ >&2"
288 }
289
290 my_test() {
291 echo 'test';
292 }
293
294 my_test2(){
295 if my_test; then
296 my_err "unable to my_test"
297 exit "${E_DID_NOTHING}"
298 fi
299 }
300
301 my_pretty_print_json() {
302 python -m json.tool
303 }
304
305 my_not_start_service_on_boot(){
306 # service to not start on boot
307 local service=$1;
308 update-rc.d $service disable;
309 }
310
311 my_install_new_font(){
312 #sudo fc-cache -v -f
313 fc-cache -v -f;
314 }
315
316 my_launch_eth0(){
317 # set eth0 iface up
318 sudo ip link set eth0 up;
319 # ask for an ip via dhcp
320 sudo dhclient eth0;
321 }
322
323 #function to show the current branch
324 my_show_current_branch(){
325 git rev-parse --abbrev-ref HEAD
326 }
327
328 my_pdf_nbpages(){
329 local filename=$1;
330
331 echo $(pdftk $filename dump_data \
332 | grep -i numberofpages \
333 | awk '{print $2}');
334 }
335
336 my_pdf_explosion() {
337 local filename=$1;
338 echo $(pdftk $filename burst);
339 }
340
341 my_pdfs_to_xml() {
342 for i in $(ls | grep .pdf$); do
343 pdftohtml -xml $i;
344 done;
345 }
346
347 # function to show one line of file
348 my_xline_of_file(){
349 local line_number=$1;
350 local filename=$2;
351 local p='p';
352
353 echo $(sed -n $line_number$p $filename);
354 }
355
356 # function to extract in one command
357 my_xtract() {
358 local filename=$1;
359
360 if is_file $filename ; then
361 case $filename in
362 *.tar.xz) tar xvfJ $filename ;;
363 *.xz) tar xf $filename ;;
364 *.tar.bz2) tar xvjf $filename ;;
365 *.tar.gz) tar xvzf $filename ;;
366 *.bz2) bunzip2 $filename ;;
367 *.rar) unrar x $filename ;;
368 *.gz) gunzip $filename ;;
369 *.tar) tar xvf $filename ;;
370 *.tbz2) tar xvjf $filename ;;
371 *.tgz) tar xvzf $filename ;;
372 *.zip) unzip $filename ;;
373 *.Z) uncompress $filename ;;
374 *.7z) 7z x $filename ;;
375 *) echo "'$filename' cannot be extracted via extract" ;;
376 esac
377 else
378 echo "'$filename' is not a valid file"
379 fi
380 }
381
382 # function to list the content of an archive
383 my_list_archive_content() {
384 local filename=$1;
385
386 if is_file $filename ; then
387 case $filename in
388 *.tar.xz) tar tvfJ $filename ;;
389 *.tar.bz2) tar tvjf $filename ;;
390 *.tar.gz) tar tzvf $filename ;;
391 *.bz2) bunzip2 $filename ;;
392 *.gz) gunzip -l $filename ;;
393 *.tar) tar tvf $filename ;;
394 *.tbz2) tar tvjf $filename ;;
395 *.tgz) tar tvzf $filename ;;
396 *.zip) unzip -l $filename ;;
397 *.Z) uncompress -l $filename ;;
398 *.7z) 7z l $filename ;;
399 *) echo "content of '$filename' cannot be listed :(" ;;
400 esac
401 else
402 echo "'$filename' is not a valid file"
403 fi
404 }
405
406 # dump a mysql database
407 my_dump_mysql_db() {
408 local database=$1;
409
410 echo "dumping database '$database' ..."
411 mysqldump -u patrick -ppatrick $database > $databse_dump_$(date +%m%d%Y).sql
412
413 }
414
415 my_dump_mysql_table() {
416 local database=$1;
417 local table=$2;
418
419 echo "dumping table '$table' from database '$database' ..."
420 mysqldump -u patrick -ppatrick $database $table > $table_dump_$(date +%m%d%Y).sql
421 }
422
423 my_uploadfile() {
424 local filename=$1
425 local ftp_url=$2;
426 local user=$3;
427 local password=$4;
428
429 echo "upload of '$filename' to '$ftp_url' by '$user' ..."
430 #curl -T $filename ftp://dev.africafilms.tv/movies/ --user dev.africafilms.tv:dev/aftv/DAK2602
431 curl -T $filename $ftp_url --user $user:$password
432 }
433
434 my_find_string() {
435 local string_to_find=$1;
436 local directory=$2;
437
438 echo "recursive looking for the string '$string' inside '$directory' directory"
439 grep -l -R -i -r $string_to_find $directory;
440 }
441
442 my_find_string2() {
443 local string_to_find=$1;
444 local directory=$2;
445
446 echo "recursive looking for the string '$string' inside '$directory' directory"
447 find $directory | xargs grep $string -sl;
448
449 }
450 # extract md5 hash from a string
451 my_xmd5() {
452 local string=$1;
453
454 echo "md5 hash of '$string' is: "
455 echo -n "$string" | md5sum;
456 }
457
458 # Creates an archive (*.tar.gz) from given directory.
459 my_maketar() {
460 local directory=$1;
461
462 tar cvzf "${directory%%/}.tar.gz" "${directory%%/}/";
463 }
464
465 # Create a ZIP archive of a file or folder.
466 my_makezip() {
467 local file=$1;
468
469 zip -r "${file%%/}.zip" "$file";
470 }
471
472 # Make your directories and files access rights sane.
473 my_sanitize() { chmod -R u=rwX,g=rX,o= "$@" ;}
474
475 # Get IP adress on ethernet.
476 my_ip() {
477 local my_ip=$( /sbin/ifconfig eth0 \
478 | awk '/inet/ { print $2 } ' \
479 | sed -e s/addr://);
480 local my_gtw="gtw: "$(netstat -nr | awk '{print $2}' | sed -n 3p);
481 echo ${my_ip:-"Not connected"}
482 echo ${my_gtw:-"Not connected"}
483 }
484
485 # Get current host related info.
486 my_host_info() {
487 echo -e "\nYou are logged on ${BRed}$HOST"
488 echo -e "\n${BRed}Local IP Address :$NC" ; my_ip
489 echo -e "\n${BRed}Current date :$NC " ; date; calendar | head -1
490 echo -e "\n${BRed}Additionnal information:$NC " ; uname -a
491 echo -e "\n${BRed}Users logged on:$NC " ; \
492 w -hs \
493 | cut -d " " -f1 \
494 | sort \
495 | uniq
496 echo -e "\n${BRed}Machine stats :$NC " ; uptime
497 echo -e "\n${BRed}Memory stats :$NC " ; free -h
498 echo -e "\n${BRed}Diskspace :$NC " ; mydf / $HOME
499 echo -e "\n${BRed}Open connections :$NC "; netstat -pan --inet;
500 echo
501 }
502
503 # Pretty-print of 'df' output. Inspired by 'dfc' utility.
504 my_df() {
505 local fs=$1;
506
507 for fs ; do
508
509 if [ ! -d $fs ]
510 then
511 echo -e $fs" :No such file or directory" ; continue
512 fi
513
514 local info=( $(command df -P $fs | awk 'END{ print $2,$3,$5 }') )
515 local free=( $(command df -Pkh $fs | awk 'END{ print $4 }') )
516 local nbstars=$(( 20 * ${info[1]} / ${info[0]} ))
517 local out="["
518 for ((j=0;j<20;j++)); do
519 if [ ${j} -lt ${nbstars} ]; then
520 out=$out"*"
521 else
522 out=$out"-"
523 fi
524 done
525 out=${info[2]}" "$out"] ("$free" free on "$fs")"
526 echo -e $out
527 done
528 }
529
530 # create_vm(){
531 # debootstrap --verbose \
532 # --variant=minbase \
533 # --arch=i386 --include ifupdown,locales,libui-dialog-perl,dialog,dhcp3-client,netbase,net-tools,iproute,openssh-server \
534 # sid /var/lib/lxc/sid http://ftp.debian.org/debian
535
536 # }
537
538
539 my_add_todo(){
540 local rememberfile="$HOME/.remember"
541 # if the file not exists, touch it
542 [[ ! -f $rememberfile ]] && touch $rememberfile
543 if [ $# -eq 0 ] ; then
544 echo "Type what you want to remember then, hit ^D: "
545 cat - >> $rememberfile;
546 else
547 #echo $(date +%m%d%Y)" -- $@" >> $rememberfile
548 echo $(date +%F)" -- $@" >> $rememberfile
549 fi
550 }
551
552 my_reminder(){
553 local rememberfile="$HOME/.remember"
554
555 #is_not_file $remberfile && echo 'nothing to do' ||
556 #is_empty $rememberfile && echo 'nothing to do' ||
557 #display_todo "$@"
558 is_not_file $rememberfile || [[ $(cat $rememberfile | wc -l) = 0 ]] && echo "nothing to do" || my_display_todo "$@";
559 }
560
561 my_display_todo(){
562
563 local rememberfile="$HOME/.remember"
564 echo $#;
565 #[[ $# -eq 0 ]] && more $rememberfile || grep -i "$@" $rememberfile | more;
566 [[ $# -eq 0 ]] && is_file $rememberfile && is_not_empty_file $rememberfile && cat $rememberfile || grep -i "$@" $rememberfile;
567 }
568
569
570 my_lsbytesum() {
571 #lsbytesum - sum the number of bytes in a directory listing
572 TotalBytes=0
573 for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }')
574 do
575 let TotalBytes=$TotalBytes+$Bytes
576 done
577 TotalMeg=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc)
578 echo -n "$TotalMeg"
579 }
580
581 # list
582 my_create_list(){
583 local listname=$1;
584 declare -a $listname;
585 }
586
587 # sensonet
588
589 sensonet_create_event() {
590 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
591 }
592
593 sensonet_update_event() {
594 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
595 }
596
597 sensonet_events() {
598 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/ || \
599 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
600 }
601
602 sensonet_del_event() {
603 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
604 }
605
606 sensonet_create_sensor() {
607 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
608 }
609
610 sensonet_update_sensor() {
611 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
612 }
613
614 sensonet_del_sensor() {
615 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
616 }
617
618 sensonet_sensors() {
619 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/ || \
620 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
621 }
622
623 sensonet_create_network(){
624 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
625 }
626
627 sensonet_update_network(){
628 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
629 }
630
631 sensonet_del_network(){
632 curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
633 }
634
635 sensonet_networks(){
636 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/ || \
637 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
638 }
639
640 sensonet_network_probes() {
641 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"/probes
642 }
643
644 sensonet_create_probe() {
645 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
646 -d "name=${1}&latitude=0.0&longitude=0.0&monitorMe=1&sleepingTime=0&networkId=univlab" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
647 }
648
649 sensonet_update_probe() {
650 curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
651 -d "name=${1}&latitude=48.0&longitude=-1.0&monitorMe=1&sleepingTime=0" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
652 }
653
654 sensonet_probes() {
655 [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/ || \
656 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"
657 }
658
659 sensonet_del_probe() {
660 curl -i -X "DELETE" -k -H -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
661 }
662
663 sensonet_probe_neighborhood(){
664 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/neighborhood
665 }
666
667 sensonet_probe_set_sleeping_time(){
668 curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "duration=${2}" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sleepingtime
669 }
670
671 sensonet_probe_sensors(){
672 [[ $# -eq 1 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors || \
673 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"
674 }
675
676 sensonet_probe_sensor_values(){
677 curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"/values
678 }
679
680 # from nixcraft
681 # Show top 10 history command on screen
682 function ht {
683 history | awk '{a[$2]++}END{for(i in a){print a[i] " " i}}' | sort -rn | head
684 }
685
686 # Wrapper for host and ping command
687 # Accept http:// or https:// or ftps:// names for domain and hostnames
688 _getdomainnameonly(){
689 local h="$1"
690 local f="${h,,}"
691 # remove protocol part of hostname
692 f="${f#http://}"
693 f="${f#https://}"
694 f="${f#ftp://}"
695 f="${f#scp://}"
696 f="${f#scp://}"
697 f="${f#sftp://}"
698 # remove username and/or username:password part of hostname
699 f="${f#*:*@}"
700 f="${f#*@}"
701 # remove all /foo/xyz.html*
702 f=${f%%/*}
703 # show domain name only
704 echo "$f"
705 }
706
707
708 ping(){
709 local array=( $@ ) # get all args in an array
710 local len=${#array[@]} # find the length of an array
711 local host=${array[$len-1]} # get the last arg
712 local args=${array[@]:0:$len-1} # get all args before the last arg in $@ in an array
713 local _ping="/bin/ping"
714 local c=$(_getdomainnameonly "$host")
715 [ "$t" != "$c" ] && echo "Sending ICMP ECHO_REQUEST to \"$c\"..."
716 # pass args and host
717 $_ping $args $c
718 }
719
720 host(){
721 local array=( $@ )
722 local len=${#array[@]}
723 local host=${array[$len-1]}
724 local args=${array[@]:0:$len-1}
725 local _host="/usr/bin/host"
726 local c=$(_getdomainnameonly "$host")
727 [ "$t" != "$c" ] && echo "Performing DNS lookups for \"$c\"..."
728 $_host $args $c
729 }