LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 07-19-2016, 11:32 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Grep help


I have a lot of work getting comfortable with grep.

I am trying to display just the line that has temp1 from sensors output.

This does not work.

grep "temp1" sensors
 
Old 07-19-2016, 11:42 PM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there,

Is sensors a file or a command (sounds like the latter)? If it's a command, the correct syntax is:

Code:
sensors | grep "temp1"
If it's a file, can you provide a sample of it's contents?
 
Old 07-20-2016, 12:33 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,905

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
you still did not learn: saying "does not work" does not help. Try to explain what's wrong, what is the expected result and what's happened instead.
also (as it was asked): what is that sensors? Is this a command, a script, a file or what? Where is it from (How it was created/downloaded/installed)?
 
Old 07-20-2016, 10:31 AM   #4
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by cliffordw View Post
Hi there,

Is sensors a file or a command (sounds like the latter)? If it's a command, the correct syntax is:

Code:
sensors | grep "temp1"
If it's a file, can you provide a sample of it's contents?
Thanks cliford.


Code:
andy@7:~$ sensors
radeon-pci-0008
Adapter: PCI adapter
temp1:         +2.0°C  (crit = +120.0°C, hyst = +90.0°C)

it8620-isa-0228
Adapter: ISA adapter
in0:          +0.89 V  (min =  +0.00 V, max =  +3.06 V)
in1:          +1.54 V  (min =  +0.00 V, max =  +3.06 V)
in2:          +2.02 V  (min =  +0.00 V, max =  +3.06 V)
in3:          +2.05 V  (min =  +0.00 V, max =  +3.06 V)
in4:          +2.04 V  (min =  +0.00 V, max =  +3.06 V)
in5:          +2.23 V  (min =  +0.00 V, max =  +3.06 V)
in6:          +2.23 V  (min =  +0.00 V, max =  +3.06 V)
3VSB:         +3.34 V  (min =  +0.00 V, max =  +6.12 V)
Vbat:         +3.17 V  
fan1:        1726 RPM  (min =   10 RPM)
fan2:           0 RPM  (min =    0 RPM)
fan3:         566 RPM  (min =    0 RPM)
fan4:           0 RPM  (min =    0 RPM)
fan5:           0 RPM  (min =    0 RPM)
temp1:        +34.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = thermistor
temp2:       -128.0°C  (low  = +127.0°C, high = +127.0°C)  sensor = disabled
temp3:        +16.0°C  (low  =  +0.0°C, high = +60.0°C)  sensor = Intel PECI
intrusion0:  ALARM

k10temp-pci-00c3
Adapter: PCI adapter
temp1:         +2.6°C  (high = +70.0°C)
                       (crit = +80.0°C, hyst = +79.0°C)

fam15h_power-pci-00c4
Adapter: PCI adapter
power1:           N/A  (crit =  65.19 W)
This displayed the line I wanted.

sensors | grep "thermistor"
 
Old 07-20-2016, 10:35 AM   #5
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by pan64 View Post
you still did not learn: saying "does not work" does not help. Try to explain what's wrong, what is the expected result and what's happened instead.
also (as it was asked): what is that sensors? Is this a command, a script, a file or what? Where is it from (How it was created/downloaded/installed)?
I did not state what sensors was because every distro I have used has it or it is available.

https://wiki.archlinux.org/index.php/Lm_sensors
 
Old 07-20-2016, 10:35 AM   #6
ardvark71
LQ Veteran
 
Registered: Feb 2015
Location: USA
Distribution: Lubuntu 14.04, 22.04, Windows 8.1 and 10
Posts: 6,282
Blog Entries: 4

Rep: Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842Reputation: 842
Hi Andy...

Please don't forget to mark this thread as "SOLVED" if you feel your question has been answered. Thanks!

Regards...

Last edited by ardvark71; 07-20-2016 at 10:37 AM. Reason: Added wordage.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & grep - how to return pathes, not grep phrases ? postcd Linux - General 2 11-25-2014 12:43 PM
grep to file outputs more than grep to screen? tcpman Linux - Server 4 06-07-2013 04:46 AM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 10:31 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 05:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration