Scripting problem: Output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting problem: Output
# 1  
Old 01-20-2009
Scripting problem: Output

#!/bin/ksh
animal[0]="horse"
animal[1]="Unicorn"
animal[2]="Tiger"
animal[6]="Camel"
print
print "$animal[0]"
print "$animal[1]"
integer marks_score
marks_score[0]=99
marks_score[1]=94
marks_score[2]=96
print -n "enter the score on the final exam:"
read marks_scores[3]
marks_scores[4]=77

In the above script, this is how to declare array of strings and integers.
I am stuck up with a problem.
Actually i want all the array of string values to be printed one by one in my output,i.e, in my output,it should display,like this:
horse
Unicorn
Tiger
Camel

Please fix this problem. Everyone 's help is really appreciated..
# 2  
Old 01-20-2009
U can use echo command instead of Print. There is no need of array u can directly assign values to the variables
# 3  
Old 01-20-2009
Code:
printf "%s\n" "${anima[@]}"

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help in populating output in table using shell scripting

Below is my code where i tried using table tag to print out put in table but its not working #!/bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1";... (5 Replies)
Discussion started by: ankit.mca.aaidu
5 Replies

2. Homework & Coursework Questions

Save output into file bash scripting

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: Hi there. i have created a program that in the end it will give output like this 1 2 3 4 5 10 9 ... (1 Reply)
Discussion started by: shdin271
1 Replies

3. Shell Programming and Scripting

Save output into file bash scripting

Hi there. i have created a program that in the end it will give output like this 1 2 3 4 5 10 9 8 7 6 11 12 13 14 15 .............. 17 i wonder how to save the output into a single string and into a file. i.e 1 10 11 12 9 2 3 8 13 14 7 4 5 6 15 17 (in this order,... (3 Replies)
Discussion started by: shdin271
3 Replies

4. Shell Programming and Scripting

Need help in shell Scripting to display a output from a command

Please find my below requirement and see if you can help me on this. I am looking for a shell script which can provide me the below output. Manuall steps which i am doing now 1) First I source the File $ . ./WC_env.sh 2) Execute the command $ /app/oracle/product/mos/bin/mosotl -url... (2 Replies)
Discussion started by: sudheshpn@gmail
2 Replies

5. UNIX for Advanced & Expert Users

Help on Shell Scripting - to store output to a fixed file

Hi I have a file called "test.txt" and it looks like this x y z x/c y/c/b now, i want to run a command and its output will be like this x 10 y/c/b 20 z 78 -------- my requirement is, i want to add the command output to "test.txt" as like below x 10 y ... (1 Reply)
Discussion started by: siva kumar
1 Replies

6. Shell Programming and Scripting

how to store output into variable-in unix shell scripting

Hi, Output of "ps -o etime,time,pcpu,pmem,fname -C sbd-java" command is - Elapsed Time %cpu %MEM COMMAND 02:14:03 00:03:28 2.5 6.3 sbd-java Can anyone tell me, how to store the the value 2.5 in a variable? When I say echo $X where x is a variable then... (4 Replies)
Discussion started by: pspriyanka
4 Replies

7. AIX

Scripting AIX date output !!

Hi, I am writing a korn shell script in AIX. I want to pass the date as a parameter to script and inside it should convert the format to +%a" "%h" "%d" "%Y. For e.g., a parameter passed as "20100301" should be converted to "Mon Mar 01 2010". I can easily do this with AIX "date" option for... (2 Replies)
Discussion started by: shibajighosh
2 Replies

8. Shell Programming and Scripting

Assigning value of SQL output to a variable in shell scripting

I am trying to assgn the output of the select statement to a variable, like this "VARIABLE_NAME=$ db2 "select COLUMN_NAME_1 from TABLE_NAME where COLUMN_NAME_2='VALUE_TO_CHECK'"; " but the value that is getting into VARIABLE_NAME is "COLUMN_NAME_1 ----------------- VALUE 1... (3 Replies)
Discussion started by: sgmini
3 Replies

9. Shell Programming and Scripting

Learning scripting -- functions capturing output

Hi, everyone! First post here. I just assembled my first Linux computer and I'm trying to teach myself shell scripting. (Xubuntu and bash, respectively, but I'm not tied to either.) I'm writing a program to deal with different kinds of files (to be executed from a text editor -- LaTeX'ing a... (9 Replies)
Discussion started by: CRGreathouse
9 Replies
Login or Register to Ask a Question