2021年5月5日星期三

variable value is carried out of the loop in shellscript

I have following script to loop the files and assign the value to variabel and excepting the out of loop will carry the value but it is not as excepted can any one help to let me know the issue

#!/bin/sh export processingDirPath="/var/jenkins_ws/dev/DEV-Build_710/Database/Online/Programmability/Stored Procedures" export proc_list="" if [ -d "$processingDirPath" ]; then echo "before loop : $proc_list" find "$processingDirPath" -maxdepth 1 -type f -iname '*.sql' | while read fname; do proc_list="$proc_list,pavan" echo "Proc_list : $proc_list" done echo "out of loop : $proc_list" else ### Control will jump here if DIR does NOT exists ### echo "No files to process in the directory : ${processingDirPath} ."

    fi  

Result when I run the script ./simple.sh before loop : Proc_list : ,pavan Proc_list : ,pavan,pavan out of loop :

In out of loop i am excepting to have ,pavan,pavan

https://stackoverflow.com/questions/67410615/variable-value-is-carried-out-of-the-loop-in-shellscript May 06, 2021 at 09:06AM

没有评论:

发表评论