Sponsored Content
Top Forums Shell Programming and Scripting Awk: How to get an awk variable out to the shell, using system() ? Post 302740455 by Scrutinizer on Thursday 6th of December 2012 07:59:29 AM
Old 12-06-2012
You're welcome. What I meant was, in your original code you had ERR_FILE_TMP and FILE_TMP inside the double quotes, so they would be interpreted by awk as a literal string instead of a variable. So yes, the way to procede then is to create the string to be passed to system() by concatenation of string parts and variables...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

can I pass awk variable to system command?

I wanna use a system function to deal with several data. So I use awk variable FILENAME to transfer the file directory to system command, but it does not work. I use a shell function "out_function" to deal with data and save the result in another directory with the same file name. How can I... (2 Replies)
Discussion started by: zhynxn
2 Replies

2. Shell Programming and Scripting

shell variable in awk

Hi All, How can i use the file for printing in awk file1 ---------- update table crn_ras_disc_dtl a set a.a5=$1,a.a1=$2,a.a2=$3,a.a3=$4,a.a4=$5; file2 -------- 10|KUMAR|23|MALE|US 20|RAJ|24|MALE|AU Output --------- update table crn_ras_disc_dtl a set... (12 Replies)
Discussion started by: cskumar
12 Replies

3. Shell Programming and Scripting

Shell variable with awk

line_no=6 echo 'Phone,' `awk 'NR==$line_no{print;exit}' <filename>` what is the error in this.. it says.. awk: Field $() is not correct. The input line number is 1. The file is <filename>. The source line number is 1. i want to print the data in the $line_no line of a certain... (2 Replies)
Discussion started by: St.Fartatric
2 Replies

4. Shell Programming and Scripting

shell function, system, awk

Hi all, I am calling a shell function within awk using system. I am struggling to get my expected output: #!/bin/sh set -o nounset BEG=44 END=55 shfun() { echo "1|2|3" } export -f shfun typeset -F > /dev/null awk 'BEGIN {OFS="|"; print "'"$BEG"'",system( "shfun"... (5 Replies)
Discussion started by: jkl_jkl
5 Replies

5. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

6. Shell Programming and Scripting

Shell variable in awk

I have 3 files and each contain m*n matrix. m = number of rows (horizontal lines) n = number of columns (entries in a particular line) What I wish to find is the sum of the 2nd number in the last row. Ex file1.dat 2 5 8 8 4 6 7 8 3 8 3 7 file2.dat 3 4 1 4 8 4 0 3 4 7 3 7 ... (3 Replies)
Discussion started by: dynamics
3 Replies

7. Shell Programming and Scripting

using awk for setting variable but change the output of this variable within awk

Hi all, Hope someone can help me out here. I have this BASH script (see below) My problem lies with the variable path. The output of the command find will give me several fields. The 9th field is the path. I want to captured that and the I want to filter this to a specific level. The... (6 Replies)
Discussion started by: Cowardly
6 Replies

8. Shell Programming and Scripting

How to use shell variable in awk?

How do you use a shell variable in awk? I am using Solaris 10 and don't have GNU products installed. File (transportation.txt) contents: car boat airplane snowmobile bicycle sled This awk statment works (prints from the car line down to bicycle awk '/car/,/bicycle/'... (8 Replies)
Discussion started by: thibodc
8 Replies

9. Shell Programming and Scripting

awk question : system output to awk variable.

Hi Experts, I am trying to get system output to capture inside awk , but not working: Please advise if this is possible : I am trying something like this but not working, the output is coming wrong: echo "" | awk '{d=system ("date") ; print "Current date is:" , d }' Thanks, (5 Replies)
Discussion started by: rveri
5 Replies

10. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies
Perl::Critic::Policy::ValuesAndExpressions::ProhibitInteUseraContrPerl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals(3pm)

NAME
Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals - Always use single quotes for literal strings. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
Don't use double-quotes or "qq//" if your string doesn't require interpolation. This saves the interpreter a bit of work and it lets the reader know that you really did intend the string to be literal. print "foobar"; #not ok print 'foobar'; #ok print qq/foobar/; #not ok print q/foobar/; #ok print "$foobar"; #ok print "foobar "; #ok print qq/$foobar/; #ok print qq/foobar /; #ok print qq{$foobar}; #preferred print qq{foobar }; #preferred Use of double-quotes might be reasonable if the string contains single quote (') characters: print "it's me"; # ok, if configuration flag set CONFIGURATION
The types of quoting styles to exempt from this policy can be configured via the "allow" option. This must be a whitespace-delimited combination of some or all of the following styles: "qq{}", "qq()", "qq[]", and "qq//". This is useful because some folks have configured their editor to apply special syntax highlighting within certain styles of quotes. For example, you can tweak "vim" to use SQL highlighting for everything that appears within "qq{}" or "qq[]" quotes. But if those strings are literal, Perl::Critic will complain. To prevent this, put the following in your .perlcriticrc file: [ValuesAndExpressions::ProhibitInterpolationOfLiterals] allow = qq{} qq[] The flag "allow_if_string_contains_single_quote" permits double-quoted strings if the string contains a single quote (') character. It defaults to off; to turn it on put the following in your .perlcriticrc file: [ValuesAndExpressions::ProhibitInterpolationOfLiterals] allow_if_string_contains_single_quote = 1 SEE ALSO
Perl::Critic::Policy::ValuesAndExpressions::RequireInterpolationOfMetachars AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 Perl::Critic::Policy::ValuesAndExpressions::ProhibitInterpolationOfLiterals(3pm)
All times are GMT -4. The time now is 09:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy