Initial commit
This commit is contained in:
31
snippets/read_first_char_of_file.sh
Executable file
31
snippets/read_first_char_of_file.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# - Read first charactor of a file:
|
||||
# -
|
||||
# - head -c1 <path-to-file>
|
||||
|
||||
deb_major_version=""
|
||||
|
||||
is_number() {
|
||||
|
||||
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
|
||||
|
||||
# - also possible
|
||||
# -
|
||||
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
|
||||
#return $([[ ! -z "${1##*[!0-9]*}" ]])
|
||||
}
|
||||
|
||||
if [[ -f "/etc/debian_version" ]]; then
|
||||
|
||||
deb_major_version=$(head -c1 /etc/debian_version)
|
||||
if is_number $deb_major_version ; then
|
||||
echo -e "\n\tDebian Major Version: $deb_major_version\n"
|
||||
else
|
||||
echo -e "\n\tNo numeric Version given. Debian Version: $(head -1 /etc/debian_version)\n"
|
||||
fi
|
||||
else
|
||||
echo -e "\nFile '/etc/debian_version' not found"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user