grep limited characters - one line
You could use a combination of grep and cut
Using your example I would use:
grep -sRn 'wp-content' .|cut -c -40grep -sRn 'wp-content' .|cut -c -80
That would give you the first 40 or 80 characters respectively.
edit:
Also, theres a flag in grep, that you could use:
-m NUM, --max-count=NUM Stop reading a file after NUM matching lines.
This with a combination of what I previously wrote:
grep -sRnm 1 'wp-content' .|cut -c -40grep -sRnm 1 'wp-content' .|cut -c -80
That should give you the first time it appears per file, and only the first 40 or 80 chars.
If you change the regex to '^.*wp-content'
you can use egrep -o
. For example,
egrep -sRo '^.*wp-content' .
The -o
flag make egrep only print out the portion of the line that matches. So matching from the start of line to wp-content
should yield the sample output in your first code block.