On Sun, Aug 11, 2019 at 09:17:53AM -0400, Stephen P. Molnar wrote:
> I am running an up-to-date installation of Buster on my Linux
> platform and have run into a strange problem with a bash script.
> 
> I have a number of ligand protein docking applications which involve
> ligand sets docking on a protein and am using Autodock with the  the
> Racoon file editor (https://autodock.scripps.edu/).
> 
> I have written a bash script which runs each set of ligand dockings:
> 
> #!/bin/sh
> for d in $(cat ligand.list)
> do
>     cd "${d}_apo-3k9b"
>     echo "${d}apo-3k9b"
>     echo "${d}apo-3k9b.dpf"
>     /home/comp/Apps/Autodock/autodock4 -p "${d}apo-3k9b.dpf" -l
> "${d}apo-3k9b.dlg"
>    cd ..
> done
> 
> The script has run successfully for several sets of ligands, but now
> there is a problem:
> 
> comp@AbNormal:~/Apps/Models/1-PhosphorusLigands/Acetylcholinesterases/3K9B/Results$
> ./Run.ligand.list.sh
> ./Run.ligand.list.sh: line 3: cd: $'Acetylcholine\r_apo-3k9b': No
> such file or directory

> The problem is in the first 'cd' command in the do loop which is
> looking for 'Acetylcholine_apo-3k9b', but is finding
> 'Acetylcholine\r_apo-3k9b', and consequently, does not change in to
> the directory 'Acetylcholine_apo-3k9b'!
> 
> The only difference from the script that ran the previous successful
> dockings, the '\r', is that I edited the script for the current use
> by changing the name of the protein, in this case 'apo-3k9b'.  I
> used Jedit to edit the script and have no idea as to the source of
> the '\r' as Jedit is using the Unix(\n) line separator.

Given your description, it's difficult to "see" where this \r (let's
assume that it is in fact what it seems) is coming from: either it
is, in fact, embedded in your script, then it has been cleaned up
by your mail program, or it is in your file "ligand.list", right
at the end of the line (I'd vote for the last).

Try substituting your cat with sed -e 's/\r$//', like so:

  #!/bin/sh
  for d in $(sed -e 's/\r$//' ligand.list)
  do
    ....

Cheers
-- tomás

Attachment: signature.asc
Description: Digital signature

Reply via email to