Hi everyone,
I am fairly new to shell scripting. I want to read in numbers from a file (one number per line). This works perfectly fine
while read CurrentLine
do
echo $CurrentLine
done < myfile
and yields the correct output:
272
745
123
If I however run a ffmpeg command in the loop
while read CurrentLine
do
echo $CurrentLine
ffmpeg -sameq -vframes 1 -ss 2 -i PMI_thin_02.avi -f image2 a_b.png
done < myfile
the output changes (I ommit the ffmpeg output and just give the echo command output):
272
5
3
If I add two spaces in the txt-file I read in, such as
272
745
123
the echo command returns the right numbers again - for some reason, the ffmpeg commands seems to result in the skipping of the first two characters in the new line.
If I put an additional for-loop around the while loop to loop over several files such as in
for FileName in *.txt; do
while read CurrentLine
do
echo $CurrentLine
ffmpeg -sameq -vframes 1 -ss 2 -i PMI_thin_02.avi -f image2 a_b.png
done < "${FileName}"
The first line of every file is read in correctly, but for all subsequent lines, the first two characters are skipped. Does anybody have any idea what is going on? I am very grateful for any hint.
Best,
Thriceguy