Tag Info

New answers tagged

1

Do you try the combination? grep -ho "18=[^,]*" list_of_files | sort | uniq -c


1

This is probably best done in Perl with a hash structure: perl -nle '($x)=/(18=[^,]+)/;$y{$x}++; END{print "$_ $y{$_}" for keys %y}' files Explanation For each line, Perl looks for 18= followed by as many non-comma characters as possible; whatever it finds, it stores in the variable $x. This variable is then used as a key to the hash %y, whose associated ...


2

This is controlled via MANPAGER. Manual pages defaults to the pager of less -is. You can just highlight the current selection: man -P "less -isg" <command> Or set the MANPAGER variable: export MANPAGER="less -isg" You could also use vim where the cursor is highlighted so the current selection will appear differently.: man -P "col -b | vim -c ...


1

Try to use this one: grep -r -E -o ".{0,10}wantedText.{0,10}" * -E tells, that you want to use extended regex -o tells, that you want to print only the match -r grep is looking for result recursively in the folder REGEX: {0,10} tells, how many arbitrary characters you want to print . represents an arbitrary character (a character itself wasn't ...


3

With GNU grep: N=10 grep -roP ".{0,$N}foo.{0,$N}" * Explanation: -o => Print only what you matched -P => Use Perl-style regular expressions The regex says match 0 to $N characters followed by foo followed by 0 to $N characters. If you don't have GNU grep: find . -type f -exec \ perl -nle ' BEGIN{$N=10} print if ...



Top 50 recent answers are included