I need to pass a list to a KornShell (ksh) function, something like this:
#!/bin/ksh
print_list ()
{
Files=$1
for file in $(Files);do
echo $file
done
}
LogFiles=`find . -type f -name "*.log"`
print_list $LogFiles
When I try to run only first element in the list gets printed. Any suggestions?
If you happen to run ksh93, not ksh88, you can use that syntax which handle embedded spaces in file/directory names:
and here is a ksh88 way, still using an array and handling spaces: