LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-21-2010, 08:59 PM   #1
Bone11409
LQ Newbie
 
Registered: Jan 2009
Posts: 19

Rep: Reputation: 0
how to grep awk or sed the first row and column


Need to pipe the data from who command to get the info from the first row and column I know how to get the info from a entire column using awk '{ print $1 }'also I do know about the whoami id command just using who as a example



minixr console Mar 21 18:28
minixr ttys000 Mar 21 20:42


v1=$(who | ?)
 
Old 03-21-2010, 09:15 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
Code:
who | head -1 | awk '{print $1}'
 
Old 03-21-2010, 09:18 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,848

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
awk gives you the record number - simply test it prior to the print.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] awk, sed, grep and paragraphs ThinkLinux Linux - Newbie 3 04-09-2010 02:22 PM
help with grep/sed/awk nikunjbadjatya Programming 8 02-17-2010 08:29 PM
sed/awk group on first column Eddie Adams Linux - General 4 04-09-2009 11:23 AM
awk/sed to grep the text ahpin Linux - Software 3 10-17-2007 01:34 AM
sed / awk command to print line number as column? johnpaulodonnell Linux - Newbie 2 01-22-2007 08:07 AM


All times are GMT -5. The time now is 07:03 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration