LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-27-2011, 08:02 AM   #1
pattanaikhr
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Rep: Reputation: 0
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
 
Old 04-27-2011, 08:14 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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.
 
1 members found this post helpful.
Old 04-27-2011, 09:19 AM   #3
pattanaikhr
LQ Newbie
 
Registered: Jan 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thanks a lot . It's working fine
 
Old 04-27-2011, 09:49 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
You're welcome

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


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
[SOLVED] Parsing text and combining the parsed text zeratul111 Linux - Newbie 6 10-28-2010 12:46 PM
Parsing text file sandeepsudeep Linux - Newbie 7 10-09-2007 05:34 AM
Help with Text Parsing Script NiallC Programming 6 06-24-2006 03:28 PM
I need help parsing text from a text file rsmccain Linux - General 2 01-05-2006 02:43 PM
Text parsing question bruoersolitario Linux - General 4 04-15-2004 02:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:02 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
Open Source Consulting | Domain Registration