LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Need one solution for Parsing Text (https://www.linuxquestions.org/questions/linux-software-2/need-one-solution-for-parsing-text-877387/)

pattanaikhr 04-27-2011 08:02 AM

Need one solution for Parsing Text
 
Hi All,
Step1 :
$lastlog -u user1
Username Port From Latest
user1 pts/4 10.142.230.18 Wed Apr 27 08:08:29 +0530 2011
Step2:
$lastlog -u user2
Username Port From Latest
user2 **Never logged in**

Please help me below outputs
============================
Output:
Step1 :
Wed Apr 27 08:08:29 +0530 2011
Step2 :
**Never logged in**

Thanks for helping me :)

Cheers,
Pattanaikhr

druuna 04-27-2011 08:14 AM

Hi,

Give this a try:
Code:

lastlog -u user1 | awk '/^user1/ { print }' | cut -c44-
Or if you want to use a variable:
Code:

THISUSER=user1
lastlog -u $THISUSER | awk '/^'$THISUSER'/ { print }' | cut -c44-

Hope this helps.

pattanaikhr 04-27-2011 09:19 AM

Thanks a lot :) . It's working fine

druuna 04-27-2011 09:49 AM

You're welcome :)

BTW: Can you put up the [SOLVED] tag (first post -> Thread Tools).


All times are GMT -5. The time now is 10:41 AM.