zoukankan      html  css  js  c++  java
  • Shell 遍历文件夹中所有文件并进行相关操作

    遍历文件夹中所有文件,获取文件名,并对指定文件做相应操作

    #!/bin/bash
    
    dir=$(ls -l /usr/ |awk '/^d/ {print $NF}')
    
    for file in $dir
    do
    
    if [[ $(echo $file | grep "AQSS") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQSS/$1/
    elif [[ $(echo $file | grep "AQCS") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQCS/$1/
    elif [[ $(echo $file | grep "AQKJ") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQKJ/$1/
    elif [[ $(echo $file | grep "AQMC") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQMC/$1/
    elif [[ $(echo $file | grep "AQKC") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQKC/$1/
    elif [[ $(echo $file | grep "AQFZ") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQFZ/$1/ 
    elif [[ $(echo $file | grep "AQGX") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQGX/$1/
    elif [[ $(echo $file | grep "AQDQ") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQDQ/$1/
    elif [[ $(echo $file | grep "AQLJ") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQLJ/$1/
    elif [[ $(echo $file | grep "AQMT") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQMT/$1/
    elif [[ $(echo $file | grep "AQBJ") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQBJ/$1/
    elif [[ $(echo $file | grep "AQKY") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQKY/$1/
    elif [[ $(echo $file | grep "AQYC") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQYC/$1/
    elif [[ $(echo $file | grep "AQKD") != "" ]] then
      hdfs dfs -put $file /origin_data/aqjc/log/topic_AQKD/$1
      else 
      echo $file
    fi
    done
  • 相关阅读:
    windows phone7 学习笔记08——屏幕方向
    windows phone7 学习笔记07——系统托盘和应用程序栏
    .Net中获取当前路径的方法
    开始》运行 常用打开程序命令
    C#操作API
    WinForm 皮肤 IrisSkin
    Visual Studio 2005 无法显示设计视图的解决方法
    SQL Server脏读方式数据提取NOLOCK和READPAST
    在存储过程中设置某表的触发器是否启用
    ajax读取XML文件并显示到下拉列表框中
  • 原文地址:https://www.cnblogs.com/chuijingjing/p/13356039.html
Copyright © 2011-2022 走看看