Skip to main content
added 63 characters in body
Source Link

Noob here - I want to run grep -r asdf however, I only want unique matches in my directories (i.e. disregarding any directory, display unique matches only).

So I ran grep -r asdf | sort --unique. However - this does not work since the directory names are different (dir1/a.txt asdf and dir2/a.txt asdf).

I didn't see an option (I tried e.g. grep -riol) to exclude directories and I guess that barely makes sense for the scope of the function. Can I somehow cut-away the directories and only show the matched filename + match (possibly without a mind/universe-bending regex/sed/...)?

Noob here - I want to run grep -r asdf however, I only want unique matches in my directories.

So I ran grep -r asdf | sort --unique. However - this does not work since the directory names are different (dir1/a.txt asdf and dir2/a.txt asdf).

I didn't see an option (I tried e.g. grep -riol) to exclude directories and I guess that barely makes sense for the scope of the function. Can I somehow cut-away the directories and only show the matched filename + match (possibly without a mind/universe-bending regex/sed/...)?

Noob here - I want to run grep -r asdf however, I only want unique matches in my directories (i.e. disregarding any directory, display unique matches only).

So I ran grep -r asdf | sort --unique. However - this does not work since the directory names are different (dir1/a.txt asdf and dir2/a.txt asdf).

I didn't see an option (I tried e.g. grep -riol) to exclude directories and I guess that barely makes sense for the scope of the function. Can I somehow cut-away the directories and only show the matched filename + match (possibly without a mind/universe-bending regex/sed/...)?

Source Link

grep -r (recursive), remove/hide all directories

Noob here - I want to run grep -r asdf however, I only want unique matches in my directories.

So I ran grep -r asdf | sort --unique. However - this does not work since the directory names are different (dir1/a.txt asdf and dir2/a.txt asdf).

I didn't see an option (I tried e.g. grep -riol) to exclude directories and I guess that barely makes sense for the scope of the function. Can I somehow cut-away the directories and only show the matched filename + match (possibly without a mind/universe-bending regex/sed/...)?