Register
It is currently Wed Jul 23, 2014 7:50 pm

awk 'NF>0'


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Fri Oct 28, 2005 10:11 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 662
Location: Des Moines, Iowa
awk 'NF>0' FILENAMEHERE

works like CAT Filename

awk 'NF>0' .bashrc
cat .bashrc


Top
 Profile WWW  
 PostPosted: Thu Dec 07, 2006 9:42 pm   

Joined: Tue Dec 05, 2006 8:37 pm
Posts: 30
Location: Thiruvananthapuram / India
Hi,

awk 'NF>0' will not exactly work like cat because if the file contains blank lines, awk 'NF>0' will skip those blank lines.

But awk 'NF>=0' will work muck like cat and it will print the bank lines too.

The following is my example BASH session:

Code:
lijeesh@Server:~$ cat data.txt
text

text

text
lijeesh@Server:~$ awk 'NF>0' data.txt
text
text
text
lijeesh@Server:~$ awk 'NF>=0' data.txt
text

text

text
lijeesh@Server:~$



Top
 Profile WWW YIM  
 PostPosted: Thu Dec 07, 2006 9:44 pm   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 662
Location: Des Moines, Iowa
Interesting.... I did not know that ;)

Thanks.


Top
 Profile WWW  
 PostPosted: Sat Dec 09, 2006 11:08 am   
User avatar

Joined: Mon Jul 03, 2006 8:58 pm
Posts: 52
Location: Rochester, NY
Call me stupid (please), but why would I use awk instead of cat in this situation? Presumably I could use either. Or was this just one more of those Perl-like "there's more than one way to do it"?


Top
 Profile WWW  
 PostPosted: Sat Jun 11, 2011 6:26 am   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Heh, you don't need to use the NF variable to simulate a simple cat(1).

Code:
awk 1 file

BrionS wrote:
Call me stupid (please), but why would I use awk instead of cat in this situation? Presumably I could use either. Or was this just one more of those Perl-like "there's more than one way to do it"?


It's something funny to know, I guess. (but completely useless)


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP