siva siva - 4 months ago 10
Bash Question

How to store and iterate the list of files in a directory(each file need to pass as a input for java module)

i am new to the shell script . i have a requirement that i need to pass a input file (one at a time)for the java program.i have a multiple inputfiles in the directory.how to store and iterate the input files.any code snippet for this is helpful .thanks in advance

Answer

Something on the below lines.
Create array of files

files=$(ls <directory name with complete path which contains all the files>)
e.g: files=$(ls /tmp/siva/)

Access items from an array:

for i in "${files[@]}";
do;
java <your classname> $i;
done;

Reference

Let me know if you need further help