You are not logged in.
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
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
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
That's the BOM, https://en.wikipedia.org/wiki/Byte_order_mark
Offline
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