Я набрал длинную команду в BASH, но, как только я набрал команду, я вижу, что неправильно набрал команду или аргумент. Я хочу, чтобы курсор перешел к аргументу или команде, которые я написал с ошибкой, используя поиск по месту, вместо нажатия клавиш со стрелками для перехода к конкретной команде или аргументу.
например.
ls *.txt | grep -e 'foo' >> list_of_text_files_containing_foo.txt
и я хочу изменить foo
в grep на bar
, найдя и заменив foo
на bar
внутри команды, не нажимая клавиши со стрелками. Есть ли способ изменить все вхождения от foo
до bar
.
Вам, вероятно, интересно об ударе быстрая замена в последней команде:
!!:gs/old/new
Пример:
$ ls *.txt | grep -e 'foo' >> list_of_text_files_containing_foo.txt
$ !!:gs/foo/bar
ls *.txt | grep -e 'bar' >> list_of_text_files_containing_bar.txt
Для большего количества информации о замене удара, читайте man bash
запуск с где-нибудь от строки 3630.
Я не думаю, что можно сделать оперативный поиск, но вместо этого изучить сочетания клавиш для контакта с Bash.
Ctrl + L Clear the Screen, similar to the clear command
Ctrl + u Cut/delete the line before the cursor position.
Alt + Del Delete the Word before the cursor.
Alt + d Delete the Word after the cursor.
Ctrl + d Delete character under the cursor
Ctrl + h Delete character before the cursor (Backspace)
Ctrl + w Cut the Word before the cursor to the clipboard.
Ctrl + k Cut the Line after the cursor to the clipboard.
Alt + t Swap current word with previous
Ctrl + t Swap the last two characters before the cursor (typo).
Esc + t Swap the last two words before the cursor.
ctrl + y Paste the last thing to be cut (yank)
Alt + u UPPER capitalize every character from the cursor to the end of the current word.
Alt + l Lower the case of every character from the cursor to the end of the current word.
Alt + c Capitalize the character under the cursor and move to the end of the word.
Alt + r Cancel the changes and put back the line as it was in the history (revert).
ctrl + _ Undo
Ссылка: Ссылка