Results for “Files & paths”
Small, practical examples. Search by task or narrow things down below.
Inspect a file length without reading it
C#: Use FileInfo.Length to retrieve a logical size in bytes.
C#✓ Tested
Limit a search to the immediate directory
Linux Commands: Use maxdepth with type f to exclude nested files and directories.
Linux Commands✓ Tested
Make a script executable by its owner
Linux Commands: Add the owner execute bit without replacing all permission bits.
Linux Commands✓ Tested
Match filenames without case sensitivity
Linux Commands: Use iname for a case-insensitive filename pattern.
Linux Commands✓ Tested
Mount a host directory read-only
Expose existing files without allowing the container to change them.
bind mount✓ Tested
Move a file to a new filename
C#: File.Move changes the file path without loading its contents.
C#✓ Tested
Normalize a path without requiring it to exist
Linux Commands: Use GNU realpath -m and relative-to to normalize dot segments.
Linux Commands✓ Tested
Pass filenames with spaces through xargs
Linux Commands: Use null delimiters end to end instead of splitting filenames on whitespace.
Linux Commands✓ Tested
Process a file as a lazy line sequence
C#: ReadLines avoids allocating one string containing the entire file.
C#✓ Tested
Put an optional service behind a profile
Keep a utility service separate from a normal Compose startup.
Compose✓ Tested
Read a filename stem and extension
C#: Use Path helpers instead of splitting a path on dots or directory separators.
C#✓ Tested
Read the byte size of a regular file
C++: file_size reads filesystem metadata without loading file contents.
C++✓ Tested