I have a large number of scripts that can be run as separate jobs on a computing cluster, which uses slurm. I want to select some of them, based on the contents, to submit. It's easy to identify the filenames of the jobs I want using grep, but I'm struggling to pipe those and submit them.I thought that I could do something like this:grep -l 'regex' script_folder/* | xargs sbatchHowever, this appears to submit the all the scripts as one job, when I want each script to be its own separate job.
Submitting list of jobs to slurm
xargs;cluster;slurm
grep -l 'pattern' script_folder/* | xargs -n 1 sbatchxargs will by default read as much as can fit on one command line before executing the given utility with all the things that it has read.With -n 1 you limit the number of items that it passes to the utility to a single item per invocation.