0

I have these directories after "ls":

08-21-resume-numrelblocks3-nqh2-numblocks2-stackonlyFalse-dockimgnegativereward-gpfg-uniformxy
08-22-32-nqh2-alpha-stack1-stack2-numrelblocks3-nqh2-dockimgnegativereward-gpfg-uniformxy-epsgreedyprobaction0.1-stackonlyFalse-SNA-Truemultihead-nonlinearitybeforeattn
08-22-6-12-alpha-stack11-stack12-numrelblocks3-nqh1-dockimgnegativereward-gpfg-multitower4-epsgreedyprobaction0.1-stackonlyTrue-GAT-Truemultihead-nonlinearitybeforeattn
08-22-alpha-stack5-stack6-numrelblocks3-nqh1-dockimgnegativereward-gpfg-multitower3-epsgreedyprobaction0.1-stackonlyTrue-GAT-Truemultihead-nonlinearitybeforeattn
08-23-alpha-stack6-stack9-numrelblocks3-nqh1-dockimgnegativereward-gpfg-multitower3-epsgreedyprobaction0.1-stackonlyTrue-SNA-Truemultihead
08-23-lstmcell-alpha-stack1-numrelblocks1-nqh1-dockimgnegativereward-gpfg-uniformxy-SpatialNeighborhoodAttention-Truemultihead-Falsestackonly-praFalse-qcmFalse

I need to feed directories that are on date 08-22 into my program execute.py. E.g.

python execute.py 08-22-32-nqh2-alpha-stack1-stack2-numrelblocks3-nqh2-dockimgnegativereward-gpfg-uniformxy-epsgreedyprobaction0.1-stackonlyFalse-SNA-Truemultihead-nonlinearitybeforeattn 08-22-6-12-alpha-stack11-stack12-numrelblocks3-nqh1-dockimgnegativereward-gpfg-multitower4-epsgreedyprobaction0.1-stackonlyTrue-GAT-Truemultihead-nonlinearitybeforeattn 08-22-alpha-stack5-stack6-numrelblocks3-nqh1-dockimgnegativereward-gpfg-multitower3-epsgreedyprobaction0.1-stackonlyTrue-GAT-Truemultihead-nonlinearitybeforeattn

How do I do so without laboriously copy and pasting each line individually...

  • 2
    Have you tried "execute.py $(ls 8-22-)" and using sys.argv ? Or "echo 8-22- | execute.py" and reading the filenames? How about using the glob package? – stolenmoment Aug 24 at 1:09
  • Do you need anything more complicated than for f in 08-22-*; do python execute.py "$f"; done ? (Since you tagged your question Ubuntu I'm assuming you are using the default bash shell - or a compatible Bourne-like shell) – steeldriver Aug 24 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.