Sponsored Content
Top Forums Shell Programming and Scripting Does awk have parameter substitution? Post 302942735 by Chubler_XL on Thursday 30th of April 2015 11:27:31 PM
Old 05-01-2015
Well you could us the ? operator like this:

Code:
argument=length($1) ? $1 : "default if empty"

or like this:

Code:
argument=$1~"^$" ? "default if empty" : $1

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

awk variable substitution

for the command below, it looks for the 3rd field value matching "P" and printing it. awk '{if ($3 == "P") print}' file how would i express this if i use a loop to find more that 1 variable fro a list? this doesn't seem to work... cat list | while read n do awk '{if ($3 == "$n") print}'... (1 Reply)
Discussion started by: apalex
1 Replies

2. Shell Programming and Scripting

Filed substitution with awk

guys, I'm trying to 9k lines of the following: aaa aaa 1 1 1 to aaa aaa 1 01 1 Im pretty ignorant when it comes to subtituting fields using awk any help ? Tony (1 Reply)
Discussion started by: tony3101
1 Replies

3. Shell Programming and Scripting

AWK substitution

I need to copy field 2 to field 3 for only those records that have the 1st field equal to account e.g. file account|123|789|xxx|yyy|zzz|... account_group|444|555|xxx|yy|zz|.... account|456|901|aaa|bbb|ccc|..... after running awk script should look like account|123|123|xxx|yyy|zzz|...... (4 Replies)
Discussion started by: klut
4 Replies

4. Shell Programming and Scripting

help with awk substitution

Hi again. A have a CSV-file in the following format: 2008.09.01,15:17:42,9227096485,9233175320,CTC10,SMS,0901151742098314,Target_MSIS DN_is_blacklisted I want to have an awk command that will say: If the first 3 digits of $4 does not begin with 922 or 923, then make $8 say "Invalid... (3 Replies)
Discussion started by: daytripper1021
3 Replies

5. Shell Programming and Scripting

Substitution using awk/gawk

Hello, I have a file containing lines such as: (1 104 (16) (17) (18) (102))$ (1 105 (16) (17) (19:21) (102))$ I would like to extract the numbers, only by using awk (or gawk). I do not want to use "sed" as it is very slow. For now my solution consists in... (2 Replies)
Discussion started by: jolecanard
2 Replies

6. UNIX for Dummies Questions & Answers

Parameter substitution with alias

Hello, in my .bashrc I tried to setup some aliases. alias scp_cmd="scp -P 8888 $1 me@somehost:." is supposed to copy a local file to somehost via scp. However it seems that the command line substitution does not work here. However this works: alias lst="ls -l $1" The above scp command can... (1 Reply)
Discussion started by: strobotta
1 Replies

7. Shell Programming and Scripting

Substitution in AWK

I am trying to use AWK to replace dallinux02 to dallinux03 everywhere in the servers.txt file and move it over to "awk2". Here is my script "awk2.awk": gsub(/dallinux02/, "dallinux03"); print > "awk2" I am trying to run this using the following: $ awk -f awk2.awk... (3 Replies)
Discussion started by: ora_umair
3 Replies

8. Shell Programming and Scripting

Parameter substitution with##

Hi experts I want to use the parameter substitution in the bash with ## to get a=mfs1000 (not the "mfs" maybe other string and the length is not the same" I want to get 1000 any help? I don't know use which pattern I use echo ${a##*} It doesn't work Lei (5 Replies)
Discussion started by: yanglei_fage
5 Replies

9. Shell Programming and Scripting

awk substitution

Hi all, I need some help with substitution in awk. Is it possible to substitute field from awk output with string from file? For example: zcat /SMS/CDR/cdr_TC/callLogs*_*_2013092710*.gz | sed 's/:/;/g' | awk -F";" '{if($2==1 && $10~/389123456789/) print $36";"$37}' 2;19733248 I want... (6 Replies)
Discussion started by: vasil
6 Replies

10. Shell Programming and Scripting

Parameter substitution is not working with sed

I am trying add a prefix variable(string) to command output. sed parameter substitution is not working. - I have found some issues on my end of testing,, please delete this thread for now. (1 Reply)
Discussion started by: kchinnam
1 Replies
Imager::Expr::Assem(3pm)				User Contributed Perl Documentation				  Imager::Expr::Assem(3pm)

NAME
Imager::Expr::Assem - an assembler for producing code for the Imager register machine SYNOPSIS
use Imager::Expr::Assem; my $expr = Imager::Expr->new(assem=>'...', ...) DESCRIPTION
This module is a simple Imager::Expr compiler that compiles a low-level language that has a nearly 1-to-1 relationship to the internal representation used for compiled register machine code. Syntax Each line can contain multiple statements separated by semi-colons. Anything after '#' in a line is ignored. Types of statements: variable definition "var" name:type defines variable name to have type, which can be any of "n" or "num" for a numeric type or "pixel", "p" or "c" for a pixel or color type. Variable names cannot include white-space. operators Operators can be split into 3 basic types, those that have a result value, those that don't and the null operator, eg. jump has no value. The format for operators that return a value is typically: result = operator operand ... and for those that don't return a value: operator operand where operator is any valid register machine operator, result is any variable defined with "var", and operands are variables, constants or literals, or for jump operators, labels. The set operator can be simplified to: result = operator All operators maybe preceded by a label, which is any non-white-space text immediately followed by a colon (':'). BUGS
Note that the current optimizer may produce incorrect optimization for your code, fortunately the optimizer will disable itself if you include any jump operator in your code. A single jump to anywhere after your final "ret" operator can be used to disable the optimizer without slowing down your code. There's currently no high-level code generation that can generate code with loops or real conditions. SEE ALSO
Imager(3), transform.perl, regmach.c AUTHOR
Tony Cook <tony@develop-help.com> perl v5.14.2 2011-06-06 Imager::Expr::Assem(3pm)
All times are GMT -4. The time now is 01:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy