Skip to content

Instantly share code, notes, and snippets.

@dlnilsson
Last active March 29, 2022 12:06
Show Gist options
  • Save dlnilsson/7dac8c9fef11b88762e7026ea80743b2 to your computer and use it in GitHub Desktop.
Save dlnilsson/7dac8c9fef11b88762e7026ea80743b2 to your computer and use it in GitHub Desktop.
Print current chrome version on Linux
#!/usr/bin/env bash
candidates=(
"chromium"
"google-chrome"
"google-chrome-stable"
"chromium-browser"
)
(for c in "${candidates[@]}"; do
if ! command -v "$c" &> /dev/null; then
continue
fi
$c --version | awk 'match($0, /[0-9.]{10,20}/) {print substr($0, RSTART+0, RLENGTH)}'
done) | sort -n | head -1
exit 0
#!/usr/bin/env sh
set -- "chromium" "google-chrome" "google-chrome-stable" "chromium-browser"
(for c in "$@"; do
if ! command -v "$c" > /dev/null 2>&1; then
continue
fi
$c --version | awk 'match($0, /[0-9.]{10,20}/) {print substr($0, RSTART+0, RLENGTH)}'
done) | sort -n | head -1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment