DEV Community

loading...

Download latest version of Slack from the Bash terminal

emmanuelnk profile image Emmanuel N Kyeyune ・2 min read

I am releasing a project to automate the download of common software latest version for Ubuntu (coming soon).

In the meantime...

Downloading the latest version of Slack from the command line is frustrating because there seems to be no official latest tag on the releases one can use. Hence one has to parse the downloads page for the correct link.

This is my solution to this problem:

Ubuntu (saved as slack-desktop-latest.deb):

wget -q https://slack.com/downloads/instructions/ubuntu -O - \
| tr "\t\r\n'" '   "' \
| grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' \
| sed -e 's/^.*"\([^"]\+\)".*$/\1/g' \
| grep 'slack-desktop' \
| xargs wget -q -O slack-desktop-latest.deb
Enter fullscreen mode Exit fullscreen mode

Explanation of commands
  • tr is the unix character translator-- here it translates newlines and tabs to spaces, as well as converts single quotes into double quotes so we can simplify our regular expressions.
  • Matching all <a href="(ADDRESS_IS_HERE)"> on a page. grep -i makes the search case-insensitive grep -o makes it output only the matching portions.
  • sed is the Stream EDitor unix utility which allows for filtering and transformation operations.
  • sed -e just lets you feed it an expression.

Fedora (saved as slack-desktop-latest.rpm):

wget -q https://slack.com/downloads/instructions/fedora -O - \
| tr "\t\r\n'" '   "' \
| grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' \
| sed -e 's/^.*"\([^"]\+\)".*$/\1/g' \
| grep 'slack.*rpm' \
| xargs wget -q -O slack-desktop-latest.rpm
Enter fullscreen mode Exit fullscreen mode

MacOS (saved as slack-desktop-latest.dmg):

wget https://slack.com/ssb/download-osx -q -O slack-desktop-latest.dmg
Enter fullscreen mode Exit fullscreen mode

To get slack in a different language, just add intl/LANG/ in any of the above urls e.g.

https://slack.com/downloads/instructions/fedora
Enter fullscreen mode Exit fullscreen mode

becomes

https://slack.com/intl/ko-kr/downloads/instructions/fedora
Enter fullscreen mode Exit fullscreen mode

for the Korean version

That's all, thanks!

Discussion

pic
Editor guide