I have a requirement where in i have to read all the filenames based on a pattern from a directory and concatenate all these file names and write it to another file.
i am using the following code to do this
var1=''
for filename in $_DIR/${FILE_NAME}*
do
if
if [ X${var1} = "X" ]
then
var1=$var1$filename
else
var1=$var1:$filename
fi
done
`echo "$var1"` >> $DIR/$filename_out.txt
its taking really long time to execute this script if there are more number files matching the pattern.
can any one suggest a better appraoch, than above one?
for the heck...i want the output to be in the form
DIR/filename: DIR/filename2: DIR/filename3: DIR/filename4..so on to be added to the output file.
[space between : and DIR is not required but the webpage was converting it to a smiley :D. so i have kept the space. in original output that space is not required]
where filename[1-4]..files matching the pattern 'filename' in the DIR
as i mentioned i was able to do this..but just wanted to know if there is any better way to do this....