Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
sample shell script using arrays
Name: John Beards Date: September 9, 2002 at 11:31:35 Pacific OS: Red Hat 7.x CPU/Ram: PIII / 128 MB
Comment:
Can someone please provide sample code that utilizes arrays. Or please direct me to a web site that provides good explanations onhow to implement arrays in shell scripts.
Name: Jerry Lemieux Date: September 9, 2002 at 17:10:39 Pacific
Reply:
Example:
Name[1]="Fred" Name[2]="Joe" print ${Name[*]}
The first 2 commands assign Fred and Joe to slots 1 and 2 in the array (I could have used 0, but that confuses new people). The third command will output:
Fred Joe
Counting the array members is done by:
print ${#Name[*]}
Print the first member of the array:
print ${Name[1]}
Print the second member of the array:
print ${Name[2]}
And there you have all you need to know to create your very own array.
Summary: Hi, I'm trying to run loops in shell scripts using the following script. loop=1 while [ loop -lt 10 ] do echo 'this is my $loop text-line' loop='expr $loop + 1' done ---- but I'm getting error: test: ...
Summary: Before using a file as a shell script you must change its access permissions so that you have execute permission on the file, otherwise the error message Permission deniedis displayed. To run the shel...
Summary: Hi, I am writing a shell script to accept input from user and upload the data files using sqlloader. I want to trap Ctrl-Z which is SIGTSTP so that user do not come out of the shell script using Ctrl-...