I wrote shell script in AIX 7.1 and it's not executed in a proper order.
The shell script is
receive 2 parameter $param and $filename
listoffiles='ls ${param}/*.txt'
awk 'FNR-1' ${listoffiles} >> ${param}/${filename}
mv ${param}/*.txt ${param}/archive
My objective is to combine lines in ${listoffiles} to one file, excluding the header of each file.
Afterwards, I'd like to move the ${listoffiles} files, including resulting ${param}/${filename} to a folder (let's say it's "archive" folder). ${filename} should refer to parameter and will give file unique name per execution call and will always have ".txt" extension.
The problem is: if there are 3 (or more) script execution in the same time, the result will be:
- One execution will result in a proper order 
- Other execution will result in - mv ${param}/*.txt ${param}/archiveto be executed first before- awk 'FNR-1' ${listoffiles} >> ${param}/${filename}
What am I doing wrong here? Or is there any way to guarantee for script to strict with it's execution step? (I've tried adding && or ; but the result stays the same)
 
     
     
    