Skip to main content

Posts

Showing posts from September, 2014

Shell Programming : Array using input file values

Shell Programming : Array using input file values
I have created a test script for understanding of "Array" using shell script. It is like perl or any other language but need to understand the requirement of array and use of it.
I need to parse a list of file names which will be collected by ls command. Then it need to print it again in double loop with some other command in bulk.
Programming Logic: 1. parse all file names correctly in array 2. print array with each its elements for testing 3. create a loop for number of file names by using print of each element of array 4. create a second loop in first loop for file names 5. print all file names with additional command without executing 6. collect output of this script and run it for your purpose.
#!/bin/sh
###### take file names
file1=file1.txt
file2=file2.txt
file3=file3.txt
pscript1=perlScript.pl
##########################
# declear and convert into array
declare -a array1
declare -a array2
declare -a array3
array1=($(ca…