Skip to content

Commit c10a458

Browse files
authored
Merge pull request #1 from mvk15/removing-extra-command--use-bash-builtin-for-extracting-a-substring
Add files via upload
2 parents 18fcb1c + 9202830 commit c10a458

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

smartmon.sh

+3-4
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,12 @@ format_output() {
166166
awk -F'{' "${output_format_awk}"
167167
}
168168

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

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

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

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

0 commit comments

Comments
 (0)