The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
direct output to a file then email it llsmr777 UNIX for Dummies Questions & Answers 2 11-21-2007 02:21 AM
Re-direct the error msg to log file rony_daniel Shell Programming and Scripting 4 11-21-2006 03:05 PM
How to direct FTP command to use a specific IP add or NIC ? pray44u SUN Solaris 5 06-02-2006 01:49 AM
Direct disk access Lopatonosec High Level Programming 3 05-31-2005 01:39 PM
direct transmission of files via TCP/IP darkspace High Level Programming 5 08-26-2002 03:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-21-2005
jvander jvander is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 20
How to direct awk output to expr?

Is there any way to combine the following two statements into one? I can't figure out how to get expr to take input from the output of the awk call - I've tried piping the output of the awk call into the expr call, and tried using a 'Here' document, nothing seems to work.

export CNT=`wc -l ${QV_FILENAME} | awk '{print $1}'`
export FILE_RECCNT=`expr ${CNT} - 2`

Thanks for any help that anyone can offer.
  #2 (permalink)  
Old 04-21-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
About a hundred solutions here... For one, awk can do arithmetic.
export CNT=`wc -l ${QV_FILENAME} | awk '{print $1-2}'`
  #3 (permalink)  
Old 04-21-2005
jvander jvander is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 20
Thanks for the help!
  #4 (permalink)  
Old 04-21-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511

Code:

awk '{}END{ print NR -2 }'

  #5 (permalink)  
Old 04-21-2005
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409

Code:
count=$(($(wc -l < $file)-2))

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 12:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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