Search code examples
shellunixvimvimdiff

While loop breaks in bash script if i call Vimdiff within loop


I am trying to use vimdiff of two files within while loop. But it breaks after 1st loop.

while read line
do
vimdiff -c TOhtml -c wqa! $line"_file1" $line"_file2"
done < inpFile.txt

Though inpFile contains multiple entries, the above loop breaks after 1st loop. I suspect if its because of subprocess. May i know how to get it running for all entries in file.


Solution

  • Redirect so that vimdiff doesn't eat the input intended for the loop:

    while read line
    do
        vimdiff -c TOhtml -c wqa! $line"_file1" $line"_file2"  < /dev/null
    done < inpFile.txt