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 OPENSOLARIS
scha_resourcetype_get
scha_resourcetype_get(1HA) Sun Cluster Commands scha_resourcetype_get(1HA)NAME
scha_resourcetype_get - access resource type information
SYNOPSIS
scha_resourcetype_get -O optag -T type
DESCRIPTION
The scha_resourcetype_get command accesses information about a resource type that is registered with the Resource Group Manager (RGM).
Use this command in shell script implementations of the callback methods for resource types that represent services that are controlled by
the RGM. This command provides the same information as the scha_resourcetype_get(3HA) C function.
Information is output by this command to the standard output (stdout) in formatted strings, as described in the scha_cmds(1HA) man page.
Output is a string or several strings that are output on separate lines. You can store the output in shell variables. You can also parse
the output by using the awk(1) command or other shell commands for further use by the script.
You need solaris.cluster.resource.read RBAC authorization to use this command. See the rbac(5) man page.
Authorized users can issue privileged Sun Cluster commands on the command line from the pfsh(1), pfcsh(1), or pfksh(1) profile shell. A
profile shell is a special kind of shell that enables you to access privileged Sun Cluster commands that are assigned to the Sun Cluster
Commands rights profile. A profile shell is launched when you run su(1M) to assume a role. You can also use pfexec(1) to issue privileged
Sun Cluster commands.
OPTIONS
The following options are supported:
-O optag Indicates the information to be accessed.
Note -
optag options, such as API_VERSION and BOOT, are not case sensitive. You can use any combination of uppercase and lowercase
letters when you specify optag options.
The following optag values retrieve the corresponding resource type properties. The value of the named property of the
resource's type is output.
API_VERSION
BOOT
FAILOVER
FINI
INIT
INIT_NODES
INSTALLED_NODES
IS_LOGICAL_HOSTNAME
IS_SHARED_ADDRESS
MONITOR_CHECK
MONITOR_START
MONITOR_STOP
PKGLIST
POSTNET_STOP
PRENET_START
RESOURCE_LIST
RT_BASEDIR
RT_DESCRIPTION
RT_SYSTEM
RT_VERSION
SINGLE_INSTANCE
START
STOP
UPDATE
VALIDATE
-T type Is the name of a resource type that is registered for use by the RGM cluster facility.
EXIT STATUS
The following exit values are returned:
0 The command completed successfully.
nonzero An error occurred.
Failure error codes are described scha_calls(3HA).
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscdev |
+-----------------------------+-----------------------------+
|Interface Stability |Stable |
+-----------------------------+-----------------------------+
SEE ALSO awk(1), scha_cmds(1HA), scha_calls(3HA), scha_resourcetype_get(3HA), attributes(5), rt_properties(5)Sun Cluster 3.2 31 May 2006 scha_resourcetype_get(1HA)