03-09-2016
Hi yifangt, x is an unused variable (it is not a string, since there are no quotes around it), so it is equivalent to ""
so it can also be written as sub(/^@/, ""), which means delete the first @ of the record.
Using "" is probably clearer, so I would use that...
Last edited by Scrutinizer; 03-09-2016 at 03:45 PM..
This User Gave Thanks to Scrutinizer For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
:D dear members I have a good knowledge of gawk and seem to do quite well with it.. but I have never understood what the use of the rs and ors are for or how they are used.. i am thinking they are for seperating lines and paragraphs but i have absolutely no idea how to make it work, if that is what... (2 Replies)
Discussion started by: moxxx68
2 Replies
2. Shell Programming and Scripting
var1=`echo "emp,dept,salgrade" | awk -F, '{print NF}'`
count=1
while ;
do
i=`expr $count`
tname=`echo "emp,dept,salgrade" | awk -F, '{ print $(echo $i) }'`
count=$count+1;
echo ${tname};
echo $count
done
I want to store in tname=emp, tname=dept,tname=salgrade
I am getting... (2 Replies)
Discussion started by: dreams5617
2 Replies
3. UNIX for Dummies Questions & Answers
hi there
i write one awk script file in shell programing
the code is related to dd/mm/yy to month, day year format
but i get an error
please can anybody help me out in this problem ??????
i give my code here including error
awk `
# date-month -- convert mm/dd/yy to month day,... (2 Replies)
Discussion started by: Herry
2 Replies
4. Shell Programming and Scripting
typeset -i i=1
while read -r filename; do
Splitfile=`$Targetfile_$i.txt`
awk 'substr($0,1,5) == substr($filename,1,5) && substr($0,526,2) == substr($filename,6,2) && substr($0,750,12) == substr($filename,8,12)' $SourceFilename >> $Splitfile
i=i+1
done < /tmp/list.out
I am using this logic... (1 Reply)
Discussion started by: pukars4u
1 Replies
5. Shell Programming and Scripting
Hello all,
Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val:
> cat getnon0file.sh
#!/bin/bash
this="getnon0file.sh"
USAGE=$this"
InFile="xyz.38"
Min="0.05"
#
awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies
6. Shell Programming and Scripting
Hi Team,
I have .csv file in the following format
.csv file
TAB1;COL1;DATATYPE;NOTNULL;WITH DEFAULT
TAB2;COL1;DATATYPE;NOTNULL;WITH DEFAULT
....
....
....
output:
ALTER TABLE TAB1. add COL1 DATATYPE NOTNULL WITH DEFAULT;
ALTER TABLE TAB2 add COL1 DATATYPE NOTNULL WITH DEFAULT;
I... (5 Replies)
Discussion started by: rocking77
5 Replies
7. Shell Programming and Scripting
Good evening, Im newbie at unix specially with awk
From an scheduler program called Autosys i want to extract some data reading an inputfile that comprises jobs names, then formating the output to columns for example
1.
This is the inputfile:
$ more MapaRep.txt
ds_extra_nikira_usuarios... (18 Replies)
Discussion started by: alexcol
18 Replies
8. UNIX for Dummies Questions & Answers
Hi all...
In the OSX forum I am starting a new awk project to learn awk.
In this code snippet I have had to check boundaries to ensure that no NUMERICAL error occurs in the rest of the code...
printf "Enter frequency required:- ";
getline FREQ;
RATE=(BYTES*FREQ);
if ( RATE <= 4000 ) {... (4 Replies)
Discussion started by: wisecracker
4 Replies
9. Shell Programming and Scripting
Hello Team,
here is the code:
scripts]# ls /etc/init.d/ | awk 'BEGIN{ORS=" && "} /was.init/ && !/interdependentwas/ && !/NodeAgent/ && !/dmgr/{print "\$\{service_cmd\} "$0 " status"}' 2>/dev/null
${service_cmd} cmserver_was.init status && ${service_cmd} fmserver_was.init status &&... (6 Replies)
Discussion started by: chandana.hs
6 Replies
10. UNIX for Beginners Questions & Answers
Question: Write a command to print the fields in a text file in reverse order?
awk 'BEGIN {ORS=""} { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename
I was thinking it should be (what is the need to set ORS="" ? )-
awk 'BEGIN { for(i=NF;i>0;i--) print $i," "; print "\n"}' filename (3 Replies)
Discussion started by: Tanu
3 Replies
LEARN ABOUT DEBIAN
dpkg::substvars
Dpkg::Substvars(3) libdpkg-perl Dpkg::Substvars(3)
NAME
Dpkg::Substvars - handle variable substitution in strings
DESCRIPTION
It provides some an object which is able to substitute variables in strings.
METHODS
my $s = Dpkg::Substvars->new($file)
Create a new object that can do substitutions. By default it contains generic substitutions like ${Newline}, ${Space}, ${Tab},
${dpkg:Version} and ${dpkg:Upstream-Version}.
Additional substitutions will be read from the $file passed as parameter.
It keeps track of which substitutions were actually used (only counting substvars(), not get()), and warns about unused substvars
when asked to. The substitutions that are always present are not included in these warnings.
$s->set($key, $value)
Add/replace a substitution.
$s->set_as_used($key, $value)
Add/replace a substitution and mark it as used (no warnings will be produced even if unused).
$s->get($key)
Get the value of a given substitution.
$s->delete($key)
Remove a given substitution.
$s->mark_as_used($key)
Prevents warnings about a unused substitution, for example if it is provided by default.
$s->no_warn($key)
Obsolete function, use mark_as_used() instead.
$s->load($file)
Add new substitutions read from $file.
$s->parse($fh, $desc)
Add new substitutions read from the filehandle. $desc is used to identify the filehandle in error messages.
$s->set_version_substvars($sourceversion, $binaryversion)
Defines ${binary:Version}, ${source:Version} and ${source:Upstream-Version} based on the given version strings.
These will never be warned about when unused.
$s->set_arch_substvars()
Defines architecture variables: ${Arch}.
This will never be warned about when unused.
$newstring = $s->substvars($string)
Substitutes variables in $string and return the result in $newstring.
$s->warn_about_unused()
Issues warning about any variables that were set, but not used
$s->set_msg_prefix($prefix)
Define a prefix displayed before all warnings/error messages output by the module.
$s->save($file)
Store all substitutions variables except the automatic ones in the indicated file.
"$s" Return a string representation of all substitutions variables except the automatic ones.
$str = $s->output($fh)
Print all substitutions variables except the automatic ones in the filehandle and return the content written.
AUTHOR
Raphael Hertzog <hertzog@debian.org>.
1.16.15 2014-06-05 Dpkg::Substvars(3)