Thursday, August 24, 2017

Linux shell script to find files and copy into another location

You can use following shell script to find files in directories and copy into another location.

#!/bin/bash
for k in `cat errlog_tmp.txt`; 
do 
arr=( $(find . -name "$k*" -type f));
echo $arr;( cp $arr "./error1$k"); 
done;

Above shell will cat file names in "errlog.txt" and find in the current directories. After successful file found, it is copied into "./error/" directory.

No comments:

Post a Comment