Ok ... a few things:
1. Please place data/code inside [code][/code] tags to make it more legible
2. Your use of wildcards is not going to workout so well, for example:
Code:
if [ -d ~/directory/*${tid}* ]; then
Now I will assume that 'tid' is being successfully set elsewhere in your code. This line says are there any directories below the path ~/directory that contain 'tid'.
This is quite different from saying is there a single directory in the path that exists and contains 'tid'
3. Just as there may be multiple directories tested, the cd may also get confused if there are multiple directories to change to
Now we get to the section causing your error:
4. The while loop has nothing feeding it so it would be waiting for user input on standard in (in your case the keyboard). Assuming you hit the enter key without typing anything, this would then fill the
'line' variable with nothing, hence your cp command would look like :- cp ~/test_dir/
As you can see this is an incomplete copy command and hence your error
The resolution is that you need to feed the file names to the while command. To have the output of a command sent to while it needs to be of the form:
Code:
while ...
do
...
done< <(your command here)
Please note there is a space between the 2 < symbols