LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2011, 11:41 AM   #1
KManepalli
LQ Newbie
 
Registered: Feb 2011
Posts: 4

Rep: Reputation: 0
display awk output in perl


Hi

I am trying to use awk command in perl.

Below is my awk comamnd which works alone.

awk '{Easttot=Easttot+$1} END {print Easttot}' MessagesProcessedEAST2Cnts.dat

I would like to use this awk's output in shell script.

I am using system command like below to get the out put. But it is not working .

$Output = system("awk '{Easttot=Easttot+$1} END {print Easttot}' MessagesProcessedEAST2Cnts.dat'");

I am not sure if the above syntax is correct.
Please let me know.

Thanks
Kiran
 
Old 02-08-2011, 05:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi, welcome to LQ!

How does the "not working" manifest itself?

Irrespective of "not working", you'd be better off to do
that calculation within perl rather than from an external
command - using two programming languages for one task
seems kind of inefficient.



Cheers,
Tink

Last edited by Tinkster; 02-08-2011 at 06:19 PM. Reason: meh
 
Old 02-08-2011, 07:59 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,250

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
I am with Tink on this one. Even though I am an avid awk user, it would seem a waste to use this when already using one of the most powerful string manipulative languages.
 
Old 02-08-2011, 08:24 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
From 'perldoc -f system':
Code:
The return value is the exit status of the program
Perhaps you meant to use `backticks`, or open().
But really, like the others have already said, the whole concept is just wrong and redundant. Calling AWK from Perl is like taking a hot-dog to a banquet.

--- rod.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk does not > output Alkass Programming 4 04-25-2010 06:10 PM
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 04:35 PM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 01:21 PM
Awk Output kalyanofb Programming 4 02-02-2007 03:23 AM
Awk output Trouble fooforon Programming 6 04-12-2004 08:14 AM


All times are GMT -5. The time now is 06:26 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration