You are not logged in.

#1 2022-02-03 13:32:56

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

[solved] Downloading the content of a Google Drive Doc

Hello all,

I have put a bash script together that download and print the content of a google drive document onto a local .txt file.

#!/bin/bash
cd /home/sweetth/Downloads
wget --no-check-certificate 'https://docs.google.com/document/export?format=txt&id=[FILE_ID]' -O 'download-doc.txt'

The trouble is that the first line when opening using nano has 3 empty spaces at the beginning of the file and cause issue for what I am intending it to be use. If I open the file in Kate (Kde editor) no empty spaces are shown. If printing it in the terminal no empty spaces is shown neither!?

The trouble is that I tried to used 'sed' or 'awk' command to remove it but nothing work.

I am assuming it's due to the formatting from the Google doc.

Any help or idea would be greatly appreciated.

many thanks

Last edited by sweetthdevil (2022-02-03 16:56:54)

Offline

#2 2022-02-03 14:54:20

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,442
Website

Re: [solved] Downloading the content of a Google Drive Doc

What's the actual content of the start of the file?  Open it in a hex editor or put the first chunk of the file through a tool like xxd, e.g.:

head -c 16 download-doc.txt | xxd

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2022-02-03 16:10:43

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

Re: [solved] Downloading the content of a Google Drive Doc

Hi Trilby,

Thank you for your reply, see below the actual content of the start of the file using xxd:

00000000: efbb bf68 7474 7073 3a2f 2f74 6834 796b  ...https://th4yk

Offline

#4 2022-02-03 16:24:59

seth
Member
Registered: 2012-09-03
Posts: 49,981

Re: [solved] Downloading the content of a Google Drive Doc

Offline

#5 2022-02-03 16:55:53

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

Re: [solved] Downloading the content of a Google Drive Doc

Brilliant!!

Thank you so much!!

For those that are interested I added the following to the bash script to remove the BOM.

sed -i '1s/^\xEF\xBB\xBF//' download-doc.txt

Offline

Board footer

Powered by FluxBB