how can i use two or multiple statements in the if part
of an awk code
for example
i want to check two flag if they are true i will write some print
operations and increase the counter.
here is the c version of the code that i want to write:
counter=0;
if (flag1==1 && flag2==0) {... (7 Replies)
Hi,
Despite reading the Conditional Statements chapter in the O'Reilly Sed & Awk book several times and looking at numerous examples, I cannot for the life of me get any kind of if ... else statement to work in my awk scripts! My scripts work perfectly (as they are written at least) and do what... (4 Replies)
I have an awk statement that works but I am calling awk twice and I know there has to be a way to combine the two statements into one. The purpose is to pull out just the ip address from loopback1.
cat config.txt | nawk 'BEGIN {FS="\n"}{RS="!"}{if ( $0 ~ "interface loopback1" ) print$4}' | nawk... (5 Replies)
I have a pretty simple script below:
#!/bin/sh
for i in *.cfg
do
temp=`awk '/^InputDirectory=/' ${i}`
input_dir=`echo ${temp} | awk '{ print substr( $0, 16) }'`
echo ${input_dir}
done
As you can see its opening each cfg file and searching for the line that has "InputDirectory="... (3 Replies)
Hello UNIX Community,
I have file that contains the following data:
testAwk2.csv
rabbit penguin goat
giraffe emu ostrich
hyena elephant panda
dog cat pig
lizard snake antelope
platypus tiger cheetah
lion rhino spider
I then find the character length of the... (1 Reply)
I'm converting some code from ksh on my macbook (Version M 1993-12-28 s+) to an older solaris machine with ksh 88.
I can't seem to figure out this line, it worked on the new shell version.
set -A combo -- $(for x in ${ImageIDs};
do
nawk -v s=$x 'if($2 == s) getline ; getline if ($1 ==... (2 Replies)
Hi,
I have the following two awk statements which I'd like to consolidate into one by piping the output from the first into the second awk statement (rather than having to write kat.txt out to a file and then reading back in).
awk 'BEGIN {FS=OFS=" "} {printf("%s ", $2);for (x=7; x<=10;... (3 Replies)
I need to run a cronjob that will monitor a directory for files with a certain extension, when one appears I then need to run the below scripts How do I go about combining the following sed statements into one script? and also retain the original filename.?
sed 's/71502FSC1206/\n&/g' # add a... (2 Replies)
Hello again everyone,
yes, I'm back again for more help! So I'm attempting to read two separate files and generate some XML code from that. My current code is:
BEGIN {
print "<?xml version=\"1.0\" encoding=\"utf-8\">"
print "<Export>"
}
{
x=1;
print "<section name=\"Query" NR "\">"... (5 Replies)
Hi
What is the right structure to use awk with multiple If statements
The following code doesn't work
#
awk '
{
A = $1
}
END {
for ( i = 1; i <= c; i++ )
{
if ( A == 236 && A ==199... (7 Replies)
Discussion started by: khaled79
7 Replies
LEARN ABOUT DEBIAN
imager::preprocess
Imager::Preprocess(3pm) User Contributed Perl Documentation Imager::Preprocess(3pm)NAME
Imager::Preprocess - simple preprocessor for handling multiple sample sizes
SYNOPSIS
/* in the source: */
#code condition true to work with 8-bit samples
... code using preprocessor types/values ...
#/code
# process and make #line directives
perl -MImager::Preprocess -epreprocess foo.im foo.c
# process and no #line directives
perl -MImager::Preprocess -epreprocess -l foo.im foo.c
DESCRIPTION
This is a simple preprocessor that aims to reduce duplication of source code when implementing an algorithm both for 8-bit samples and
double samples in Imager.
Imager's "Makefile.PL" currently scans the MANIFEST for .im files and adds Makefile files to convert these to .c files.
The beginning of a sample-independent section of code is preceded by:
#code expression
where expression should return true if processing should be done at 8-bits/sample.
You can also use a #code block around a function definition to produce 8-bit and double sample versions of a function. In this case #code
has no expression and you will need to use IM_SUFFIX() to produce different function names.
The end of a sample-independent section of code is terminated by:
#/code
#code sections cannot be nested.
#/code without a starting #code is an error.
The following types and values are defined in a #code section:
o IM_GPIX("im", "x", "y", &col)
o IM_GLIN("im", "l", "r", "y", "colors")
o IM_PPIX("im", "x", "y", &col)
o IM_PLIN("im", "x", "y", "colors")
o IM_GSAMP("im", "l", "r", "y", "samples", "chans", "chan_count")
These correspond to the appropriate image function, eg. IM_GPIX() becomes i_gpix() or i_gpixf() as appropriate.
o IM_ADAPT_COLORS("dest_channels", "src_channels", "colors", "count")
Call i_adapt_colors() or i_adapt_fcolors().
o IM_FILL_COMBINE("fill") - retrieve the combine function from a fill object.
o IM_FILL_FILLER("fill") - retrieve the fill_with_* function from a fill object.
o IM_SAMPLE_MAX - maximum value for a sample
o IM_SAMPLE_MAX2 - maximum value for a sample, squared
o IM_SAMPLE_T - type of a sample (i_sample_t or i_fsample_t)
o IM_COLOR - color type, either i_color or i_fcolor.
o IM_WORK_T - working sample type, either int or double.
o IM_Sf - format string for the sample type, "%d" or "%f".
o IM_Wf - format string for the work type, "%d" or "%f".
o IM_SUFFIX(identifier) - adds _8 or _double onto the end of identifier.
o IM_EIGHT_BIT - this is a macro defined only in 8-bit/sample code.
Other types, functions and values may be added in the future.
AUTHOR
Tony Cook <tonyc@cpan.org>
perl v5.14.2 2011-06-06 Imager::Preprocess(3pm)