LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to grep awk or sed the first row and column (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-grep-awk-or-sed-the-first-row-and-column-796953/)

Bone11409 03-21-2010 07:59 PM

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 | ?)

troop 03-21-2010 08:15 PM

Code:

who | head -1 | awk '{print $1}'

syg00 03-21-2010 08:18 PM

awk gives you the record number - simply test it prior to the print.


All times are GMT -5. The time now is 04:23 PM.