Issue
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
Solution
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
Answered By - mhouglum Answer Checked By - David Marino (WPSolving Volunteer)