【发布时间】:2021-07-29 20:10:41
【问题描述】:
我想列出 gcs 存储桶中的文件,其中包含文件内容中特定字符串模式的多个文件夹。有没有使用 gustil 的快速解决方案?
【问题讨论】:
我想列出 gcs 存储桶中的文件,其中包含文件内容中特定字符串模式的多个文件夹。有没有使用 gustil 的快速解决方案?
【问题讨论】:
#!/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!!"
这会奏效。如果有人有更好的解决方案,请更新相同的
【讨论】: