I am trying to read files one by one by using the for loop like below, by passing argument to the functions. Argument 3 makes lot of problem due to space in file names.
Example:
source_file_restructure()
{
echo "inside the function"
source_folder=$1
target_folder=$2
file_pattern=$3
delimiter=$4
echo $file_pattern
echo " Getting inside the function.... "
for file_name in `ls -Al ${source_folder}*"${file_pattern}"*.csv`
do
some processing.......
done
The above ls command not working properly when there are files contain white spaces like file 1.csv,
Input :
SOurce Folder : /home/test/
File Pattern : "file"
Function argument :
source_file_restructure ${source_folder} ${target_folder} "${file_pattern}" ${delimiter}
Suggest some option to handle the problem.
ls
for parsing the file names. Instead usefind
in awhile
loop. – Ramesh Oct 19 '14 at 16:42