perl awk system quote probems


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers perl awk system quote probems
# 1  
Old 05-13-2012
perl awk system quote probems

Hey guys,

I'm having some issues escaping quotes and getting the following line to run in perl. The quotes are really messing me up.

Code:
system (" awk 'BEGIN{FS="/t";OFS=","} {print \$1,$fieldNum}' $file > output.csv ");


Last edited by WongSifu; 05-13-2012 at 04:22 PM.. Reason: syntax error in first post
# 2  
Old 05-13-2012
Hi WongSifu,

Are you executing a system instruction in a perl script to run an awk comand? What a mess!!

For some help, in perl you can substitute double-quotes with qq and single-quotes with q.

No difference between:
Code:
print "Now\n";

and
Code:
print qq[Now\n];

And the same for single-quotes.

EDIT to say that you can also substitute system with qx[...] with similar result.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing all but the first and last double quote in a line with a single quote with awk

From: 1,2,3,4,5,This is a test 6,7,8,9,0,"This, is a test" 1,9,2,8,3,"This is a ""test""" 4,7,3,1,8,"""" To: 1,2,3,4,5,This is a test 6,7,8,9,0,"This; is a test" 1,9,2,8,3,"This is a ''test''" 4,7,3,1,8,"''"Is there an easy syntax I'm overlooking? There will always be an odd number... (5 Replies)
Discussion started by: Michael Stora
5 Replies

2. Shell Programming and Scripting

Shell or Perl (adding quote around path)

Hi Experts, I have a line as below: Text 351:2139 /opt/bo/boexi30/bobje/data/.bobj/registry/software/business objects/suite 12.0/olap intelligence/occa(o) What I need is: add a single quote around the path as below: chown 351:2139... (4 Replies)
Discussion started by: apatil65
4 Replies

3. Homework & Coursework Questions

Problem with using using quote in awk script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: i have the output of a csh script piped to an awk script. In the awk script i was trying to assign a variable... (3 Replies)
Discussion started by: ymc1g11
3 Replies

4. Shell Programming and Scripting

[Solved] Not able to quote perl function in sprintf() !

The required form of command is as perl /product/editique/RFR/preproc/scripts/ExprEval.pl -P 'EGAL_CHAINE (" ","")' -K /varsoft/editique/RFR/preproc/logs/D.RFR.PR.PCAC9.PCPA.00.54.20110920.Evaluate_Expression.logWhat's wrong with this code (it is not quoting the function, I have checked... (1 Reply)
Discussion started by: ezee
1 Replies

5. Shell Programming and Scripting

Executing AWK in a perl script using 'system'...

I have a simple perl script that looks similar to this: #!/usr/bin/perl/ # Have a lot of PERL code in the front of this script. #Would now like to execute a system command using AWK system (qq(cd /location && awk '/full/ {print $1;exit}' /myfile)); The system command in my perl script... (4 Replies)
Discussion started by: SysAdm2
4 Replies

6. Shell Programming and Scripting

replacing a quote in some lines with multiple quote fields

i want to replace mistaken quotes in line starting with tag 300 and relocate the quote in the correct position so the input is 223;25 224;20100428064823;1;0;0;0;0;0;0;0;8;1;3;9697;18744;;;;;;;;;;;; 300;X;Event:... (3 Replies)
Discussion started by: wradwan
3 Replies

7. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

8. Shell Programming and Scripting

Regex in grep to match all lines ending with a double quote (") OR a single quote (')

Hi, I've been trying to write a regex to use in egrep (in a shell script) that'll fetch the names of all the files that match a particular pattern. I expect to match the following line in a file: Name = "abc" The regex I'm using to match the same is: egrep -l '(^) *= *" ** *"$' /PATH_TO_SEARCH... (6 Replies)
Discussion started by: NanJ
6 Replies

9. Shell Programming and Scripting

want to print single quote using awk

i want to print ' symbol using awk i tried: awk '{print " ' "}' awk '{print "\' "}' both not work please help me. (2 Replies)
Discussion started by: RahulJoshi
2 Replies

10. UNIX for Dummies Questions & Answers

how to print single quote in awk

Hi all, It is a very stupid problem but I am not able to find a solution to it. I am using awk to get a column from a file and I want to get the output field in between single quotes. For example, Input.txt 123 abc 321 ddff 433 dfg ........ I want output file to be as ... (6 Replies)
Discussion started by: gauravgoel
6 Replies
Login or Register to Ask a Question