From 09b51e2e2c8c4fe1ea3d79d3f9d98e46644bed29 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 18:18:01 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E4=BB=BB=E5=8A=A1=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 添加bot远程地址 2. 增加文件后缀配置 3. 增加定时任务页数缓存 --- back/api/cron.ts | 21 +++++++++++++++++++++ back/services/cron.ts | 10 ++++++++-- sample/config.sample.sh | 3 +++ shell/api.sh | 26 ++++++++++++++++++++++++++ shell/bot.sh | 8 ++++++++ shell/share.sh | 1 + shell/task.sh | 4 ++++ shell/update.sh | 9 +++++++-- src/pages/crontab/index.tsx | 24 ++++++++++++++++++------ 9 files changed, 96 insertions(+), 10 deletions(-) diff --git a/back/api/cron.ts b/back/api/cron.ts index ee3f6e4e..63436808 100644 --- a/back/api/cron.ts +++ b/back/api/cron.ts @@ -225,4 +225,25 @@ export default (app: Router) => { } }, ); + + route.put( + '/crons/status', + celebrate({ + body: Joi.object({ + ids: Joi.array().items(Joi.string().required()), + status: Joi.string().required(), + }), + }), + async (req: Request, res: Response, next: NextFunction) => { + const logger: Logger = Container.get('logger'); + try { + const cronService = Container.get(CronService); + const data = await cronService.status(req.body); + return res.send({ code: 200, data }); + } catch (e) { + logger.error('🔥 error: %o', e); + return next(e); + } + }, + ); }; diff --git a/back/services/cron.ts b/back/services/cron.ts index c5c718ec..88f94032 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -83,8 +83,14 @@ export default class CronService { }); } - public async status(_id: string, stopped: boolean) { - this.cronDb.update({ _id }, { $set: { stopped, saved: false } }); + public async status({ + ids, + status, + }: { + ids: string[]; + status: CrontabStatus; + }) { + this.cronDb.update({ _id: { $in: ids } }, { $set: { status } }); } public async remove(ids: string[]) { diff --git a/sample/config.sample.sh b/sample/config.sample.sh index 44efdf7b..924ed3d2 100644 --- a/sample/config.sample.sh +++ b/sample/config.sample.sh @@ -10,6 +10,9 @@ AutoDelCron="true" ## 在运行 ql repo 命令时,是否自动增加新的本地定时任务 AutoAddCron="true" +## ql repo命令拉取脚本时需要拉取的文件后缀,直接写文件后缀名即可 +RepoFileExtensions="js py" + ## 由于github仓库拉取较慢,所以会默认添加代理前缀,如不需要请移除 GithubProxyUrl="https://ghproxy.com/" diff --git a/shell/api.sh b/shell/api.sh index 2e3b7d81..b5bec373 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -147,3 +147,29 @@ get_user_info() { exit 0 fi } + +update_cron_status() { + local ids=$1 + local status=$2 + local currentTimeStamp=$(date +%s) + local api=$( + curl -s "http://localhost:5700/api/crons/status?t=$currentTimeStamp" \ + -X 'PUT' \ + -H "Accept: application/json" \ + -H "Authorization: Bearer $token" \ + -H "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36" \ + -H "Content-Type: application/json;charset=UTF-8" \ + -H "Origin: http://localhost:5700" \ + -H "Referer: http://localhost:5700/crontab" \ + -H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \ + --data-raw "{\"ids\":\"[$ids]\",\"status\":\"$status\"}" \ + --compressed + ) + code=$(echo $api | jq -r .code) + message=$(echo $api | jq -r .message) + if [[ $code == 200 ]]; then + echo -e "成功" + else + echo -e "失败(${message})" + fi +} diff --git a/shell/bot.sh b/shell/bot.sh index e047721f..c6b71d05 100644 --- a/shell/bot.sh +++ b/shell/bot.sh @@ -3,6 +3,7 @@ ## 导入通用变量与函数 dir_shell=/ql/shell . $dir_shell/share.sh +url="${github_proxy_url}https://github.com/SuMaiKaDe/bot.git" repo_path="${dir_repo}/dockerbot" echo -e "\n1、安装bot依赖...\n" @@ -10,6 +11,13 @@ apk --no-cache add -f zlib-dev gcc jpeg-dev python3-dev musl-dev freetype-dev echo -e "\nbot依赖安装成功...\n" echo -e "2、下载bot所需文件...\n" +if [ -d ${repo_path}/.git ]; then + git_pull_scripts ${repo_path} +else + rm -rf ${repo_path} + git_clone_scripts ${url} ${repo_path} "main" +fi + cp -rf "$repo_path/jbot" $dir_root if [[ ! -f "$dir_root/config/bot.json" ]]; then cp -f "$repo_path/config/bot.json" "$dir_root/config" diff --git a/shell/share.sh b/shell/share.sh index 464be17f..e4d9e0f2 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -62,6 +62,7 @@ import_config() { command_timeout_time=${CommandTimeoutTime:-"1h"} github_proxy_url=${GithubProxyUrl:-""} block_cookie=${TempBlockCookie:-""} + file_extensions=${RepoFileExtensions:-"js py"} } ## 创建目录,$1:目录的绝对路径 diff --git a/shell/task.sh b/shell/task.sh index b6208786..35e3ae6c 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -120,6 +120,10 @@ run_normal() { log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" make_dir "$log_dir" + + local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1$" | perl -pe "s|.*ID=(.*) $cmd_task $p1$|\1|" | xargs | sed 's/ /","/g') + local status="0" ## 0 任务运行中 + update_cron_status "\"$id\"" $status timeout $command_timeout_time $which_program $p1 2>&1 | tee $log_path } diff --git a/shell/update.sh b/shell/update.sh index bc5cb976..21fac8b9 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -357,7 +357,12 @@ gen_list_repo() { rm -f $dir_list_tmp/${repo}*.list >/dev/null 2>&1 cd ${repo_path} - files=$(find . -name "*.js" | sed 's/^..//') + + local cmd="find ." + for extension in $file_extensions; do + cmd="${cmd} -o -name \"*.${extension}\"" + done + files=$($cmd | sed 's/^..//') if [[ $path ]]; then files=$(echo "$files" | egrep $path) fi @@ -365,7 +370,7 @@ gen_list_repo() { files=$(echo "$files" | egrep -v $blackword) fi if [[ $dependence ]]; then - find . -name "*.js" | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts + $cmd | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts fi for file in ${files}; do filename=$(basename $file) diff --git a/src/pages/crontab/index.tsx b/src/pages/crontab/index.tsx index 8d57ae2f..18da79dc 100644 --- a/src/pages/crontab/index.tsx +++ b/src/pages/crontab/index.tsx @@ -187,6 +187,8 @@ const Crontab = () => { const [isLogModalVisible, setIsLogModalVisible] = useState(false); const [logCron, setLogCron] = useState(); const [selectedRowIds, setSelectedRowIds] = useState([]); + const [currentPage, setCurrentPage] = useState(1); + const [pageSize, setPageSize] = useState(20); const getCrons = () => { setLoading(true); @@ -233,7 +235,7 @@ const Crontab = () => { if (data.code === 200) { message.success('删除成功'); const result = [...value]; - result.splice(index, 1); + result.splice(index + pageSize * (currentPage - 1), 1); setValue(result); } else { message.error(data); @@ -264,7 +266,7 @@ const Crontab = () => { .then((data: any) => { if (data.code === 200) { const result = [...value]; - result.splice(index, 1, { + result.splice(index + pageSize * (currentPage - 1), 1, { ...record, status: CrontabStatus.running, }); @@ -298,7 +300,7 @@ const Crontab = () => { .then((data: any) => { if (data.code === 200) { const result = [...value]; - result.splice(index, 1, { + result.splice(index + pageSize * (currentPage - 1), 1, { ...record, pid: null, status: CrontabStatus.idle, @@ -342,7 +344,7 @@ const Crontab = () => { if (data.code === 200) { const newStatus = record.isDisabled === 1 ? 0 : 1; const result = [...value]; - result.splice(index, 1, { + result.splice(index + pageSize * (currentPage - 1), 1, { ...record, isDisabled: newStatus, }); @@ -429,7 +431,7 @@ const Crontab = () => { if (index === -1) { result.push(cron); } else { - result.splice(index, 1, { + result.splice(index + pageSize * (currentPage - 1), 1, { ...cron, }); } @@ -442,7 +444,7 @@ const Crontab = () => { .then((data: any) => { const index = value.findIndex((x) => x._id === cron._id); const result = [...value]; - result.splice(index, 1, { + result.splice(index + pageSize * (currentPage - 1), 1, { ...cron, ...data.data, }); @@ -511,6 +513,12 @@ const Crontab = () => { }); }; + const onPageChange = (page: number, pageSize: number | undefined) => { + setCurrentPage(page); + setPageSize(pageSize as number); + localStorage.setItem('pageSize', pageSize + ''); + }; + useEffect(() => { if (logCron) { localStorage.setItem('logCron', logCron._id); @@ -532,6 +540,7 @@ const Crontab = () => { setMarginLeft(0); setMarginTop(-72); } + setPageSize(parseInt(localStorage.getItem('pageSize') || '20')); }, []); return ( @@ -602,6 +611,9 @@ const Crontab = () => { columns={columns} pagination={{ hideOnSinglePage: true, + current: currentPage, + onChange: onPageChange, + pageSize: pageSize, showSizeChanger: true, defaultPageSize: 20, showTotal: (total: number, range: number[]) => From cf1840a47071ba38d4702fcad8572d27dd0da31b Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 18:34:12 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E7=8A=B6=E6=80=81=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/api.sh | 6 +++--- shell/task.sh | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/shell/api.sh b/shell/api.sh index b5bec373..2c2384c2 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -133,7 +133,7 @@ del_cron_api() { get_user_info() { local currentTimeStamp=$(date +%s) local api=$( - curl -s "http://localhost:5700/api/user?t=$currentTimeStamp" \ + curl -s "http://localhost:5600/api/user?t=$currentTimeStamp" \ -H 'Accept: */*' \ -H "Authorization: Bearer $token" \ -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36' \ @@ -153,7 +153,7 @@ update_cron_status() { local status=$2 local currentTimeStamp=$(date +%s) local api=$( - curl -s "http://localhost:5700/api/crons/status?t=$currentTimeStamp" \ + curl -s "http://localhost:5600/api/crons/status?t=$currentTimeStamp" \ -X 'PUT' \ -H "Accept: application/json" \ -H "Authorization: Bearer $token" \ @@ -162,7 +162,7 @@ update_cron_status() { -H "Origin: http://localhost:5700" \ -H "Referer: http://localhost:5700/crontab" \ -H "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7" \ - --data-raw "{\"ids\":\"[$ids]\",\"status\":\"$status\"}" \ + --data-raw "{\"ids\":[$ids],\"status\":\"$status\"}" \ --compressed ) code=$(echo $api | jq -r .code) diff --git a/shell/task.sh b/shell/task.sh index 35e3ae6c..9ea31d87 100755 --- a/shell/task.sh +++ b/shell/task.sh @@ -3,6 +3,7 @@ ## 导入通用变量与函数 dir_shell=/ql/shell . $dir_shell/share.sh +. $dir_shell/api.sh ## 组合Cookie和互助码子程序,$1:要组合的内容 combine_sub() { @@ -120,11 +121,11 @@ run_normal() { log_dir="$dir_log/${log_dir_tmp%%.*}" log_path="$log_dir/$log_time.log" make_dir "$log_dir" - + local id=$(cat $list_crontab_user | grep -E "$cmd_task $p1$" | perl -pe "s|.*ID=(.*) $cmd_task $p1$|\1|" | xargs | sed 's/ /","/g') - local status="0" ## 0 任务运行中 - update_cron_status "\"$id\"" $status + update_cron_status "\"$id\"" "0" timeout $command_timeout_time $which_program $p1 2>&1 | tee $log_path + update_cron_status "\"$id\"" "1" } ## 并发执行,因为是并发,所以日志只能直接记录在日志文件中(日志文件以Cookie编号结尾),前台执行并发跑时不会输出日志 From 3a35673b1b9ddd4496e466fa191ec534daf714c9 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 18:37:25 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0shell=20token=E8=8E=B7?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/api.sh | 2 ++ shell/update.sh | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/api.sh b/shell/api.sh index 2c2384c2..c58242b8 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -173,3 +173,5 @@ update_cron_status() { echo -e "失败(${message})" fi } + +get_token \ No newline at end of file diff --git a/shell/update.sh b/shell/update.sh index 21fac8b9..70e0bddd 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -7,8 +7,6 @@ dir_shell=/ql/shell send_mark=$dir_shell/send_mark -get_token - ## 重置仓库remote url,docker专用,$1:要重置的目录,$2:要重置为的网址 reset_romote_url() { local dir_current=$(pwd) From 14ebfab9c9955cb92c8dc7e5b031251b922675e5 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 18:45:05 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=8F=82=E6=95=B0=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/cron.ts | 5 ++++- shell/api.sh | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/back/api/cron.ts b/back/api/cron.ts index 63436808..5206c6b6 100644 --- a/back/api/cron.ts +++ b/back/api/cron.ts @@ -238,7 +238,10 @@ export default (app: Router) => { const logger: Logger = Container.get('logger'); try { const cronService = Container.get(CronService); - const data = await cronService.status(req.body); + const data = await cronService.status({ + ...req.body, + status: parseInt(req.body.status), + }); return res.send({ code: 200, data }); } catch (e) { logger.error('🔥 error: %o', e); diff --git a/shell/api.sh b/shell/api.sh index c58242b8..d2c1d410 100755 --- a/shell/api.sh +++ b/shell/api.sh @@ -168,9 +168,9 @@ update_cron_status() { code=$(echo $api | jq -r .code) message=$(echo $api | jq -r .message) if [[ $code == 200 ]]; then - echo -e "成功" + echo -e "更新任务状态成功" else - echo -e "失败(${message})" + echo -e "更新任务状态失败(${message})" fi } From 015244ff563f3183608a2497555ab03a64287dc0 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 18:50:29 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sample/config.sample.sh | 6 +++--- src/version.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sample/config.sample.sh b/sample/config.sample.sh index 924ed3d2..35a37640 100644 --- a/sample/config.sample.sh +++ b/sample/config.sample.sh @@ -1,6 +1,6 @@ -## Version: v2.2.0-062 -## Date: 2021-06-07 -## Update Content: session管理增加批量操作\n增加go-cqhttp通知方式\n修复页面标题 +## Version: v2.2.0-063 +## Date: 2021-06-13 +## Update Content: \n1. 增加文件后缀配置 RepoFileExtensions\n2. 增加定时任务pageSize缓存\n3. 增加定时任务自动运行时状态展示 ## 上面版本号中,如果第2位数字有变化,那么代表增加了新的参数,如果只有第3位数字有变化,仅代表更新了注释,没有增加新的参数,可更新可不更新 diff --git a/src/version.ts b/src/version.ts index 246fd666..d2123029 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ -export const version = 'v2.2.0-062'; -export const changeLog = 'https://t.me/jiaolongwang/105'; +export const version = 'v2.2.0-063'; +export const changeLog = 'https://t.me/jiaolongwang/106'; From 29042ec11c4f2f772f8f99055debb82678f1a949 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 19:33:35 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=8E=E7=BC=80=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/update.sh b/shell/update.sh index 70e0bddd..efcf7e32 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -357,8 +357,14 @@ gen_list_repo() { cd ${repo_path} local cmd="find ." + local index=0 for extension in $file_extensions; do - cmd="${cmd} -o -name \"*.${extension}\"" + if [[ $index -eq 0 ]]; then + cmd="${cmd} -name \"*.${extension}\"" + else + cmd="${cmd} -o -name \"*.${extension}\"" + fi + let index+=1 done files=$($cmd | sed 's/^..//') if [[ $path ]]; then From cd8249d53c45e5bd610f827398c4eea550442c60 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 20:04:56 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=9B=9E=E9=80=80ql=20re?= =?UTF-8?q?po=E6=8B=89=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/update.sh b/shell/update.sh index efcf7e32..44ff8190 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -356,16 +356,16 @@ gen_list_repo() { cd ${repo_path} - local cmd="find ." - local index=0 - for extension in $file_extensions; do - if [[ $index -eq 0 ]]; then - cmd="${cmd} -name \"*.${extension}\"" - else - cmd="${cmd} -o -name \"*.${extension}\"" - fi - let index+=1 - done + local cmd="find . -name *.js" + # local index=0 + # for extension in $file_extensions; do + # if [[ $index -eq 0 ]]; then + # cmd="${cmd} -name \"*.${extension}\"" + # else + # cmd="${cmd} -o -name \"*.${extension}\"" + # fi + # let index+=1 + # done files=$($cmd | sed 's/^..//') if [[ $path ]]; then files=$(echo "$files" | egrep $path) From 8885fcf1a59f4c198f90b2c1567eb0443b823804 Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 20:27:06 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dql=20repo=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/shell/update.sh b/shell/update.sh index 44ff8190..7bf53451 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -356,17 +356,17 @@ gen_list_repo() { cd ${repo_path} - local cmd="find . -name *.js" - # local index=0 - # for extension in $file_extensions; do - # if [[ $index -eq 0 ]]; then - # cmd="${cmd} -name \"*.${extension}\"" - # else - # cmd="${cmd} -o -name \"*.${extension}\"" - # fi - # let index+=1 - # done - files=$($cmd | sed 's/^..//') + local cmd="find ." + local index=0 + for extension in $file_extensions; do + if [[ $index -eq 0 ]]; then + cmd="${cmd} -name \"*.${extension}\"" + else + cmd="${cmd} -o -name \"*.${extension}\"" + fi + let index+=1 + done + files=$(eval $cmd | sed 's/^..//') if [[ $path ]]; then files=$(echo "$files" | egrep $path) fi From 882622b1f767299a23b1dc6c16ada02fe4c6742c Mon Sep 17 00:00:00 2001 From: hanhh Date: Sun, 13 Jun 2021 22:41:38 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dql=20repo=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/update.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/update.sh b/shell/update.sh index 7bf53451..f8d8c5cb 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -374,7 +374,7 @@ gen_list_repo() { files=$(echo "$files" | egrep -v $blackword) fi if [[ $dependence ]]; then - $cmd | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts + eval $cmd | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts fi for file in ${files}; do filename=$(basename $file)