0

The following is perfect to find the Permission denied file/folder. Now need to add pipeline to the follows to exec sudo chmod o+rw. How to make it work? Thanks.

find . 2>&1 | sed 's/^[^:]*: .\(.*\).: Permission denied/\1/p;d'
Vadim Kotov
  • 7,766
  • 8
  • 46
  • 61
caot
  • 2,706
  • 30
  • 34
  • Why can't you just do `2>/dev/null` over the output of `find` instead of removing with `sed` – Inian Mar 22 '18 at 15:32
  • @Inian the result looks not right just do 2>/dev/null – caot Mar 22 '18 at 15:35
  • Can you show us a sample of how `find` output looks like – Inian Mar 22 '18 at 15:38
  • @Inian the line of code is from question at https://stackoverflow.com/questions/49431602/how-do-i-split-a-string-on-a-delimiter-in-bash/49432024#49432024 – caot Mar 22 '18 at 15:45
  • `find ... | sed ... | xargs chmod ...` or if *spaces* or other special characters `find ...|sed...|tr \\n \\0 | xargs -0 ...` – F. Hauri Mar 22 '18 at 18:21
  • @F.Hauri I know how to use xargs, however need to use sudo in the pipeline. – caot Mar 22 '18 at 18:23

0 Answers0