The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 11:19 AM
vsftpd hiding partial uploads jhod22 Linux 3 07-08-2006 04:49 PM
for linux and BSD users interested in Unix system V/bsd moxxx68 BSD 0 12-04-2004 01:09 AM
Interested, but lost. Ned UNIX for Dummies Questions & Answers 9 09-02-2003 12:03 AM
Extremely Interested Punk18 UNIX for Dummies Questions & Answers 5 08-16-2001 03:36 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-15-2004
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
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?
  #2 (permalink)  
Old 12-15-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
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 11:07 AM..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0