LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 10: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, 04:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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 05:19 PM. Reason: meh
 
Old 02-08-2011, 06:59 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
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, 07:24 PM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
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



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 05:10 PM
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 03:35 PM
awk , I need help for awk, just a display function mcandy General 1 12-15-2008 12:21 PM
Awk Output kalyanofb Programming 4 02-02-2007 02:23 AM
Awk output Trouble fooforon Programming 6 04-12-2004 07:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:44 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
Open Source Consulting | Domain Registration