Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
*I meant to post this in Linux General, can one of the moderators move it?*
I am reading the output of /proc/acpi/thermal_zone/ATF0/temperature in a program to read my CPU temp. I am using cat like the following:
Code:
#cat /proc/acpi/thermal_zone/ATF0/temperature
temperature: 49 C
I basically want to get rid of the spaces in between temperature and the actual temperature. Is there a command I can pipe the cat output to, to remove the spaces. I have seen suggestions for sed, or tr, but for some reason I cannot get them to work properly.
Last edited by CincinnatiKid; 09-14-2010 at 09:44 AM.
Reason: Wrong Forum
That sed command cannot handle anything but spaces, so it won't handle tabs or newlines (if they are in there). If there are none then it will work ok.
*I meant to post this in Linux General, can one of the moderators move it?*
In future, please use the "Report" button (bottom right of the post) to ask the moderators to move threads. Doing so is guaranteed to get their attention (I believe an email is sent when posts are reported), but posting in your thread is not, because they aren't necessarily going to read it (whatever the reason may be - they can't look at every single thread, for example).
Having said that, I've reported it for you now. It's probably better off in Programming, but obviously the mods will make that decision.
What's the reason for the square brackets if there's one character inside?
Habit, I automatically use space and tab when hunting for whitespace (I should use :space: more often) and forget that the square brackets aren't really needed when removing either of the two. I don't use the + that much because in some programs it needs to be escaped (sed being an example).
This would indeed work:
Code:
sed 's/ */ /' /proc/acpi/thermal_zone/ATF0/temperature
This would not:
Code:
sed 's/ */ /' /proc/acpi/thermal_zone/ATF0/temperature
But this would:
Code:
sed 's/ \+/ /' /proc/acpi/thermal_zone/ATF0/temperature
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.