files

one-liners (mostly) to manage files

create subdirectory for each file

for file in *; do [ -f "$file" ] && mkdir -p "${file%.*}" && mv "$file" "${file%.*}/"; done

merge files and add filename to text

find . -maxdepth 1 -type f -name "*en.srt" -exec sh -c 'echo "=== {} ==="; cat "{}"' \; > combined_files.txt

find and delete

find . -type f -path '*4.3*/*' -name '*.yml' -exec rm {} -i \;

(-i interactive)

find files (.pl.) and count words

find ./ -type f -name "*.pl.*" -exec wc -w {} +

find the newest file recursively

find $1 -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- | head

(supports filenames with spaces). Performance improved with xargs:

find image files in directory

or simply by extension (-iname for case insensitive seach)

windows gitbash version:

or just all contents of images/ dirs

find images in html files:

find images in markdown files:

count files in subdirectories

mindepth and maxdepth to only check immediate descendants. add -name e.g "*.md" etc to only count certain filetype

batch rename files

Last updated