Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
538 views
in Technique[技术] by (71.8m points)

google cloud platform - String Replace With GSUTIL

I am trying to remove a pipe at the end of the header(first) row in a .csv file in GCS using GSUTIL and sed. The command below produces the output sed: can't read ... No such file or directory

sed 's/58_rxsig"|"/58_rxsig1/' gs://../file.csv

58_rxsig is the last field name in the header row so my thought was to find the literal string '58_rxsig|' and just replace with the literal string '58_rxsig' but I've apparently been unable to get the syntax correct.

Any ideas on how to accomplish this?

Sample Input:

12_word|

Desired Output:

12_word

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The sed command doesn't know how to read files from GCS. You'll need to download the contents of your file from GCS to a local file and then supply that as your last argument to sed, e.g. if you had an object named "a/b/c.txt" in your bucket:

gsutil cp gs://bucket/a/b/c.txt my/local/directory/
sed <your flags and arguments here> my/local/directory/c.txt

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...