Mac Terminal

So I was typing some things in Terminal and after a while, I decided to use (sudo powermetrics --samplers smc |grep -i “CPU die temperature") to check CPU temperature but I was greeted with (pipe dquote>). Now would anyone know how to exit this? I already tried looking it up but it isn't helping. Any help is appreciated!

MacBook Pro 13″, macOS 10.15

Posted on Aug 30, 2022 6:13 AM

Reply
Question marked as ⚠️ Top-ranking reply

Posted on Aug 30, 2022 8:24 AM

In the Terminal, just type control+c to break out of the command expecting you to complete its syntax. Don't type control+z as that just throws the session in the background.


For Intel platforms only (notice the spacing around the pipe symbol).


sudo powermetrics -n 1 --samplers smc | grep "(CPU|GPU) die"

This was from a just booted Core i7 iMac:




21 replies
Sort By: 
Question marked as ⚠️ Top-ranking reply

Aug 30, 2022 8:24 AM in response to LegionScyther7

In the Terminal, just type control+c to break out of the command expecting you to complete its syntax. Don't type control+z as that just throws the session in the background.


For Intel platforms only (notice the spacing around the pipe symbol).


sudo powermetrics -n 1 --samplers smc | grep "(CPU|GPU) die"

This was from a just booted Core i7 iMac:




Reply

Sep 14, 2022 1:54 PM in response to HWTech

I entered the sudo powermetrics -n1 --samplers smc command and got (SMC is currently in monitor mode, no data available). However, when I entered it a second time, I got what's in the first image. Now for the sudo  powermetrics  -n1  --samplers  smc  |   grep  -iE  "(CPU|GPU) die" command, I entered my password and it gave the CPU temperature once. It only gives the temperature if the CPU is being used enough or else it won't show. The second image shows this. The highlighted part is when the CPU was cool giving no info while the non-highlighted part is when the CPU reached a high temperature.

Reply

Sep 20, 2022 7:39 AM in response to HWTech

So I did what you said and it works! It gives the temperature just like before! I noticed that both sudo  powermetrics  --samplers  smc  |  grep  -iE  "(CPU|GPU) die" and sudo  powermetrics  --samplers  smc  |  grep  -iE  "(CPU) die" give CPU temp but I think (I think) that pipe dquote only appears when an invalid command is entered? I don't know for sure but it's worth mentioning...

Reply

Aug 30, 2022 8:57 AM in response to VikingOSX

Yeah... I think I did control+z earlier but I can't recall. Besides that, I did the control+c and it seemed to work but then I put it the (sudo powermetrics --samplers smc |grep -i “CPU die temperature") but it just shows (pipe dquote>) again. Would a restart help or no? Also, in case this info helps, this is on an Early 2015 13" MacBook Pro with an Intel Core i5. Anything else I could try?

Reply

Aug 31, 2022 10:07 AM in response to LegionScyther7

Can't explain why either. On my 2014 Air running Catalina 10.15.7, the SMC sampler does not see the integrated GPU, but does return the CPU die temperature with the same command syntax as I used previously. When you use the parenthesis, it forces to be a subprocess and it does not echo results to the Terminal.

Reply

Sep 1, 2022 5:35 PM in response to VikingOSX

It doesn't work on my MBPro 13" mid-2012 non-Retina model either. In fact I cannot read any temps using powermetrics even when using the "all" option. I did get an error "unable to get smc values", but not sure why. Seems maybe not all Macs have this support. I am running macOS 10.15.x.


The OP may just have to resort to using MacsFanControl.


Reply

Sep 12, 2022 6:08 AM in response to VikingOSX

So what could I do from here? I really only use the sudo powermetrics --samplers smc |grep -i “CPU die temperature" command to check my CPU temperature when playing games or when I'm using CPU intensive software. That command worked everytime until pipe dquote kept appearing after entering sudo powermetrics --samplers smc |grep -i “CPU die temperature".

Reply

Sep 12, 2022 9:43 AM in response to LegionScyther7

FYI, I managed to try this command on several different models of Apple laptops with varying results. It seems many laptops don't access to the temps or SMC attributes. The laptops I've been able to retrieve the SMC values have been the USB-C 2016+ models. On some older laptops it is telling me it cannot retrieve SMC values because "SMC is currently in monitor mode". I'm not sure what is going on with that error message. If you use this part of the command without adding the "grep" filter, then you will see the information provided and any error messages:

sudo  powermetrics  -n1  --samplers  smc


The command provided by @VikingOSX is incorrect as it cannot parse the "(CPU|GPU)" portion of the filter. The following updated command will work if the SMC values are accessible (notice the inclusion of the "-E" option necessary for the "(CPU|GPU)" portion of the filter to work -- tested on Big Sur):

sudo  powermetrics  -n1  --samplers  smc  |   grep  -iE  "(CPU|GPU) die"



Of course this all assumes you are using an Intel Mac since M1/M2 Macs with Apple Silicon do not have an SMC so these command will not work at all. I have no idea how to access any sensor information on Apple Silicon Macs or possible alternate methods on the Intel Macs. I normally just rely on third party apps like MacsFanControl to provide the functionality, although I may be looking into an app which can produce a sensor log over time (I don't usually need this functionality, but there are times it may prove useful).

Reply

Sep 12, 2022 10:12 AM in response to HWTech

HWTech wrote:

The command provided by @VikingOSX is incorrect as it cannot parse the "(CPU|GPU)" portion of the filter.


It was correct on my particular 2020 Intel Core i7 hardware as the screen capture was the command and its results without using the extended (-E) grep. But as you have observed, powermetrics does behave differently across varying Mac hardware, so one might have to use egrep where appropriate.

Reply

Sep 12, 2022 12:31 PM in response to VikingOSX

VikingOSX wrote:


HWTech wrote:

The command provided by @VikingOSX is incorrect as it cannot parse the "(CPU|GPU)" portion of the filter.

It was correct on my particular 2020 Intel Core i7 hardware as the screen capture was the command and its results without using the extended (-E) grep.

Just curious what version of macOS you are using? I was using multiple versions of Big Sur from early 11.6.1 to latest 11.6.8 on at least two different laptop models 2014 & 2017.


HWTech wrote:

On some older laptops it is telling me it cannot retrieve SMC values because "SMC is currently in monitor mode".

Seems a reboot fixed this issue. Now I have to wonder if this is related to the issue a user reported for the laptop running hot. I really miss the days when Macs acted normal and didn't have so many quirks. Hard to tell what is normal and abnormal these days.

Reply

Sep 16, 2022 5:02 PM in response to LegionScyther7

If you want to monitor the temperature non-stop, then remove the " -n1" part of the command as that limits it to one time reporting. To terminate the command you will need to press Control + C within that Terminal window running the process.


FYI, I was hoping to test this command on a Mac running Monterey to compare my results with Big Sur and @VikingOSX. I'll see if I can remember next week. Unfortunately Apple has been making changes to the hardware and even these utilities so things don't always work as expected across various hardware and OS revisions. Somehow third party apps are able to access the temperature sensors, but I'm not sure how they do it. I'm not sure if there is anyway to do so using standard macOS command line utilities.


Personally I normally just use MacsFanControl (posted link in earlier post) to monitor the fan speed and temps since it just works. I have rarely needed to worry about logging the results. It is possible to run MacsFanControl without installing the driver as long as you don't authenticate when running the app, but it is a bit non-intuitive to do so as you must also "Cancel" one of the options. I normally just run it directly from the Downloads folder. Plus this option may prevent being able to automatically update the app. Unfortunately you cannot log the results with this method.

Reply

Sep 20, 2022 7:45 AM in response to LegionScyther7

The GPU temperature is only be available if you have a Mac with a discrete GPU. The majority of Mac configurations rely on the Intel GPU integrated into the CPU. You can see exactly what items are available by running the "powermetrics" command without filtering it through "grep":

sudo  powermetrics  -n1  --samplers  smc
Reply

Sep 20, 2022 11:08 AM in response to HWTech

I was guessing that the GPU temp would not be shown as it is integrated in the CPU but that's perfectly fine. Now, I wanted to ask if there’s a command that can restore Terminal back to its default settings? I’m asking in case I did some damage while messing with Terminal. I don’t think I did, but I’m just going to have it ready.

Reply

Sep 21, 2022 1:06 PM in response to LegionScyther7

There is no safety net on the command line except for what the user creates themselves by making sure any affected files are backed up. Nothing you discussed in this thread should have made any changes to your environment or macOS. Also, we have no way of knowing all the commands you ran or any files which you may have modified.


Be extremely careful using any commands found on the Internet without fully understanding what those commands and each option with those commands will do. You can get more information on each individual command by reviewing the manual "man" pages for each command which will also tell you what each option does. For example, for the commands mentioned in this thread you could check what each one by running these commands:

man  sudo
man  powermetrics
man  grep


Be extremely careful when using "sudo" because it gives the command following it full root (aka admin) access which can very easily cause you to break macOS or even accidentally delete all your data without any way of recovering it except from a backup since data deleted using the command line does not go to the Trash. Without "sudo " pre-pending the command your local user data is still at risk from a mistake, but it does minimize accidents occurring outside of your home user folder. Keep in mind that even users with years of command line experience have been known to make a simple mistake that has had terrible repercussions....sometimes just because of a simple typographical error.


Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Mac Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.