LinuxQuestions.org
Help answer threads with 0 replies.
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, 05: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, 06: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, 06:00 AM   #3
vermaden
Member
 
Registered: Jan 2006
Location: pl_PL.lodz
Distribution: FreeBSD
Posts: 401

Rep: Reputation: 85
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, 08:07 PM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,039

Rep: Reputation: 97
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


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

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

All times are GMT -5. The time now is 09:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration