02-11-2005
awk output?
i have this file
11 tony tony
12 john john 0
13 nick nick 20
14 mary mary 40
i want to display the file like
tony tony missing
john john 0 Failed
nick nick Failed
mary mary 40
if there is no mark for a name flag it as missing ,mark <40 flagged as failed
i came up with
awk ' {no=$4
if (!no){
print $2,$3,"MISSING"
}
else {
if (no>=40){
print $2,$3,$4
}
else {
print $2,$3,$4,"Failed"
}
}
}' file
but the output is :
tony tony missing
john john missing
nick nick Failed
mary mary 40
why it is displaying missing after john while there is mark "0" for him?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
could any one tell me why the following code is working in infinite loop
every time it is asking for no. even though it does not have for loop
#!/bin/awk -f
BEGIN {
print "type a number";
}
{
print "The square of ", $1, " is ", $1*$1;
print "type another number";
}
END {
... (3 Replies)
Discussion started by: useless79
3 Replies
2. Shell Programming and Scripting
nawk -F"|" '{for (i=1;i<=NF;i++) {gsub("^*", "",$i);gsub("*$", "",$i)}}1' OFS="|" file | wc -l
1000
nawk -F"|" '{for (i=1;i<=NF;i++) {gsub("^*", "",$i);gsub("*$", "",$i);print $0}}' OFS="|" file | wc -l
22000
The above awk command are same but with different printing... (1 Reply)
Discussion started by: pinnacle
1 Replies
3. Shell Programming and Scripting
Hi Experts,
I am adding a column of numbers with awk , however not getting correct output:
# awk '{sum+=$1} END {print sum}' datafile
2.15291e+06
How can I getthe output like : 2152910
Thank you..
# awk '{sum+=$1} END {print sum}' datafile
2.15079e+06 (3 Replies)
Discussion started by: rveri
3 Replies
4. Shell Programming and Scripting
hi guys,
i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB
MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00
MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00
this the file raw format:
Number of... (6 Replies)
Discussion started by: dagigg
6 Replies
5. Shell Programming and Scripting
I have a file with the following content.
> cat /tmp/internetusage.txt
6709.296322 30000 2/7/2010 0.00I am using the following awk command to calculate a percentage from field 1 and 2 from the file.
awk '{ print $1/$2*100 }' /tmp/internetusage.txt
This outputs the value "22.3643" as a... (1 Reply)
Discussion started by: jelloir
1 Replies
6. Shell Programming and Scripting
hi i want to find the size of a folder and assign it to a variable and then compare if it is greater than 1 gb.
i am doin this script, but it is throwing error....
#!/bin/ksh
cd . | du -s | size = awk '{print $1}'
if size >= 112000
then
echo size high
fi
ERROR : (4 Replies)
Discussion started by: Nithz
4 Replies
7. Shell Programming and Scripting
Hi All,
I have around 900 Select Sql's which I would like to run in an awk script and print the output of those sql's in an txt file.
Can you anyone pls let me know how do I do it and execute the awk script? Thanks. (4 Replies)
Discussion started by: adept
4 Replies
8. Shell Programming and Scripting
Hi Experts,
I am trying to get system output to capture inside awk , but not working:
Please advise if this is possible :
I am trying something like this but not working, the output is coming wrong:
echo "" | awk '{d=system ("date") ; print "Current date is:" , d }'
Thanks, (5 Replies)
Discussion started by: rveri
5 Replies
9. Shell Programming and Scripting
hello all
input file
AAA: XXX1
CCC: DD SS
SSS: SSS1
BBBB: ASAS
ZZZ: ZZZZZ1
XXX: XXXXXXXXXXXXXXX1
PPPP: PPPPPP1
RRRR: 111111111
ZZZ: ZZZZZ2
XXX: XXXXXXXXXXXXXXX2
PPPP: PPPPPP2
RRRR: 222222222
ZZZ: ZZZZZ3
XXX: XXXXXXXXXXXXXXX3
PPPP: PPPPPP3
RRRR: 33:33:33:33:33 (2 Replies)
Discussion started by: vikus
2 Replies
10. 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
ii(1) General Commands Manual ii(1)
NAME
ii - irc it or irc improved
DESCRIPTION
ii is a minimalistic FIFO and filesystem based IRC client. It creates an irc directory tree with server, channel and nick name directo-
ries. In every directory a FIFO file (in) and and normal file (out) is placed. This will be for example ~/irc/irc.freenode.net/. The in
file is used to communicate with the servers and the out files includes the server messages. For every channel and every nick name there
will be new in and out files. The basic idea of this is to be able to communicate with an IRC server with basic command line tools. For
example if you will join a channel just do echo "/j #channel" > in and ii creates a new channel directory with in and out file.
SYNOPSIS
ii [-s servername] [-p port] [-k password] [-i prefix] [-n nickname] [-f realname]
OPTIONS
-s servername
lets you override the default servername (irc.freenode.net)
-p port
lets you override the default port (6667)
-k password
lets you use a password to authenticate your nick on the server (be aware of the problem that this is visible in the process list,
if you don't want this use a query to submit your password)
-i prefix
lets you override the default irc path (~/irc)
-n nickname
lets you override the default nick ($USER)
-f realname
lets you specify your real name associated with your nick
DIRECTORIES
~/irc In this directory the irc tree will be created. In this directory you will find a directory for your server (default: irc.freen-
ode.net) in which the FIFO and the output file will be stored. If you join a channel a new directory with the name of the channel
will be created in the ~/irc/$servername/ directory.
COMMANDS
/a [<message>]
mark yourself as away
/j #channel/nickname [<message>]
join a channel or open private conversation with user
/l #channel/nickname
leave a channel or query
/n nick
change the nick name
/t topic
set the topic of a channel
Everything which is not a command will simply be posted into the channel or to the server.
So if you need /who just write /WHO as described in the RFC to the server in FIFO.
out file usage
Write wrappers, pagers or use your tools of choice to display the out file contents (loco, multitail, etc.).
CONTACT
Write to ii (at) modprobe (dot) de for suggestions, fixes, 7|-|>< ;) etc.
AUTHORS
Copyright (C) 2005-2006 by Anselm R. Garbe <garbeam (at) gmail (dot) com> and Copyright (C) 2005-2008 by Nico Golde <nico (at) ngolde (dot)
de>
SEE ALSO
echo(1), tail(1),
ii(1)