Script to store the variable in a table or array.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to store the variable in a table or array.
# 1  
Old 06-06-2011
Script to store the variable in a table or array.

Hi,

I have few variable say 10

ex:-
l_pc_291334_01_0_01_00.cmp
l_pc_441133_50_0_02_00.cmp
l_pc_441133_55_0_02_00.cmp

Each variable value is coming via loop on a table.

I want to create a script that stores these value to a table or array ( But one by one not all at one time as it is in loop ).

Once in the table or array , we need to write it in last using while or do statement.

Please help i am new in creating script.
# 2  
Old 06-06-2011
what are you trying achieve here, please give us your requirement with out coding terms.

we can interpret your requirement in thousands of way unless you make it precise.
# 3  
Old 06-06-2011
Can you please specify your requirements more clearly.
Give some sample inputs and expected output.
# 4  
Old 06-06-2011
You can use 'set' command. Lets say you get a list of inputs from a directory, store it in an array and then call a function for each of the entries in array.

Code:
 
set -A arrayName `ls *.txt`
for anEntry in ${arrayName[*]}; do
 functionName ${anEntry}
done

# 5  
Old 06-06-2011
Input say i have 10 files.
Like :-
/home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CGM/l_pc_112138_01_0_01_00.cgm
/home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CMP/l_pc_112138_01_0_01_00.cmp
/home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CGM/l_pc_112138_01_0_02_00.cgm
/home/td_8d02_int_data_IPCL/ILLUSTRATIONS/CMP/l_pc_112138_01_0_02_00.cmp
/home/td_8d02_int_data_IPC-L/ILLUSTRATIONS/CGM/l_pc_112138_02_0_01_00.cgm

I want to create a Script for these files. In the script i will check the size of file and it's existance .

******************Now from here the creation of scripting starts*********************** ( Need your help in this , please create a full script for me )

#!/bin/ksh

let nb_error = 0.
let nb_error_exist = 0.

Test -s Path + lw_file ( Please tell wether it is ok or not , we have to check the size of file greater than zero )

if [$? ! = "0"]
then
let nb_error = $ nb_error + 1

*************** Now here i want a internal table or array to store the file name only which is empty *************

Store the file name in a table1.

test -e path+lw_file ( Please tell wether it is ok or not , we have to check the existance of the file )

if [$? ! = "0"]
then
let nb_error_exist = $ nb_error_exist+ 1


*************** Now here i want a internal table or array to store the file name only which does not exist *************

Store the file name in a table2.

FI
FI

List of missing released illustrations ( *Constant value )

Loop on table1.
Write the file name.

List of missing released illustrations ( *Constant value )

Loop on table2.
Write the file name.


Output will be Like below :-

List of missing rfiles

l_pc_291334_01_0_01_00.cmp
l_pc_441133_50_0_02_00.cmp
l_pc_441133_55_0_02_00.cmp

List of empty files

l_pc_534941_01_0_01_00.cmp

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script to loop and store in array

I'm trying to achieve the follwoinig with no luck. Find the directories that are greater than 50GB in size and pick the owner of the directory as I would like to send an alert notification. du -sh * | sort -rh 139G Dir_1 84G Dir_2 15G Dir_3 ls -l Dir_1 drwx------ 2... (3 Replies)
Discussion started by: 308002184
3 Replies

2. Shell Programming and Scripting

Bash to store result in variable for other lines in script to use

I can not figure out how to capture the $filename variable store by the bash. #!/bin/bash # oldest folder stored as variable for analysis, version log created, and quality indicators matched to run dir=/home/cmccabe/Desktop/NGS/test find "$dir" -maxdepth 1 -mindepth 1 -type d -printf... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

create an array which can store the strings from the user input in shell script

I want to create an array which can store the strings from the user input in shell script . example :- I want to store the 5 fruits name in a single array which the user provides . (1 Reply)
Discussion started by: Pkast
1 Replies

4. Shell Programming and Scripting

Store values from a file into an array variable in Shell

Dear All, I have been trying to do a simple task of extracting 2 fields from the file (3 rows) and store it in an array variable. I tried with: #! /bin/bash ch=`cut -f10 tmp.txt` counter=0 for p in $pid do c=${ch} echo "$c ..$counter" counter=$((counter+1))... (2 Replies)
Discussion started by: ezhil01
2 Replies

5. Shell Programming and Scripting

Store all the passed arguments in an array and display the array

Hi I want to write a script which store all the parameters passed to the script into an array. Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD. I want to know how can I... (3 Replies)
Discussion started by: dgmm
3 Replies

6. Shell Programming and Scripting

bash Script: Issue with iterating Directory and store into array

Hi all, I am working on a backup based script, in which it enters to a directory and check the sub-directories and copy the names into an array. cd $CPFs k=0 for i in * do if then ARRs="$i" k=$(($k+1)) #echo "$i" ... (19 Replies)
Discussion started by: canishk
19 Replies

7. Shell Programming and Scripting

How to store contents of a command in array of variables in shell script?

I want to store contents of command dir in array of variables For eg: dir contents are command d2 demovi~ file inven java new untitled folder d1 demovi er1 filename inven~ myfiles ubuntu desktop xmms ----------------------------------- I... (3 Replies)
Discussion started by: netresearch
3 Replies

8. Shell Programming and Scripting

How to store query multiple result in shell script variable(Array)

:) Suppose,I have one table A. Table A have one column. Table A have 10 rows. I want this 10 rows store into shell script variable. like #!/bin/ksh v_shell_var=Hi here in call oracle , through loop How can I store table A's 10 rows into v_shell_var (Shell Script Array). Regards, Div (4 Replies)
Discussion started by: div_Neev
4 Replies

9. Shell Programming and Scripting

When can a script deny to store any value in a variable

In a shell script, I am storing some values into variables. In between the code I am calling an PL/SQL precedure by connecting to ORACLE which generates a file. All this happens fine. The problem is, the values are not getting stored in variables after this PL/SQL code while perfectly before... (1 Reply)
Discussion started by: mitte_dino
1 Replies

10. Shell Programming and Scripting

Store return code of shell script in oracle table

Hi friends, I have to do the following things : 1) there should be a shell script returning the returning the return code of the script. and i have to add some more details like on which machine is has run , at what time and other details and then using plsql i have to add a row to Oracle... (3 Replies)
Discussion started by: sveera
3 Replies
Login or Register to Ask a Question