obda.net

Convert Filenames Recursively to Lower Case

Add a comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

Use zmv to recursively convert the names of all files and (sub-) directories within the current directory to lower case:

autoload zmv
zmv '(**/)(*)' '$1${2:l}'

If you want to convert to upper case instead of lower case, use :u instead of :l.

Default File Permissions for a Directory

Add a comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

You can set the default permissions for all files created in a given directory using POSIX access control lists (ACLs). For example, after executing

user@host:~$ setfacl -d -m u::rwx,g::rwx,o::r-x ~/path/to/example/dir

all new files (and directories, too) in ~/path/to/example/dir will have group write permission enabled. To check the currently effective ACLs, use getfacl.

Redirect STDIN in a Shell Script

1 comment

cheat-sheet articles are about code snippets that I need every once in a while, and which I constantly forget about.

If you have a shell script, and want to redirect all input it receives via STDIN to another script or program, use <&0:

#!/bin/zsh
/path/to/another/script.pl --script-args <&0