1、脚本查看
nisjdeMacBook-Pro:Downloads nisj$ cat traveDir.sh
#!/usr/bin/env bash
function read_dir(){
for file in `ls $1`
do
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
cat $1"/"$file|grep "command=sh /data/etl/sh/agr_common.sh dim"|awk -F" " '{print $3}'>>/Users/nisj/Downloads/runigJob.sql
fi
done
}
rm -rf /Users/nisj/Downloads/runigJob.sql
read_dir $1
2、调用示例
sh traveDir.sh /Users/nisj/WptWork/gitOnline/azkaban-job/src/etl-scheduler-subflow
3、注意说明
3.1、调用格式是:[sh traveDir.sh 要遍历的路径]
3.2、[awk -F" " '{print $3}']的使用
3.3、Shell函数的使用
3.4、结果文件查看
nisjdeMacBook-Pro:Downloads nisj$ cat runigJob.sql
dim_regist_sc_1d
dim_sale_id_snap_1d
dim_sale_uri_snap_1d
dim_sc_webtype_1d
dim_seller_base_snap_1d
dim_seller_cfc_organization_full_1d
dim_share_documents_full_chain_1d
dim_template_category_chain_1d
dim_user_base_curr_snap_1d
dim_userinfo_snap_full_1d
dim_user_yj_artisan_full_1d
dim_userinfo_address_full_1d
dim_userinfo_basic_info_full_1d
dim_product_category_full_1d
nisjdeMacBook-Pro:Downloads nisj$
3.5、一个查找文件中包含固定字符串的python脚本
/Users/nisj/Documents/wptDataGit-nisj/wptData/pyScript/love/findFile.py
# encoding: utf-8
import os
def find(find_text):
os.system("""find /Users/nisj/WptWork/gitOnline/etl/sql -maxdepth 1 -type f -name '*.sql'|xargs grep -n '{find_text}'|grep -v '\--'>>/Users/nisj/Downloads/ods_dependent.sql""".format(find_text=find_text));
find_text_list=['ods_activity_sale_apply_full_1d',
'ods_activity_sale_apply_full_1d_old',
'ods_alcohol_alcohol_exchange_full_1d',
'ods_alcohol_alcohol_full_1d',
'ods_alcohol_alcohol_order_full_1d',
'ods_alcohol_alcohol_pay_full_1d',
'ods_alcohol_currency_exchange_full_1d']
os.system(
"rm -rf /Users/nisj/Downloads/ods_dependent.sql");
for find_text in find_text_list:
find(find_text=find_text)