I want to apply a link to a specific file automatically with a Linux bash script. A part of the target pathname is shall be taken from a txt file. This is my program:
bandA="B01"
while IFS= read -r bandB || [ -n "$p" ]
do
printf '%s\n' $bandA #from header
printf '%s\n' $bandB #from list.txt
ln -sfn /bst.$bandA.cfg /bst.cfg
done < LIST.txt
The first line of LIST.txt is "B01", too. (without quotation marks)
The command line returns always
B01 B01
The problem occurs at the ln command. When I apply $bandA the link is created successfully. When I apply $bandB from the IFS=read the link is not created. Although the variable is obviously written correctly. It must be an issue with the syntax. How can I solve the issue?
The problem was caused because some symbols were added during read process:
By deleting them with
the link can be created.