From f578383b63efc7cab1571fae7660ec77e9fba89f Mon Sep 17 00:00:00 2001 From: coolneng Date: Thu, 29 Apr 2021 14:10:53 +0200 Subject: [PATCH] Add search by extension capabilities to copy-files --- copy-files.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/copy-files.sh b/copy-files.sh index 53e8d51..ec14587 100644 --- a/copy-files.sh +++ b/copy-files.sh @@ -1,8 +1,8 @@ #!/bin/sh usage() { - echo "Usage: copy-files.sh " - echo ": file that contains the files to copy, each on a different line" + echo "Usage: copy-files.sh " + echo ": directory where the files are located" echo ": directory where the files are copied to" exit 1 } @@ -11,9 +11,7 @@ if [ $# != 2 ]; then usage fi -filename=$1 +input=$1 output=$2 -while read -r p; do - cp "$p" "$output" -done <"$filename" +find "$input" -type f -iregex '.*\.\(pdf\|doc\|docx\|xlsx\|accdb|\mdb\)' -print0 | xargs -0 cp "{}" "$output"