0

I am trying to find the list of all git repositories on my local machine. I do get all of them but I also get some repositories which have Permission denied in the output

find . -name .git -type d -prune | sed '/Permission/d'

The output of the command is

find: ./.Trash/Fuze_old.app/Contents/Frameworks/Fuze Helper.app: Permission denied
./.nvm/.git
./.oh-my-zsh/.git
./.Trash/AutoLayout/.git
./.Trash/DemoProject/.git
find: ./Library/Python: Permission denied
./.Trash/NavView/.git
./.Trash/Something/.git
./.zsh/zsh-autosuggestions/.git

I do not want the lines with Permission denied.

How do I get that?

2

1 Answer 1

4

The "permission denied" lines are likely on STDERR instead of STDOUT, which is why your sed command is ineffective. Try this (if you're on a Unix-like system):

find . -name .git -type d -prune 2>/dev/null
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.