For loop in bash using ls to get array of file names
So I have a group of files of the form:
cluster_1 cluster_2 cluster_3 etc CLUSTERS="ls cluster_*" for zzCLUSTER in $CLUSTERS do cat "${zzCLUSTERS}" | tr '/' ' ' | uniq | cat > "${zzCLUSTERS}".reads done but for some reason this isent working? I've looked at like 50 examples and I can't seem to get it to work. It says that I can't redirect |
Correction, this is the code I have essentially
clusterlist="ls cluster_*" for zzCLUSTERS in "$clusterlist" do cat "${zzCLUSTERS}" | tr '/' ' '| cat > "${zzCLUSTERS}".reads done the error I'm getting is cat: ls cluster_*: No such file or directory |
You can use:
for zzCLUSTER in cluster_*; do ... done instead of CLUSTERS=$(ls cluster_*) You used double quotes instead of backticks or the $(...) form. |
Thank you thank you thank you!
So what is the difference between " " , ' ' , and ` ` in bash? When should each be used? |
Code:
schneidz@lq /sp> ls temp |
You can use:
for zzCLUSTER in cluster_*; do ... done instead of CLUSTERS=$(ls cluster_*) You used double quotes instead of backticks or the $(...) form. |
All times are GMT -5. The time now is 04:39 PM. |