2

Refering to this question, I want something a little bit similar. The idea is that I execute a command, then it asks for a file name to process, and after it is done with processing, it asks for the next filename and so on. The problem that I have thousands of files, so I cannot enter them manually one by one. However, I have a .txt file containing all the filenames.

So I wanted to write a bash script which:

  1. execute the command
  2. when it asks about a filename, it reads the first line from the txt file
  3. the program will process the file, then asks for the next
  4. the bash gives the next and so on

until the program asks for a file, and already the .txt file is done, then I terminate automatically

PerlDuck
  • 13,335

1 Answers1

1

Whenever one speaks of "thousands of files", I immediately think of xargs (read man xargs). Assuming your filenames are simple (not containing blanks or other funny characters):

xargs --interactive -n 1 <filenames.txt YourProgram
waltinator
  • 36,399