【问题标题】:How do I list all files in gcs bucket (with all folder) for a specific string match in the file content using gsutil command如何使用 gsutil 命令列出 gcs 存储桶中的所有文件(包含所有文件夹)以匹配文件内容中的特定字符串
【发布时间】:2021-07-29 20:10:41
【问题描述】:

我想列出 gcs 存储桶中的文件,其中包含文件内容中特定字符串模式的多个文件夹。有没有使用 gustil 的快速解决方案?

【问题讨论】:

    标签: unix gsutil


    【解决方案1】:
    #!/bin/bash
    read -p "Enter gcs path : " gcs_path
    read -p "Enter pattern : " pattern
    path=${gcs_path}**
    #pattern=$2
    echo "loading the list of files.."
    gsutil ls -h $path > gcs_list.txt
    echo "Looking for the pattern from the list...."
    while read -r line ; do
    ##echo "Reading line :  $line"
    if      gsutil cat $line | grep -q "$pattern"  ; then
            #true
            echo " Match found for $line"
    fi
    done < gcs_list.txt
    echo "Pattern search done!!"
    

    这会奏效。如果有人有更好的解决方案,请更新相同的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-16
      • 2020-02-25
      • 2018-12-03
      • 1970-01-01
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 2021-06-13
      相关资源
      最近更新 更多