The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Partial Request are coming... please help pa.chidhambaram IP Networking 0 02-05-2008 08:19 AM
vsftpd hiding partial uploads jhod22 Linux 3 07-08-2006 01:49 PM
for linux and BSD users interested in Unix system V/bsd moxxx68 BSD 0 12-03-2004 10:09 PM
Interested, but lost. Ned UNIX for Dummies Questions & Answers 9 09-01-2003 09:03 PM
Extremely Interested Punk18 UNIX for Dummies Questions & Answers 5 08-16-2001 12:36 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-15-2004
Registered User
 

Join Date: Aug 2004
Posts: 141
Wink Interested in partial command output.

Command output is given to the console. As in the following case -

wc -l filename
produces following output
nn filename

From this, I am only interested with nn(rowcount). Cant we simply extract it thr console?

I also tried with null device, I know as - /dev/null

wc -l filename > /dev/null | cut -d " " -f 1 /dev/null

This also didnt help me.

Will I have to use temporary file, in order to retrieve only rowcount?
Reply With Quote
Forum Sponsor
  #2  
Old 12-15-2004
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
The easiest way is to pipe it through awk
Code:
wc -l file | awk '{print $1}'
You can omit the filename by supplying the file as STDIN, e.g.
Code:
$ wc -l < file
but you'll still get leading whitespace. So the awk solution is easiest.

EDIT: Looking at this, it'd be less expensive to just do the whole thing with awk...
Code:
awk '{c++} END{print c}' file
Cheers
ZB

Last edited by zazzybob; 12-15-2004 at 08:07 AM.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:12 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0