Sponsored Content
Full Discussion: Variable in awk substituion
Top Forums Shell Programming and Scripting Variable in awk substituion Post 302938445 by RudiC on Monday 16th of March 2015 11:15:21 AM
Old 03-16-2015
Not sure I understand what you're trying to achieve. Please show the input files and the desired output.
For certain the (single) quotation around the $i can't work.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Env Variable substituion in Sed (-s option)

Folks, I've been trying to use the ENV variable with slashes(/) in its value inside the sed substitution.. Sed 's/myval/'$MYVAL'/' file1 >> file.tmp If MYVAL=<sometext>, it works. if MYVAL=/home/venkat, it doesnt. *************************** bash-2.05$ export VAL=/home/venkat... (5 Replies)
Discussion started by: gvsreddy_539
5 Replies

2. Shell Programming and Scripting

Perl Arrays and Substituion

@xray =~ s/^ *//g; @xray =~ s/ *$//g; @xray =~ s/\s+/ /g; Guess I have a two part question ... First Is there a way to make substitutions, remove leading spaces, trailing spaces, and crunch multiple spaces into a single space, to the entire array, or must the substitutions be done on on... (1 Reply)
Discussion started by: popeye
1 Replies

3. UNIX for Advanced & Expert Users

Tough Substituion command

I have lines like: Mg2.qns W=0.175u Mg2.qpsb W=0.175u Mg4.qns W=0.175u Mg4.qpsb W=0.175u Which I need to become: Mg2.qns W=wmg2qns Mg2.qpsb W=wmg2qpsb Mg4.qns W=wmg4qns Mg4.qpsb W=wmg4qpsb To acheive this individually line by line I use a command like:... (3 Replies)
Discussion started by: ggggdddd
3 Replies

4. Solaris

bad substituion error

Dear All i am getting "bad substituion" error in the follwing piece of code when i run from crontab.however it works if i run directly from my machine. #!/bin/bash for i in `cat abc` do part1=${i:0:12} ; part2=${i:13:27} ; echo "$part1,$part2">> def done (1 Reply)
Discussion started by: asadlone
1 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

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

7. Shell Programming and Scripting

awk print variable then fields in variable

i have this variable: varT="1--2--3--5" i want to use awk to print field 3 from this variable. i dont want to do the "echo $varT". but here's my awk code: awk -v valA="$varT" "BEGIN {print valA}" this prints the entire line. i feel like i'm so close to getting what i want. i... (4 Replies)
Discussion started by: SkySmart
4 Replies

8. UNIX for Beginners Questions & Answers

Bad substituion error : Dont understand why

Hi Folks - I'm getting the following error message when executing my script: $ chmod +x Winexe_Admin.sh $ ./Winexe_Admin.sh Script Name: Winexe_Admin.sh Script Name without EXT: Winexe_Admin ./Winexe_Admin.sh: line 43: ${_MAINPATH}${_LOGPATH}${LOGPATH$}${_YEAR}_${_MONTH}${_DAY}: bad... (2 Replies)
Discussion started by: SIMMS7400
2 Replies

9. 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

10. UNIX for Beginners Questions & Answers

Grepping for one variable while using awk to parse an associated variable

Im trying to search for a single variable in the first field and from that output use awk to extract out the lines that contain a value less than a value stored in another variable. Both the variables are associated with each other. Any guidance is appreciated. File that contains the... (6 Replies)
Discussion started by: ncwxpanther
6 Replies
deb-substvars(5)						    dpkg suite							  deb-substvars(5)

NAME
       deb-substvars - Debian source substitution variables

SYNOPSIS
       substvars

DESCRIPTION
       Before  dpkg-source,  dpkg-gencontrol  and dpkg-genchanges write their control information (to the source control file .dsc for dpkg-source
       and to standard output for dpkg-gencontrol and dpkg-genchanges) they perform some variable substitutions on the output file.

       A variable substitution has the form ${variable-name}.  Variable names consist of alphanumerics, hyphens  and  colons  and  start  with	an
       alphanumeric.  Variable	substitutions  are  performed repeatedly until none are left; the full text of the field after the substitution is
       rescanned to look for more substitutions.

       After all the substitutions have been done each occurrence of the string ${} (which is not a legal substitution) is replaced with a $ sign.

       While variable substitution is done on all control fields, some of those fields are used and needed during the build when the  substitution
       did not yet occur. That's why you can't use variables in the Package, Source and Architecture fields.

       Variable substitution happens on the content of the fields after they have been parsed, thus if you want a variable to expand over multiple
       lines you do not have to include a space after the newline. This is done implicitly when the field is output. For example, if the  variable
       ${Description} is set to "foo is bar.${Newline}foo is great." and if you have the following field:

	Description: foo application
	 ${Description}
	 .
	 More text.

       It will result in:

	Description: foo application
	 foo is bar.
	 foo is great.
	 .
	 More text.

       Variables  can  be  set	using  the  -V	common	option. They can be also specified in the file debian/substvars (or whatever other file is
       specified using the -T option). This file consists of lines of the form name=value.  Trailing whitespace on each  line,	blank  lines,  and
       lines starting with a # symbol (comments) are ignored.

       Additionally, the following standard variables are available:

       Arch   The current host architecture (i.e. the architecture the package is being built for, the equivalent of DEB_HOST_ARCH).

       source:Version
	      The source package version (since dpkg 1.13.19).

       source:Upstream-Version
	      The upstream source package version, including the Debian version epoch if any (since dpkg 1.13.19).

       binary:Version
	      The binary package version (which may differ from source:Version in a binNMU for example; since dpkg 1.13.19).

       Source-Version
	      The  source  package version (from the changelog file). This variable is now obsolete and emits an error when used as its meaning is
	      different from its function, please use the source:Version or binary:Version as appropriate.

       source:Synopsis
	      The source package synopsis, extracted from the source stanza Description field, if it exists (since dpkg 1.19.0).

       source:Extended-Description
	      The source package extended description, extracted from the source stanza Description field, if it exists (since dpkg 1.19.0).

       Installed-Size
	      The approximate total size of the package's installed files. This value is copied into the corresponding control file field; setting
	      it  will	modify the value of that field. If this variable is not set dpkg-gencontrol will compute the default value by accumulating
	      the size of each regular file and symlink rounded to 1 KiB used units, and a baseline of 1 KiB for any other filesystem object type.

	      Note: Take into account that this can only ever be an approximation, as the actual size used on the  installed  system  will  depend
	      greatly  on  the	filesystem  used and its parameters, which might end up using either more or less space than the specified in this
	      field.

       Extra-Size
	      Additional disk space used when the package is installed. If this variable is set its value is added to that of  the  Installed-Size
	      variable (whether set explicitly or using the default value) before it is copied into the Installed-Size control file field.

       S:fieldname
	      The  value  of the source stanza field fieldname (which must be given in the canonical capitalisation; since dpkg 1.18.11).  Setting
	      these variables has no effect other than on places where they are expanded explicitly.  These  variables	are  only  available  when
	      generating binary control files.

       F:fieldname
	      The value of the output field fieldname (which must be given in the canonical capitalisation). Setting these variables has no effect
	      other than on places where they are expanded explicitly.

       Format The .changes file format version generated by this version of the source packaging scripts. If you set this variable the contents of
	      the Format field in the .changes file will change too.

       Newline, Space, Tab
	      These variables each hold the corresponding character.

       shlibs:dependencyfield
	      Variable settings with names of this form are generated by dpkg-shlibdeps.

       dpkg:Upstream-Version
	      The upstream version of dpkg (since dpkg 1.13.19).

       dpkg:Version
	      The full version of dpkg (since dpkg 1.13.19).

       If a variable is referred to but not defined it generates a warning and an empty value is assumed.

FILES
       debian/substvars
	      List of substitution variables and values.

SEE ALSO
       dpkg(1), dpkg-genchanges(1), dpkg-gencontrol(1), dpkg-shlibdeps(1), dpkg-source(1).

1.19.0.5							    2018-04-16							  deb-substvars(5)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy