usage of AWK command under perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting usage of AWK command under perl script
# 1  
Old 10-14-2011
usage of AWK command under perl script

i have two files as shown below
t1.txt:
Code:
argument1
argu2
argu37

t2.txt:
Code:
22
33
44

i want o/p as
Code:
argument1             22
argu2                     33
argu37                   44

i am trying to merge two file under perl script using following
Code:
system("paste t1.txt t2.txt | awk '{ printf "%-10s %s\n", $1, $2 }'>ff.txt");

i am getting error as
Substitution pattern not terminated at rr.pl line .....

i am able to get o/p when i run the command under shell script as below
Code:
paste t1.txt t2.txt | awk '{ printf "%-10s %s\n", $1, $2 }'>ff.txt

but i want perl script for it.
can anyone help me out.

Last edited by Franklin52; 10-14-2011 at 03:40 AM.. Reason: Please use code tags, thank you
# 2  
Old 10-14-2011
I don't use perl, and it seems strange to make a system call to awk when perl is so powerful, ... but,

"What happens when you have \"two levels\" of quotes in perl?"

edit-- in case the hint wasn't helpful enough, i do believe perl has a special qq() function too... such that maybe:
Code:
system( qq(paste t1.txt t2.txt | awk '{ printf "%-10s %s\n", $1, $2 }'>ff.txt) );

would do better?

Last edited by neutronscott; 10-14-2011 at 03:52 AM.. Reason: clearify
# 3  
Old 10-14-2011
i am getting error as below:
Use of uninitialized value in concatenation (.) or string at rr.pl line
# 4  
Old 10-14-2011
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Usage of shell variable in perl command

Hi, I have a shell script, In which i have variable "var1" and some perl command inside shell script. export var1='coep -n rst-a2p-hinje.vci.all.com -c' perl -pi -e 's/^/coep -n rst-a2p-hinje.vci.all.com -c /' command.txt currently I am adding value of var1 in command.txt file by... (2 Replies)
Discussion started by: rakeshtomar82
2 Replies

2. How to Post in the The UNIX and Linux Forums

Usage of tail command in .awk

Hi, I want to do file format using awk script, for that i wan to use 'tail'. Here is the scenario. I will be having set of files in a directory. Those files i need to write to another directory with same file name, but while writing the file to out directory, i need to write the last line as... (3 Replies)
Discussion started by: Venkata Madhu
3 Replies

3. HP-UX

Perl script limit cpu usage

Hi Experts, I am executing multiple instances(in parallel) of perl script on HP-UX box. OS is allocating substantial amount of CPU to these perl processes,resulting higher cpu utilization. Glance always shows perl processes are occupying majority of the CPU resource. It is causing slower... (2 Replies)
Discussion started by: sai_2507
2 Replies

4. Shell Programming and Scripting

usage of Awk command for output

Hi Experts, I have a Text file generated as below; <NAME> NEW#<technicalName><TAB> <Version> OLD#<technicalName><TAB> <Version> e.g. CH_PPV_AUDIT_DISTRIBUTOR NEW#EL_CFG_FTP_DISTRIBUTOR 2.1.0.upc2 OLD#EL_CFG_FTP_DISTRIBUTOR 2.1.0.upc1... (19 Replies)
Discussion started by: rajangupta2387
19 Replies

5. Shell Programming and Scripting

Perl Script to find the disk usage and to delete the files which is consuming more space

Hi All, I have written a script to check the file system usage and to delete the files which is consuming more space.Please check whether the script is corrcet #Script Starts here #!/usr/local/bin/perl #Program to find the disk space and to delete the older files #Checks the type of OS... (8 Replies)
Discussion started by: arunkarthick
8 Replies

6. Programming

Executing a awk command inside perl script --

Hello experts I want to execute a awk command, which reads from txt files and sums the numbers from the first column for those listed only inside a <init> block -- The awk command is like awk '/<\/?init>/{x = !x}x{a++}x && a > 2{sum+=$1}END{printf"%E" "\n", sum} So, I want to execute... (2 Replies)
Discussion started by: Alkass
2 Replies

7. Shell Programming and Scripting

Reverse script usage -Awk

Is it possible to convert EXONtoBED (Output to input)? 1. BEDtoExon.sh ------------------- awk '{ n11 = split($11, t11, ",") n12 = split($12, t12, ",") for (i = 0; ++i < n11;) { s12 = $2 + t12 print $1, s12, s12 + t11, i”E_”$4 } }' $1 ... (1 Reply)
Discussion started by: quincyjones
1 Replies

8. Shell Programming and Scripting

awk and grep command usage

hi Can anyone explain me how these two commands awk and grep works in a ksh shell Thanks Babu (1 Reply)
Discussion started by: ksmbabu
1 Replies

9. Shell Programming and Scripting

time command usage in sh script

how do i get the following type of information when we have a time command in sh script. 0.01user 0.00system 1:32.98elapsed 0%CPU (0avgtext+0avgdata 5360maxresident)k 0inputs+0outputs (342major+0minor)pagefaults 0swaps I always see the following for the time command real 0m0.000s user ... (7 Replies)
Discussion started by: kris_search
7 Replies

10. Shell Programming and Scripting

Perl Split Command usage

Hi, I am trying to use the split commad to seperate string reading from file. but it dosent give me a correct result. can some body tell me what is the wrong in following scritp. #!/usr/bin/perl -w #use CGI qw(:standard); ... (2 Replies)
Discussion started by: maheshsri
2 Replies
Login or Register to Ask a Question