Last active
March 29, 2022 12:06
-
-
Save dlnilsson/7dac8c9fef11b88762e7026ea80743b2 to your computer and use it in GitHub Desktop.
Print current chrome version on Linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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