1

I have binary files in a directory containing timespec time stamps in following format:

timeStamps_from_callId_1
timeStamps_from_callId_2
timeStamps_from_callId_3
timeStamps_from_callId_4
timeStamps_from_callId_5
......

and I have a program called timing_reader in the same directory which has following format:

Usage: ./timing_reader <timing-file> [output file]

Now I want to automate the processing of these files through Bash scripting in such a way that each output file will be named as exactly the input file with .csv extension. For example:

./timing_reader timeStamps_from_callId_1 timeStamps_from_callId_1.csv

and

./timing_reader timeStamps_from_callId_2 timeStamps_from_callId_2.csv

and so on. I am a very basic user of Bash and have no experience of scripting whatsoever. Any sort of help is highly appreciated.

Black_Zero
  • 445
  • 1
  • 6
  • 12

1 Answers1

2

Maybe, for loop?:

for i in timeStamps_from_callId_*;
do
   ./timing_reader ${i} ${i}.csv
done

Or, awk?:

ls timeStamps_from_callId_* | awk '{printf "./timing_reader %s %s.csv",$0,$0}' | sh -
Nehal J Wani
  • 16,071
  • 3
  • 64
  • 89
  • The for loop did the job although I had to include a sleep statement to let the processing of first file finish before starting the next one. Thanks for the help. – Black_Zero Aug 15 '16 at 09:38