As i see it, not really understanding awk yet, but you're comparing a STRING (a) with an INTEGER (k).
Anyhow, so you pass a list of variables, and when it matches a certain string, you want to call that function?
Must it be awk, because bash works just fine
Hope this helps
Anybody know what's wrong with this syntax?
awk -v job="$job" 'BEGIN { FS="|"}
{print $1,$2," ",$4," ",$3\n,$5,"\n"}' list
It's keeping give me this message:
awk: syntax error near line 1
awk: bailing out near line 1
It seems awk has problem with my BEGIN command.
Any... (8 Replies)
Does anybody know how to print a variable passed to awk command?
awk -F"|" 'BEGIN {print $job,"\n","Question \n"} {print $1,$2$4," ",$3}' "job=$job1" file1
I am trying to pass job the variable job1.
the output is blank.
?? (3 Replies)
I'm trying to get awk to do arithmetic functions with external variables and I'm getting an error that I cannot figure out how to fix.
Insight would be appreciated
money=$1
rate1=$(awk -F"\t " '/'$converting'/{print $3}' convert.table)
rate2=$(awk -F"\t"... (2 Replies)
I'm an experienced awk user, but this one has me stumped. I have an awk script which is called from a UNIX command line as you'd expect:
myscript.awk -v foo=$1 -v bar=$2 filename
My question is this: is there a mechanism for determining the names of the -v variables within a script?
... (3 Replies)
I have an awk script script.awk for example and want to pass a flag (let's call it "neat") so that the data is put into nice columns. For example like this
awk -v neat -f script.awk fin > fout
Then check inside the program if the use has put neat, if yes I output the lines in nice columns,... (1 Reply)
I have the following code in a csh script
I want to pass the value of the variable sigmasq to the awk script so that I can divide $0 by the value of sigmasq
grep "Rms Value" $f.log \
| awk '{ sub(/*:*\.*/,x); \
print... (2 Replies)
Hello
I have a text file with the next pattern
Name,Year,Grade1,Grade2,Grade3
Name,Year,Grade1,Grade2,Grade3
Name,Year,Grade1,Grade2,Grade3
I want to assign to external variables the grades using the awk method.
After i read the file line by line in order to get the grades i use this
... (2 Replies)
Using ksh to call a function which has awk script embedded.
It parses a long two element list file, filled with text numbers (I want column 2, beginning no sooner than line 45, that's the only known thing) . It's unknown where to start or end the data collection, dynamic variables will be used. ... (1 Reply)
Currently have this:
set current=192.168.0.5
set servicehost = `echo $current | awk -F. '{print $4}'`
echo $numberoffields
5
..but would like to reduce # of variables and eliminate echo to have something like this:
set servicehost = `awk -v s="$current" -F. 'BEGIN{print $2}'`But... (3 Replies)
Hi Forum.
I have the following test.txt file and need to extract certain rows based on "starting position", "length of string" and "string to search for":
1a2b3d
2a3c4d
.....
My script accepts 3 parameters: (starting col pos, length to search for, string to search for) and would like to... (4 Replies)
Discussion started by: pchang
4 Replies
LEARN ABOUT REDHAT
initlog
initlog(8) System Manager's Manual initlog(8)NAME
initlog - log messages and events to the system logger
SYNOPSIS
initlog [-cefnpqrs] [--cmd=ARG] [--event=ARG] [--facility=ARG] [--name=ARG] [--priority=ARG] [--run=ARG] [--string=ARG]
DESCRIPTION
initlog logs messages and events to the system logger. It is mainly designed for use in init scripts. initlog reads a configuration file
/etc/initlog.conf by default, to determine its settings. Any line preceded with a # is a comment, and the following configuration direc-
tives are recognized:
facility <logging facility>
Sets the default logging facility
priority <logging priority>
Sets the default logging priority
ignore <regexp>
Messages that match the regular expression will not be logged.
initlog behavior can also be configured by command-line options.
OPTIONS
-c, --cmd=[program]
Execute the specified program, logging anything output to stdout or stderr.
-e, --event=[number]
Logs that the specified event happened. Used in conjuction with --name. Currently specified events are:
1 the action completed successfully
2 the action failed
3 the action was cancelled at user request
4 the action failed due to the failure of a dependent action
-f, --facility=[facility]
Log at the specified syslog facility. The default is daemon (see syslog(3)).
-n, --name=[string]
Log the event under the specified string, such as "inetd".
-p, --priority=[priority]
Log at the specified syslog priority. The default is notice (see syslog(3)).
-q Do not print the program's output, unless it exits with a non-zero exit code.
-r, --run=[program]
Execute the specified program, with an open file descriptor so that the program can pass back commands to initlog.
-s, --string=[string]
Log the specified string to the logger.
--conf=[file]
Specifies an alternate configuration file.
FILES
/etc/initlog.conf
SEE ALSO syslog(3), logger(1)
Sun Jan 24 1999 initlog(8)