How do I improve this function efficiency so that it only searches once instead of three times:

# Fixes permissions for files and directories in the given folder or the current folder
fixperms() {
  find "${1:-.}" -type f -executable -exec chmod 744 {} \;
  find "${1:-.}" -type f ! -executable -exec chmod 644 {} \;
  find "${1:-.}" -type d -exec chmod 755 {} \;
}
@thann
mod
admin
link
fedilink
1
edit-2
4M

IDK exactly what you’re trying to do, but you can use chmod -r ugo+rw to add read+write permissions for everyone for all files in a folder recursively.

@ajr@lemmy.ml
creator
link
fedilink
24M

Sometimes when you copy a directory the folder permissions get messed up. I’m trying to make a function to fix the permissions so the files and folders don’t allow writing or executing to anyone other than yourself.

Ask specific questions about how to code something in sh, bash, zsh, etc

General bash discussion on lemmy.ml

Create Post From:
lemmy.ml

  • 0 users online
  • 2 users / day
  • 2 users / week
  • 2 users / month
  • 5 users / 6 months
  • 17 subscribers
  • 9 Posts
  • 17 Comments
  • Modlog