JohnBash
JohnBash

Reputation: 13

Bash Script to execute linux file

As shown in the image below, I have a Linux executable and it can be run using this command:

./bomb filename0.txt

I need a bash script to run this continuously as I have various files that I want to run the executables with as shown in the picture such as filename0, filename1, filename and so on.

enter image description here

How could I automate the execution of my script with all these files as argument?

Upvotes: 1

Views: 460

Answers (2)

aydow
aydow

Reputation: 3801

Use bash. This script will execute bomb on every file in your directory

for file in /path/to/dir/*.txt
do
  path/to/bomb "$file" >> results.out
done

Example

[20:37:04] ado@crystal
± >  touch a b c

[16:47:26] ado@crystal
± >  ls
a b c

[16:47:27] ado@crystal
± >  for i in *; do echo "this is $i"; done
this is a
this is b
this is c

Upvotes: 1

codegrep_admin
codegrep_admin

Reputation: 529

for i in `seq 0 10`
do
 ./bomb filename$i.txt
done

The above code will run from filename0 to filename10

Upvotes: 0

Related Questions