Select files without parsing ls
#find walks a tree. -exec passes each pathname as an argument without splitting it on whitespace.
Fragment
Do not feed arbitrary newline-delimited filenames to unquoted command substitution.
Reference
Read commands, quoting, streams, paths and scripts.
POSIX sh (2017 baseline), Bash additions and named Unix tools. Examples are independent fragments; file paths are illustrative. Bash-only syntax is labeled. macOS and Linux utility flags can differ.
POSIX sh docs find utility ↗POSIX utilities index ↗
find walks a tree. -exec passes each pathname as an argument without splitting it on whitespace.
Fragment
Do not feed arbitrary newline-delimited filenames to unquoted command substitution.
ripgrep is a separately installed tool. -F searches literal text, -n shows line numbers, -g filters paths, and --files lists searched files.
Fragment
By default rg filters ignored, hidden and binary files. Exit 1 means no match; 2 means an error. No match in this set does not establish absence everywhere.
head and tail select ends of a file; sed -n selects a line range; wc counts. These operate on text, not structured JSON.
Fragment
mkdir -p creates missing parent directories. cp copies; mv moves or renames. Existing destinations can be overwritten according to each utility’s rules.
Fragment
Use a disposable workspace when learning file operations; inspect the destination first.
r/w/x mean read/write/execute for files. On directories, x allows traversal and w controls entry changes subject to other rules. chmod u+x adds owner execute permission.
Fragment
Permissions and ownership are separate. umask masks initial permission bits; existing files do not change.
rm removes a directory entry; rmdir removes an empty directory. Neither operation normally goes through a desktop trash folder. -r recursively descends and -f suppresses prompts/some missing-file errors.
Fragment
Inspect the exact operands before deleting. Removing a name does not guarantee secure erasure of underlying data.
grep selects matching lines; cut selects delimited fields; sed can select or replace text; awk provides record/field processing. Each tool has its own regex and escaping rules.
Fragment
cut is not a CSV parser: quoted delimiters and embedded newlines need a CSV-aware tool.
mktemp creates a uniquely named temporary file/directory. It is common on Linux/macOS, but not part of the POSIX.1-2017 utility baseline.
Fragment
Use cleanup that only removes the path you created. GNU/BSD mktemp flags differ beyond common template forms.