в vi:
vi +X filename
в EMACS:
emacs +X filename
в оболочке:
nl -ba -nln filename| grep '^X '
вы можете использовать контекстgrep cgrep вместо grep
, чтобы увидеть некоторые строки выше и ниже совпадающей строки ..
ПРИМЕРЫ:
вывести только эту строку:
$ nl -ba -nln active_record.rb | grep '^111 '
111 module ConnectionAdapters
с контекстом:
$ nl -ba -nln active_record.rb | grep -C 2 '^111 '
109 end
110
111 module ConnectionAdapters
112 extend ActiveSupport::Autoload
113
для управления контекстом в grep
check man grep
:
Context Line Control
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.
-B NUM, --before-context=NUM
Print NUM lines of leading context before matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.
-C NUM, -NUM, --context=NUM
Print NUM lines of output context. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given.