Skip to content

Commit

Permalink
Removing extra shell command; Use bash builtin for extracting a subst…
Browse files Browse the repository at this point in the history
…ring (#221)

Removing extra shell command; Use bash builtin for extracting a
substring

Signed-off-by: Mykhailo Kravchuk <[email protected]>
  • Loading branch information
mvk15 authored Oct 23, 2024
1 parent 6b36c81 commit 6e26d97
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions smartmon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,13 @@ format_output() {
awk -F'{' "${output_format_awk}"
}

smartctl_version="$(/usr/sbin/smartctl -V | head -n1 | awk '$1 == "smartctl" {print $2}')"
smartctl_version="$(/usr/sbin/smartctl -V | awk 'NR==1 && $1 == "smartctl" {print $2}')"

echo "smartctl_version{version=\"${smartctl_version}\"} 1" | format_output

if [[ "$(expr "${smartctl_version}" : '\([0-9]*\)\..*')" -lt 6 ]]; then
exit
# Exit if "smartctl" version is lower 6
if [[ ${smartctl_version%.*} -lt 6 ]]; then
exit 0
fi

device_list="$(/usr/sbin/smartctl --scan-open | awk '/^\/dev/{print $1 "|" $3}')"
Expand Down

0 comments on commit 6e26d97

Please sign in to comment.