root@SDP_Wildcat_Pass-3-C1:~# cat /proc/driver/rtc
rtc_time : 05:29:40
rtc_date : 2014-12-19
alrm_time : 01:51:53
alrm_date : 2014-12-20
alarm_IRQ : no
alrm_pending : no
update IRQ enabled : no
periodic IRQ enabled : no
periodic IRQ frequency : 1024
max user IRQ frequency : 64
24hr : yes
periodic_IRQ : no
update_IRQ : no
HPET_emulated : yes
BCD : yes
DST_enable : no
periodic_freq : 1024
batt_status : okay
it's wrong with below command
root@SDP_Wildcat_Pass-3-C1:~# cat /proc/driver/rtc |awk -F: "/alrm_time/{print $3}"
alrm_time : 01:51:53
Could be quoting issue
akshay@nio:/tmp$ awk -F: "/alrm_time/{print $3}" file
alrm_time : 01:51:53
akshay@nio:/tmp$ awk -F: '/alrm_time/{print $3}' file
51
akshay@nio:/tmp$ akshay=123; awk -F: "/alrm_time/{print $akshay}" file
123
1 Like
RudiC
October 5, 2014, 10:33am
3
What's wrong? Which result do you want to get?
Two mistakes.
$3 is substituted by the shell even within "quotes". You need 'single quotes'.
the field delimiter : is wrong, there would be only two fields (with spaces). The default delimiter (white space) would work with $3 here. A more sophisticated delimiter is
-F ' +: +'
and $2 is the value without leading spaces.
< /proc/driver/rtc awk -F ' +: +' '$1=="alrm_time" {print $2}'
---------- Post updated at 10:09 AM ---------- Previous update was at 09:51 AM ----------
Just seeing you want the second field of the value. Then the : and $3 are ok.