User Tools

Site Tools


en:cs:bash:snippet

Bash Snippets

Download files from Google Drive with Wget

I last used it in 2022. If Google hasn't changed it since then, it should work.
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=FILEID' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILEID" -O FILENAME && rm -rf /tmp/cookies.txt

In the code above, fix the two FILEID parts and enter the name you want to save in the FILENAME part with the extension.

Horizontal line drawing across the entire screen

printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -

Learn the size of a file

#!/bin/bash
FILENAME=/home/heiko/dummy/packages.txt
FILESIZE=$(wc -c < "$FILENAME")
# non standard way (GNU stat): FILESIZE=$(stat -c%s "$FILENAME")
 
echo "Size of $FILENAME = $FILESIZE bytes."

Taken from UCH Wiki. ===== NOTLAR =====

en/cs/bash/snippet.txt · Last modified: 2024/08/16 20:10 by 127.0.0.1