'different PDB files add hydrogen same time using reduce program in shell script with modified file name (1axk.pdb <---->1ackH.pdb)

I tried to run this code but its repeated the same file and ignored the other files and I want to stored all the directory files into a variable so that, read the file one by one and after addition of hydrogen by reduce program the file contain same file name with H addition and I want to save this output in separate directory how I can do this please help me I am new in this coding field. I tried to run this code but its repeated the same file and ignored the other files

#!/bin/bash
# A script for reduce program

l = cd ~/hetero
for l  in hetero/*.pdb 
do
    ls | xargs -L 1 -d '\n' reduce *.pdb > ....*H.pdb
done

echo "all done"


Solution 1:[1]

Your for-loop defines l as a variable whose value you obtain within the loop with the syntax $l. If you don't use $l inside your loop, you cannot expect loop iterations to depend on it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pommy