NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Dunce awk question
Using your version string above, the following works for me:
% echo 'Model: HGST HTS721010A9E630, Rev: JB0OA3J0, Serial #:
JR10046P1D5UXN' | awk '/Model/ { print $3 }'
HTS721010A9E630,
Some rules I usually go by:
1. Piping through grep and awk is almost always wrong - awk has some
fine regexps, you should just use them
2. Different disks and virtual disks report using different formats.
For instance, for me on a VM:
% sudo atactl wd0 identify
Model: VMware Virtual IDE Hard Drive, Rev: 00000001, Serial #:
00000000000000000001
and the third field in that string is "Virtual"
3. Most uses of "just print this" in awk for me use the "print" verb.
"printf" needs a format string, same as in C.
Regards,
Al
On 25 September 2015 at 08:34, William A. Mahaffey III <wam%hiwaay.net@localhost> wrote:
>
>
> I am trying to use awk & grep to fashion a command to print out HDD temps,
> along w/ some identifying info:
>
> [wam@4256EE1, ~, 10:41:29am] 418 % sudo atactl wd0 identify | grep Model
> Model: HGST HTS721010A9E630, Rev: JB0OA3J0, Serial #: JR10046P1D5UXN
> [wam@4256EE1, ~, 10:41:31am] 419 % sudo atactl wd0 identify | grep Model |
> awk '{printf $3 " "}' -
> [wam@4256EE1, ~, 10:41:32am] 420 % uname -a
> NetBSD 4256EE1.CFD.COM 6.1.5 NetBSD 6.1.5 (GENERIC) amd64
> [wam@4256EE1, ~, 10:41:34am] 421 %
>
> I am only *weakly* familiar w/ GNU awk, where the above works. What am I
> missing here, I expected the above to print out the model # of the HDD.
> Please apply the clue-bat generously :-) ....
>
>
> --
>
> William A. Mahaffey III
>
> ----------------------------------------------------------------------
>
> "The M1 Garand is without doubt the finest implement of war
> ever devised by man."
> -- Gen. George S. Patton Jr.
>
Home |
Main Index |
Thread Index |
Old Index