LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2007, 07:08 AM   #1
ericcarlson
Member
 
Registered: Jan 2002
Posts: 162

Rep: Reputation: 30
I need to tail -f just a few colums o a text file


This file is in this format, which I tail -f from putty on a PC:

30-Jan-2007 13:03:28 Pwcws 1.30 [KSFH] ---- Entry ----
30-Jan-2007 13:03:28 Pwcws 1.30 [KSFH] Account:
30-Jan-2007 13:03:28 Pwcws 1.30 [KSFH] Collection: default
30-Jan-2007 13:03:28 Pwcws 1.30 [KSFH] User: (Anon)

I now have putty for the Nokia E61 and its screen is narrower. What I want to do is tail -f > {something} so that only the essential columns are shown, which in this case are:

13:03:28 ---- Entry ----
13:03:28 Account:
13:03:28 Collection: default
13:03:28 User: (Anon)

i.e. the 13th-22nd chars then the 40th to the line end. A cinch for you BASH veterans!!!! Thanks.
 
Old 01-30-2007, 07:23 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Code:
tail -f filename | gawk '{print substr($0,13,9),substr($0,40)}'

Last edited by colucix; 01-30-2007 at 07:26 AM.
 
Old 01-30-2007, 07:51 AM   #3
ericcarlson
Member
 
Registered: Jan 2002
Posts: 162

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by colucix
Code:
tail -f filename | gawk '{print substr($0,13,9),substr($0,40)}'
Right first time - thanks!
 
Old 01-30-2007, 03:07 PM   #4
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
a simple one:

tail -f filename | awk '{ print $2, $6 }'
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM
scp/ssh tail(multiple file) remote copy tpreitano Linux - General 1 08-22-2005 02:17 PM
Tail Last Modified File in a Directory tyoungblood Linux - Software 3 08-12-2005 08:42 AM
Echoing the first and last colums of a textfile ganninu Linux - General 4 06-26-2004 05:54 AM
dmegs tail Unchecked file sysytem -- Run e2fsck Nichole_knc Slackware 6 04-18-2004 05:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:24 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