{"id":1363,"date":"2025-02-28T18:11:27","date_gmt":"2025-02-28T18:11:27","guid":{"rendered":"https:\/\/trouble.org\/?p=1363"},"modified":"2025-02-28T18:12:20","modified_gmt":"2025-02-28T18:12:20","slug":"watching-dmesg-on-mac","status":"publish","type":"post","link":"https:\/\/trouble.org\/?p=1363","title":{"rendered":"watching dmesg on mac"},"content":{"rendered":"<p>Simple script to watch dmesg for changes, something like &#8220;<tt>dmesg --follow<\/tt>&#8221; or &#8220;<tt>dmesg -w<\/tt>&#8221; on systems with a real <tt>dmesg<\/tt> command.<\/p>\n<div class=\"codecolorer-container bash blackboard\" style=\"overflow:auto;white-space:nowrap;height:800px;\"><div class=\"bash codecolorer\">:<br \/>\n<br \/>\n<span class=\"co0\">#<\/span><br \/>\n<span class=\"co0\"># watch dmesg output on the mac for new results... useful since the mac<\/span><br \/>\n<span class=\"co0\"># doesn't support the --follow\/-w\/etc. opts (at least for now!)<\/span><br \/>\n<span class=\"co0\"># tries to update every second<\/span><br \/>\n<span class=\"co0\">#<\/span><br \/>\n<br \/>\n<span class=\"co0\"># number of seconds to sleep<\/span><br \/>\n<span class=\"re2\">SLEEPY<\/span>=<span class=\"nu0\">1<\/span><br \/>\n<br \/>\n<span class=\"re2\">prev<\/span>=$<span class=\"br0\">&#40;<\/span><span class=\"kw2\">mktemp<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<span class=\"re2\">curr<\/span>=$<span class=\"br0\">&#40;<\/span><span class=\"kw2\">mktemp<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<span class=\"co0\"># get rid of temp files on exit<\/span><br \/>\n<span class=\"kw3\">trap<\/span> <span class=\"st0\">&quot;rm -f <span class=\"es2\">$prev<\/span> <span class=\"es2\">$curr<\/span>&quot;<\/span> EXIT<br \/>\n<br \/>\n<span class=\"co0\"># initial... send to screen and tmp file<\/span><br \/>\n<span class=\"kw2\">dmesg<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">tee<\/span> <span class=\"re5\">-a<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$prev<\/span>&quot;<\/span><br \/>\n<br \/>\n<span class=\"co0\"># loop-till-I-can't-loop-no-mo<\/span><br \/>\n<span class=\"kw1\">while<\/span> <span class=\"kw2\">true<\/span>; <span class=\"kw1\">do<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co0\"># get the latest, compare<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">dmesg<\/span> <span class=\"sy0\">&gt;<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$curr<\/span>&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">diff<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$prev<\/span>&quot;<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$curr<\/span>&quot;<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> <span class=\"st_h\">'^&gt;'<\/span> <span class=\"sy0\">|<\/span> <span class=\"kw2\">cut<\/span> <span class=\"re5\">-c3-<\/span><br \/>\n&nbsp; &nbsp; <span class=\"co0\"># move new to the old, snooze, repeat<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">mv<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$curr<\/span>&quot;<\/span> <span class=\"st0\">&quot;<span class=\"es2\">$prev<\/span>&quot;<\/span><br \/>\n&nbsp; &nbsp; <span class=\"kw2\">sleep<\/span> <span class=\"re1\">$SLEEPY<\/span><br \/>\n<span class=\"kw1\">done<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Simple script to watch dmesg for changes, something like &#8220;dmesg &#8211;follow&#8221; or &#8220;dmesg -w&#8221; on systems with a real dmesg command. : # # watch dmesg output on the mac for new results&#8230; useful since the mac # doesn&#8217;t support the &#8211;follow\/-w\/etc. opts (at least for now!) # tries to update every second # # [&hellip;]<\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[364,362,363],"tags":[169,324,365,366],"class_list":["post-1363","post","type-post","status-publish","format-standard","hentry","category-monitor","category-shell","category-system","tag-bash","tag-mac","tag-monitor","tag-system"],"_links":{"self":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/1363","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1363"}],"version-history":[{"count":4,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions"}],"predecessor-version":[{"id":1367,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/1363\/revisions\/1367"}],"wp:attachment":[{"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}