Skip to content

Commit

Permalink
Merge pull request #1 from mvk15/removing-extra-command--use-bash-bui…
Browse files Browse the repository at this point in the history
…ltin-for-extracting-a-substring

Add files via upload
  • Loading branch information
mvk15 authored Oct 11, 2024
2 parents 18fcb1c + 9202830 commit c10a458
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions smartmon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,12 @@ 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
fi
# Exit if "smartctl" version is lower 6
[[ ${smartctl_version%.*} -lt 6 ]] && exit 0

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

Expand Down

0 comments on commit c10a458

Please sign in to comment.