I am on Ubuntu 14.04. Lets say there are a few executables.
ATest, BTest, CTest, random1, random2
I want to execute everything that ends with "Test", but I do not know beforehand exactly how many executable fits this criteria
./*Test
only ends up executing the ATest
but something like
ls *Test
works perfectly showing only the files ending with Test.
What is the correct shell command to execute multiple executables with a pattern without knowing how much files matches this pattern?
You can use a short script to accomplish this:
#!/bin/bash
for f in *Test
do
"./$f"
done
Or, even as a one-liner:
for f in *Test; do "./$f"; done
find . -name \*Test -exec ./{} \;
EDIT: This will also search all subdirectories. To only search current directory:
find . -maxdepth 1 -name \*Test -exec ./{} \;