I need help with a linux command with which I can search for a string in a text file and go to the first position this string is found and being able to scroll down and up from there. I am looking for hours for such command. GREP will only find the occurrences, print them and exit the file. I need to be able to jump to that line and being able to scroll up and down in order to see the other lines around.
You can do that with
vim, for example:
less +/pattern file.txt
vim +/pattern file.txt
This will open
file.txt for editing and jump to the first match of "pattern", if such exists. You can move up or down with the arrow keys or with
The pattern can be a basic regular expression (BRE) that
vim understand. For example:
less +/^settings file.txt
vim +/^settings file.txt
this will jump to the first line that starts with the string "settings".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!Donate Us With