Hi,
i have say 100 files in a directory.
file1.log
file2.log
file3.log
file4.log
file5.log
file6.log
...
...
...
file99.log
file100.log
I need to create another file which contains the list of al these log files.
each file should contain only 10 log file names.
it shud be like
filename1.list --- can contain first 10 log file, may be based on the timestamp.
filename2.list --- next 10 files.
So since we have 100 log files in this location, we need to get 10 filename*.list with 10 files in each file..
Did i confuse with the question? please let know
Please help
Regards,
Robz
Hello,
Here is a logic that you can use. Try to implement it and ask if you have problems constructing the statements.
- List al the log filenames.
- add the names to an array.
- loop through the array writing 10 records to a file
- change filename when 10 records are written
Regards,
HKansal
thanks bro.. but am writing a Shell script for this..
Array seems not possible...
u got any code snippet
Regards,
Robin Paulose
somewhat like this can work...modify it if u need...
set -A _Array `ls file*`
i=0
j=10
for file_name in ${_Array[@]}
do
if [[ $j -eq 10 ]]; then
j=0;
(( i = $i + 1 ))
>filename$i.list
fi
echo $file_name >> filename$i.list
(( j = $j + 1 ))
done
Here I would say "good job Rakesh" as you captured the logic I stated earlier.
But I would have considered it better to give that step wise. Anyways, the job's done I guess.
Regards,
HKansal