Blog Detail
Linux and unix shell scripts container
http://linuxscripting.blogspot.com/
Scripts, Manuals, Tips, Tricks and Hints in using and administering Linux, Solaris, BSD, Unix. Shell scripts, Bash, sh, zsh, ash, csh, sed, awk, man, info, perl, ruby, php, python, cgi, programming.
Recent Posts
Seconds to hours and minutes
This program format an arbitrary number of seconds into hours and minutes: #!/bin/bashseconds=0echo -n "Enter number of seconds > "read secondshours=$((seconds / 3600))seconds=$((seconds % 3600))minutes=$((seconds / 60))seconds=$((seconds % 60))ech...
Simple array usage in Bash
#!/bin/basharray=(one two three four [5]=five)echo "Array size: ${#array[*]}"echo "Array items:"for item in ${array[*]}do printf " %s\n" $itemdoneecho "Array indexes:"for index in ${!array[*]}do printf " %d\n" $indexdoneecho "Array items an...
Fifth basic front end with dialog/Xdialog - Building a Gauge
A gauge based on dialog can be used to indicate progress of your program. Building a gauge is slightly tricky. Look at the following example: #!/bin/shDIALOG=${DIALOG=dialog}COUNT=10(while test $COUNT != 110doecho $COUNTecho "XXX"echo "The new\n\mes...
Fourth basic front end with dialog/Xdialog - Radiolist and Checklist
Radiolists and checklists can be programmed just like menus. A simple radio list example is given below. #! /bin/shDIALOG=${DIALOG=dialog}tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$trap "rm -f $tempfile" 0 1 2 5 15$DIALOG --backtitle "...
Third basic front end with dialog/Xdialog - building menu
Try the following program both in console and X (after changing dialog to Xdialog as before): #!/bin/shDIALOG=${DIALOG=dialog}tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$trap "rm -f $tempfile" 0 1 2 5 15$DIALOG --clear --title "My favor...
Second basic front end with dialog/Xdialog
The following script reads a string you input and prints it back.#!/bin/shDIALOG=${DIALOG=dialog}tempfile=`tempfile 2>/dev/null` || tempfile=/tmp/test$$trap "rm -f $tempfile" 0 1 2 5 15$DIALOG --title "My input box" --clear \ --inputbox "Hi, t...

