Sponsored Content
Operating Systems OS X (Apple) The Alternate DC board for AudioScope.sh. Post 302947904 by Don Cragun on Tuesday 23rd of June 2015 06:34:02 PM
Old 06-23-2015
Here is your script with two additional ways to produce the same results. Maybe you'll like one of these alternatives better than your current code...
Code:
#!/bin/bash
range_lows=(100 200 300 400 500)
# lookup
while true
do
	read -p "Number, 100 to 499:- " num
	echo 'Using original if statements:'
	if [ $num -ge 100 ] && [ $num -le 199 ]
	then
		echo "1) $num"
	fi
	if [ $num -ge 200 ] && [ $num -le 299 ]
	then
		echo "2) $num"
	fi
	if [ $num -ge 300 ] && [ $num -le 399 ]
	then
		echo "3) $num"
	fi
	if [ $num -ge 400 ] && [ $num -le 499 ]
	then
		echo "4) $num"
	fi
	printf '\nUsing if-else sequence:\n'
	if [ "$num" -lt 100 ]
	then :
	elif [ "$num" -le 199 ]
	then	echo "1) $num"
	elif [ "$num" -le 299 ]
	then	echo "2) $num"
	elif [ "$num" -le 399 ]
	then	echo "3) $num"
	elif [ "$num" -le 499 ]
	then	echo "4) $num"
	fi
	printf '\nUsing array lookup:\n'
	for((i=0; i < ${#range_lows[@]}; i++))
	do 	[ "$num" -lt ${range_lows[i]} ] && break
	done
	[ $i -gt 0 ] && [ $i -lt ${#range_lows[@]} ] && echo "$i) $num"
done

All of these could be simplified considerably if you know that $num will expand to a number within your known ranges. All of these will fail if $num does not expand to a numeric string.
This User Gave Thanks to Don Cragun For This Post:
 

9 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Board Maintenance

Just a remark now the board has grown to considerable proportion. I see too little of an active hand(s) maintaning the boards, clipping away dead posts, moving posts that were created in the wrong forums etc. It's a bit tiring to see alot of threads ending in: this has been covered before, do a... (7 Replies)
Discussion started by: patvdv
7 Replies

2. What is on Your Mind?

AudioScope has had a magazine review. <shock>

Hi Admin and Staff... Thanks for hosting AudioScope.sh on this site. I have had the biggest surprise of my life today. This months issue of the UK Linux magazine "Linux Format" have done a small piece on the project. Issue April 2014, LXF 182, page 65... This I never expected and I... (1 Reply)
Discussion started by: wisecracker
1 Replies

3. OS X (Apple)

AC to DC trigger pulse for AudioScope.sh.

Hi all... Has _below_ ever been done in UNIX shell scripting before? (I have done this easily in Python but this is using purely the shell.) The DEMO version IS built and has been tested. Pre-amble... I now need at least one control pulse for the AudioScope.sh when in PURELY audio I/O mode,... (2 Replies)
Discussion started by: wisecracker
2 Replies

4. Shell Programming and Scripting

Experimental awk audio converter for CygWin and AudioScope.sh

Development machine:- Standard MBP 13 inch, OSX 10.7.5... GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11) Copyright (C) 2007 Free Software Foundation, Inc. Scenario:- Audio capture for AudioScope.sh for CygWin without ANY third party installs. I am trying my hardest to get a... (6 Replies)
Discussion started by: wisecracker
6 Replies

5. How to Post in the The UNIX and Linux Forums

Board not present

Can please somebody tell me what could be the reason for the following error (Unix Motorola Server): /usr/etc/ce3/s374: Board at address 0xff10000 not present - Entry skipped. /dev/lpc2: I/O error I already replaced the board 374 on the server, but I have the same problem. Thank you! (1 Reply)
Discussion started by: dma
1 Replies

6. What is on Your Mind?

AudioScope...

Boy oh boy, with only a MONO mic input to use AudioScope gets much more difficult when the ALTDC board is included. It needs, so far, two hits at the MIC input with a single hit at the HEADPHONE audio output. The first at the highest practical resolution for the AC component and the second... (0 Replies)
Discussion started by: wisecracker
0 Replies

7. OS X (Apple)

The DC Control and Timer boards for AudioScope.sh...

Hi all... Apologies for any typos... For those intersted in the AudioScope the next construction is finished. I have not been totally idle but working out the hard stuff to be able to be very simple to build. It is a single transistor simple timer that lasts for about 1.2 to 1.8 seconds.... (2 Replies)
Discussion started by: wisecracker
2 Replies

8. UNIX for Advanced & Expert Users

Has AudioScope found a bug in bash 4.4.5?

Using AudioScope.sh on Ubuntu 17.04 from a live DVD disc I came across an error. Consider the code below it is a MUCH shortened version of the KEYBOARD input in AudioScope. #!/bin/bash bash --version uname -a status=0 KEYBOARD() { read -r -p "Enter QUIT or EXIT to quit:- " kbinput if ||... (11 Replies)
Discussion started by: wisecracker
11 Replies

9. OS X (Apple)

AudioScope Project.

AudioScope Project. (Apologies for any typos.) For the few following...... AudioScope.sh... Now at Version 0.60.00. Well this baby has come a long way since its inception in January 2013. It is now at Version 0.60.00. It is MUCH more Apple centric now with a new OSX Sierra minimum _silent_... (7 Replies)
Discussion started by: wisecracker
7 Replies
DISKTAB(5)						      BSD File Formats Manual							DISKTAB(5)

NAME
disktab -- disk description file SYNOPSIS
#include <disklabel.h> DESCRIPTION
Disktab is a simple database which describes disk geometries and disk partition characteristics. It is used to initialize the disk label on the disk. The format is patterned after the termcap(5) terminal data base. Entries in disktab consist of a number of `:'-separated fields. The first field for each entry gives the names by which a disk's entry may be selected, separated by `|' characters. The last name given should be a long name fully identifying the disk. The optional fields for each entry are: ID Type Description ty str Type of disk (e.g. removable, winchester) dt str Type of controller (e.g. SMD, ESDI, floppy) ns num Number of sectors per track nt num Number of tracks per cylinder nc num Total number of cylinders on the disk sc num Number of sectors per cylinder, ns*nt default su num Number of sectors per unit, sc*nc default se num Sector size in bytes, DEV_BSIZE default sf bool Controller supports bad144-style bad sector forwarding rm num Rotation speed, rpm, 3600 default sk num Sector skew per track, default 0 cs num Sector skew per cylinder, default 0 hs num Headswitch time, usec, default 0 ts num One-cylinder seek time, usec, default 0 il num Sector interleave (n:1), 1 default d[0-4] num Drive-type-dependent parameters bs num Boot block size, default BBSIZE sb num Superblock size, default 0 ba num Block size for partition `a' (bytes) bd num Block size for partition `d' (bytes) be num Block size for partition `e' (bytes) bf num Block size for partition `f' (bytes) bg num Block size for partition `g' (bytes) bh num Block size for partition `h' (bytes) fa num Fragment size for partition `a' (bytes) fd num Fragment size for partition `d' (bytes) fe num Fragment size for partition `e' (bytes) ff num Fragment size for partition `f' (bytes) fg num Fragment size for partition `g' (bytes) fh num Fragment size for partition `h' (bytes) oa num Offset of partition `a' in sectors ob num Offset of partition `b' in sectors oc num Offset of partition `c' in sectors od num Offset of partition `d' in sectors oe num Offset of partition `e' in sectors of num Offset of partition `f' in sectors og num Offset of partition `g' in sectors oh num Offset of partition `h' in sectors pa num Size of partition `a' in sectors pb num Size of partition `b' in sectors pc num Size of partition `c' in sectors pd num Size of partition `d' in sectors pe num Size of partition `e' in sectors pf num Size of partition `f' in sectors pg num Size of partition `g' in sectors ph num Size of partition `h' in sectors ta str Partition type of partition `a' (4.2BSD file system, swap, etc) tb str Partition type of partition `b' tc str Partition type of partition `c' td str Partition type of partition `d' te str Partition type of partition `e' tf str Partition type of partition `f' tg str Partition type of partition `g' th str Partition type of partition `h' FILES
/etc/disktab SEE ALSO
getdiskbyname(3), bsdlabel(8), newfs(8) HISTORY
The disktab description file appeared in 4.2BSD. BSD
October 14, 2006 BSD
All times are GMT -4. The time now is 06:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy