
私はcarlist.txtを検索していくつかの項目を取り出しました。これは私にパイプでつながるとgrep -e Peugeot -e PeuGeot carlist.txt
思いましたが、これは私が得たものです:grep -e Peugeot -e PeuGeot carlist.txt | vi
Vim: Warning: Input is not from a terminal
Vim: Error reading input, exiting...
Vim: preserving files...
Vim: Finished.
答え1
"-"を引数としてviまたはvimを実行すると、標準入力から編集したいファイルが読み込まれます。したがって:
grep -e Peugeot -e PeuGeot carlist.txt | vi -
必要なことをします。
答え2
これに加えて、vim -
次の構文を使用してプロセス置換を使用できます。<(command)
例:
vim <(echo This is example.)
vim <(cat /etc/hosts)
また見なさい:
答え3
使用する必要があります出力リダイレクト:
grep ... > newfile.txt && vi newfile.txt
また、お客様のサービスもgrep
改善される可能性があると思います。
grep 'Peu[gG]eot' carlist.txt > newfile.txt && vi newfile.txt
答え4
存在する~/bin/r
:
#!/bin/sh
[ $# -eq 0 ] && set -- -;
exec vi -R "$@"
存在する~/.vimrc
:
: au StdinReadPost * set buftype=nofile
それから:
ls |r
grep -e Peugeot -e PeuGeot carlist.txt | r
私は持っています
r- () { "$@" | r; }
私~/.bashrc,
の場合
r- ls -l