New answers tagged

0

The author of the question provided the following solution, which is apparently derived from the answer on SO. I found the solution in stackoverflow find folder \( -name 'foo*' -or -name 'bar' -or -name 'dummy*' \) -exec rm -r {} \;


0

One command that solves this is: rsync --dry-run --verbose --recursive --relative --prune-empty-dirs --include="**/" --include="*.tpl" --exclude="*" /source /dest/ --relative: Recreate all parent folders. --include="**/": The ** part allows recursion for folders (/). --include="*.tpl": The pattern. --exclude=...


0

Use this recursive function to list total files in a directory recursively, up to a certain depth (it counts files and directories from all depths, but show print total count up to the max_depth): #!/bin/bash # set -x export max_depth="2" export found_files="/tmp/found_files.txt" function get_all_the_files() { depth="$1"; ...


0

A for loop is a less verbose: $ shopt -s globstar nullglob dotglob $ for i in **/*.{sql,conf,py,csv}; do cp "$i" "scan/$(basename "$i")" done


Top 50 recent answers are included