Code:
grep PATTERN [FILE]
So... and these are on the command line, not through any cron job:
Code:
# smartctl -a /dev/sda
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.10.0+2] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
Vendor: LSI
Product: MR9271-4i
Revision: 3.45
User Capacity: 3,999,688,294,400 bytes [3.99 TB]
Logical block size: 512 bytes
Logical Unit id: 0x600605b00b6d7d501eeb815b5ba29659
Serial number: 005996a25b5b81eb1e507d6d0bb00506
Device type: disk
Local Time is: Mon Oct 24 11:11:22 2016 CEST
Device does not support SMART
Error Counter logging not supported
Device does not support Self Test logging
But if I only want the "Serial number"
Code:
# smartctl -a /dev/sda | grep "Serial number"
Serial number: 005996a25b5b81eb1e507d6d0bb00506
There are more advanced ways to specify patterns, for example to get the capacity and serial:
Code:
# smartctl -a /dev/sda | grep "Serial\|Capacity"
User Capacity: 3,999,688,294,400 bytes [3.99 TB]
Serial number: 005996a25b5b81eb1e507d6d0bb00506
You'll also see that grep checks the lines in order and if they match the pattern they'll be displayed, regardless of the order in the pattern.
You're also now at the stage where your cron line is getting a bit complicated so you might want to consider creating a shell script and calling that from cron.