Sponsored Content
Top Forums Shell Programming and Scripting Reduce the number of lines by using Array Post 302931007 by sea on Friday 9th of January 2015 10:52:39 AM
Old 01-09-2015
Here is something to get started, to chew on Smilie

Code:
#!/bin/bash
#
#
#	Variables
#
	declare -A AGE				# Create an associative array
	NAMES="Kim Lee Jack Sam Nick Smith"	# List with names
#
#	Fill the array
#
	select name in Back $NAMES;do		# Select an entry of the list NAMES
		[[ $name = Back ]] && break	# Exit the select-loop / break out
		
		echo "Hello $name, what is your age?"
		read age
		AGE[$name]=$age			# Set the arrays entry '$name' to value '$age'
	done
#
#	Output the content
#
	for n in $NAMES
	do
		echo "$n is ${AGE[$n]} years old"
	done
	echo "Have a nice day :)"

Hope this helps
This User Gave Thanks to sea For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to reduce multiple files into a specific number of files

Can anyone please let me know how do I reduce files into a specific number of files by cat'ing files? For example: 15 files must be reduced to 1 or 5 or 9 (possible values 1 to 14) (5 Replies)
Discussion started by: aryanbelank
5 Replies

2. Shell Programming and Scripting

How to insert the number to an array

Hi I work in ksh88 and have a file which has several "set -A " statements: set -A PNUM_LSTM 2713 4124 2635 270 2529 2259 2214 set -A PNUM_LSTM $* for pn in ${PNUM_LSTM} etc... I need to add another number, lets say 555, to the first line ONLY so only the the first line will be updated... (2 Replies)
Discussion started by: aoussenko
2 Replies

3. Shell Programming and Scripting

Number lines of file and assign variable to each number

I have a file with a list of config files numbered on the lefthand side 1-300. I need to have bash read each lines number and assign it to a variable so it can be chosen by the user called by the script later. Ex. 1 some data 2 something else 3 more stuff which number do you... (1 Reply)
Discussion started by: glev2005
1 Replies

4. Shell Programming and Scripting

count the number of lines that start with the number

I have a file with contents similar to this. abcd 1234 4567 7666 jdjdjd 89289 9382 92 jksdj 9823 298 I want to write a shell script which count the number of lines that start with the number (disregard the lines starting with alphabets) (1 Reply)
Discussion started by: grajp002
1 Replies

5. Shell Programming and Scripting

Largest number in array. Help!

I need to calculate the biggest number in array size n. Example: Users enter: 1 7 4 9 The biggest number is : 9 Simple but I'm really new on this on Shell/Bash! Anything will be helpful! Thanks! #!/bin/bash printf "\tEnter a list of numbers, with spaces: " read -a ARRAY BIG=$1... (5 Replies)
Discussion started by: Sundown
5 Replies

6. UNIX and Linux Applications

Looking to reduce the number a cpus available for SGE

Hey all Im looking to reduce the number of cpus available on a certain node in our cluster available for jobs using SGE. i.e. we have one node that has 24 cpus available for jobs on SGE, i would like to reduce that to 16. Thanks (1 Reply)
Discussion started by: olifu02
1 Replies

7. Shell Programming and Scripting

Reduce the number of lines in script

Hello All, I have created a script which will show the errors from a log file in between a particular section. v1=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to find' v2=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to add' if then echo... (5 Replies)
Discussion started by: Vikram_Tanwar12
5 Replies

8. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

9. Programming

Code review: recursion in circular array, reduce two functions to one?

Hello, I think there's an easier way to do this but can't seem to recall but given an array of animals and an initial value is a random index in the array, here it's 3. 3,4,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0... inifinite repeat a quick brute force solution i came up with was two functions, i... (6 Replies)
Discussion started by: f77hack
6 Replies

10. UNIX for Beginners Questions & Answers

Print number of lines for files in directory, also print number of unique lines

I have a directory of files, I can show the number of lines in each file and order them from lowest to highest with: wc -l *|sort 15263 Image.txt 16401 reference.txt 40459 richtexteditor.txt How can I also print the number of unique lines in each file? 15263 1401 Image.txt 16401... (15 Replies)
Discussion started by: spacegoose
15 Replies
AGE(4)							   BSD Kernel Interfaces Manual 						    AGE(4)

NAME
age -- Attansic/Atheros L1 Gigabit Ethernet driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device miibus device age Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): if_age_load="YES" DESCRIPTION
The age device driver provides support for Attansic/Atheros L1 PCI Express Gigabit Ethernet controllers. All LOMs supported by the age driver have TCP/UDP/IP checksum offload for both transmit and receive, TCP segmentation offload (TSO), hardware VLAN tag stripping/insertion features and an interrupt moderation mechanism as well as a 64-bit multicast hash filter. The L1 also supports Jumbo Frames (up to 10240 bytes), which can be configured via the interface MTU setting. Selecting an MTU larger than 1500 bytes with the ifconfig(8) utility configures the adapter to receive and transmit Jumbo Frames. The age driver supports the following media types: autoselect Enable autoselection of the media type and options. The user can manually override the autoselected mode by adding media options to rc.conf(5). 10baseT/UTP Set 10Mbps operation. 100baseTX Set 100Mbps (Fast Ethernet) operation. 1000baseTX Set 1000baseTX operation over twisted pair. The age driver supports the following media options: full-duplex Force full duplex operation. half-duplex Force half duplex operation. For more information on configuring this device, see ifconfig(8). HARDWARE
The age driver provides support for LOMs based on Attansic/Atheros L1 Gigabit Ethernet controller chips, including: o ASUS M2N8-VMX o ASUS M2V o ASUS M3A o ASUS P2-M2A590G o ASUS P5B-E o ASUS P5B-MX/WIFI-AP o ASUS P5B-VMSE o ASUS P5K o ASUS P5KC o ASUS P5KPL-C o ASUS P5KPL-VM o ASUS P5K-SE o ASUS P5K-V o ASUS P5L-MX o ASUS P5DL2-VM o ASUS P5L-VM 1394 o ASUS G2S LOADER TUNABLES
Tunables can be set at the loader(8) prompt before booting the kernel or stored in loader.conf(5). hw.age.msi_disable This tunable disables MSI support on the Ethernet hardware. The default value is 0. hw.age.msix_disable This tunable disables MSI-X support on the Ethernet hardware. The default value is 0. SYSCTL VARIABLES
The following variables are available as both sysctl(8) variables and loader(8) tunables: dev.age.%d.int_mod Maximum amount of time to delay interrupt processing in units of 2us. The accepted range is 0 to 65000, the default is 50 (100us). Value 0 completely disables the interrupt moderation. dev.age.%d.process_limit Maximum amount of Rx events to be processed in the event loop before rescheduling a taskqueue. The accepted range is 30 to 255, the default value is 128 events. The interface does not need to be brought down and up again before a change takes effect. dev.age.%d.stats Display lots of useful MAC counters maintained in the driver. SEE ALSO
altq(4), arp(4), miibus(4), netintro(4), ng_ether(4), vlan(4), ifconfig(8) HISTORY
The age driver was written by Pyun YongHyeon <yongari@FreeBSD.org>. It first appeared in FreeBSD 7.1. BSD
September 18, 2008 BSD
All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy