linux - Save Bash Shell Script Output To a File with a String -


i have executable takes file , outputs line. running loop on directory:

for file in $directory/*.png         ./eval $file >> out.txt done 

the output of executable not contain name of file. want append file name each output.

edit1

perhaps, not explain correctly want name of file , output of program well, processing same file, doing following

for file in $directory/*.png          echo -n $file >> out.txt      or      printf "%s" "$file" >> out.txt      ./eval $file >> out.txt done 

for both new line inserted

if understood question, want is:

  • get name of file,
  • ...and output or program processing file (in case, eval),
  • ...on same line. , last part problem.

then i'd suggest composing single line of text (using echo), comprising:

  • the name of file, $file part,
  • ...followed separator, may not need may further processing of result. used ":". can skip part if not interesting you,
  • ...followed output of program processing file: $(...) construct

    echo $file ":" $(./eval $file) >> out.txt

...and appending line of text file, got part right.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -