i have no understanding of how to write an array or use one, please help!
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
make 2 files. one to Input 10 numbers and print out the biggest number, and one to Write a script that can check your permission (read/write/execution) on the input filename as the argument.
2. Relevant commands, code, scripts, algorithms:
has to be made using arrays and the declare -a command
3. The attempts at a solution (include all code and scripts):
i have no understanding i can do it using arguements but not with an array
4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
University of michigan, michigan, chang, cse 132
Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
1. declare -a [arrayvariablename] is optional, but good practice
So:
2. to assign a value to an array element (one of the members of the array:
This now means that the fourteenth (remember we chose to start counting from 0?)
contains 4.
3. So we want to enter ten numbers right? We need a loop to count from 0 .. 9
i becomes 0 then 1,2,3..... as the loop goes on.
You now have 10 array element, each of which has a number in it. Let's find the biggest one.
So let us stomp thru the array and assign something to another variable, call it max
display the result:
Have fun....
PS:
is shell shorthand for if [ ] then do something endif.
Hi Unix Gurus,
I need to grep for a block that is between a start and end keyword and then in between I need to find and replace a keyword.
for eg: I need to search between Test = 000; and Test = 000; and find K9 and replace with M9
INPUT FILE
Define {
Replace = K9;
Test =... (6 Replies)
Hello there,
I am a newbie to unix and i have been trying to code a shell script for bash shell which reads the files in a folder using ls and writes them into an array variable. But, i am running into several errors while running the script. The script is given below:
#!/bin/bash... (16 Replies)
Hi,
I have a bash script that currently holds some data. I am trying to write all the contents to a file called temp.txt.
I am using
echo ${array} > temp.txt
The problem that I am experiencing is that the elements are being written horizontally in the file. I want them written... (5 Replies)
I have an array and two variables as below,
I need to check if $datevar is present in $filename.
If so, i need to replace $filename with the values in the array.
I need the output inside an ARRAY
How can this be done.
Any help will be appreciated. Thanks in advance. (2 Replies)
im in a basic unix class and our professor speaks broken engliash so i can never understand what exactly we are doing in class and i have no prior experience with unix. we were given an assignment to make 2 files. one to Input 10 numbers and print out the biggest number, and one to Write a script... (1 Reply)
NEWBIE ALERT!
Hi,
I'm 1 month into learning Perl and done reading "Minimal Perl" by Tim Maher (which I enjoyed enoumously). I'm not a programmer by profession but want to use Perl to automate various tasks at my job. I have a problem (obviously) and are looking for your much appreciated help.... (0 Replies)
Hello,
I have an array in which output of a query is stored. These values can be accessed by,
foreach my $val (@result){
print ("\nValue : @{$val} from result");}
Can anybody please explain me, how to delete any particular element in array @result ? (4 Replies)
Ok, so I'm trying to finalize my understanding of read/write and kernel interaction.
read():
You have a library function that has as it's first parameter (what the open file to read from is), second parameter( a pointer to a buffer (is this the location of a buffer in the user area or the... (7 Replies)
Ok, so I'm trying to finalize my understanding of read/write and kernel interaction.
read():
You have a library function that has as it's first parameter (what the open file to read from is), second parameter( a pointer to a buffer (is this the location of a buffer in the user area or the... (1 Reply)