how to use vim to open every .txt file under a directory (with Bash)
bash, vim, while-loop
Solution
Try:
vim $( find . -name "*.txt" )
To fix your solution, you can (probably) do:
find . -name "*.txt" -print | while read aline; do
read -p "start spellchecking fine: $aline" sth < /dev/tty
vim $aline < /dev/tty
done
The problem is that the entire while loop is taking its input from find, and vim inherits that pipe as its stdin. This is one technique for getting vim's input to come from your terminal. (Not all systems support `/dev/tty`, though.)
Problem
I am trying the following to use a `vim` to open every `txt` file under current directory. ``` find . -name "*.txt" -print | while read aline; do read -p "start spellchecking fine: $aline" sth vim $aline done ``` Running it in `bash` complains with ``` Vim: Warning: Input is not from a terminal Vim: Error reading input, exiting... Vim: Finished. ``` Can anyone explain what could possibly goes wrong? Also, I intend to use `read -p` for prompt before using vim, without no success.