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 functionsource_folder=$1target_folder=$2file_pattern=$3delimiter=$4echo $file_patternecho  Getting inside the function.... for file_name in `ls -Al ${source_folder}*${file_pattern}*.csv`dosome processing.......doneThe above ls command not working properly when there are files contain white spaces like file 1.csv,Input :SOurce Folder : /home/test/File Pattern : fileFunction argument : source_file_restructure ${source_folder} ${target_folder} ${file_pattern} ${delimiter}Suggest some option to handle the problem.
How to List files which contain white space in filename?
linux;sed;awk
Replacefor file_name in `ls -Al ${source_folder}*${file_pattern}*.csv`With:for file_name in ${source_folder}*${file_pattern}*.csvThe output of a command in backticks, as in the first form above, is subject to word-splitting.  The second form above does not use backticks.  It will, by contrast, work with  any file name, even ones that contain spaces, tabs, newlines or any other difficult character.Also, replacesource_file_restructure ${source_folder} ${target_folder} ${file_pattern} ${delimiter}Withsource_file_restructure ${source_folder} ${target_folder} ${file_pattern} ${delimiter}Without the double-quotes, the shell will perform word-splitting.  With the double-quotes, the function will be called correctly even if source_folder or target_folder have spaces, tabs, newlines, or other difficult characters.