LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX
User Name
Password
Other *NIX This forum is for the discussion of any UNIX platform that does not have its own forum. Examples would include HP-UX, IRIX, Darwin, Tru64 and OS X.

Notices


Reply
  Search this Thread
Old 10-31-2007, 04:23 AM   #1
bharatbsharma
Member
 
Registered: Oct 2007
Posts: 33

Rep: Reputation: 15
calling awk commands in perl script


I want to execute awk command in perl script

my working awk command is
awk '{$1 = ""; $2 = ""; print}' f1.txt

which i am calling in perl script using

system ( " awk '{$1 = ""; $2 = ""; print}' f1.txt " );

but executing this through perl is not working.

do i need to use escape characters?

How do i use them?
 
Old 10-31-2007, 05:00 AM   #2
Gethyn
Member
 
Registered: Aug 2003
Location: UK
Distribution: (X)Ubuntu 10.04/10.10, Debian 5, CentOS 5
Posts: 900

Rep: Reputation: 32
Please don't double post.
 
Old 10-31-2007, 05:00 AM   #3
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 406

Rep: Reputation: 89
Code:
#! /bin/sh

len=10
conv=10
# like that
awk '{print v1, v2}' v1=$len v2=$conv
# or like that
awk '{print "'"$len"'", "'"$conv"'"}'
 
Old 11-02-2007, 07:07 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 98
If you change:
Code:
system ( " awk '{$1 = ""; $2 = ""; print}' f1.txt " );
into:
Code:
system(" awk '{\$1 = \"\"; \$2 = \"\"; print}' f1.txt");
the $ and " symbols will then be correctly passed to the awk command.
 
  


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
Calling perl script and passing variable from php script hosea Programming 5 10-21-2008 08:01 AM
awk/perl script for extract data mruknown1 Programming 3 09-11-2007 09:19 AM
awk/perl script for extract data mruknown1 Linux - Newbie 2 09-11-2007 04:42 AM
Script help for awk and timing commands jakev383 Linux - General 2 12-18-2006 07:35 PM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-28-2004 11:31 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Other *NIX

All times are GMT -5. The time now is 04:43 AM.

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