02-11-2008
Processing with AWK and Arrays
Done, thanks for the help - worked.
Last edited by fusionX; 02-20-2008 at 01:01 AM..
Reason: Job Done. now its owkring.
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi All,
I have been working on awk and arrays. I have this small script:
cat maillog*|awk -F: '$2=="SMTP-Accept" && $5~/string/ {lastdate=substr($1,1,8); internaluser=$5; v++} END {for (j in v) {print lastdate, v, j}'| sort>> mail.list
This gives me the number of mails users are getting. ... (1 Reply)
Discussion started by: nitin
1 Replies
2. Shell Programming and Scripting
Guys,
OK so i have been trying figure this all all day, i guess its a pretty easy way to do it.
Right, so i have to column of data which i have gotten from one huge piece of data. What i would like to do is to put both of these into one array using awk. Is this possible??
If so could... (1 Reply)
Discussion started by: imonthejazz
1 Replies
3. Shell Programming and Scripting
Hi, I've written the following code to manipulate the first 40 lines of a data file into my desired order:
#!/bin/awk -f
{ if (NR<=(4)){
a=a$0" "}
else { if ((NR >= (5)) && (NR <= (13))) {
b=b$0" " }
else {if ((NR >= (14)) && (NR <= (25))){
c=c$0" "}
... (5 Replies)
Discussion started by: catwoman
5 Replies
4. Shell Programming and Scripting
Hi,
I have spent the afternoon trawling Google, Unix.com and Unix in a Nutshell for information on how awk arrays work, and I'm not really getting too far.
I ahve a batch of code that I am pretty sure can be better managed using awk, but I'm not sure how to use awk arrays to do what I'm... (1 Reply)
Discussion started by: littleIdiot
1 Replies
5. Shell Programming and Scripting
Hi,
I have the following data in a file for example:
Name="Fred","Bob","Peterson","Susan","Weseley"
Age="24","30","28","23","45"
Study="English","Engineering","Physics","Maths","Psychology"
Code="0","0","1","1","0"
Name="Fred2","Bob2","Peterson2","Susan2","Weseley2"... (14 Replies)
Discussion started by: james2009
14 Replies
6. UNIX for Dummies Questions & Answers
Hi
Can someone please explain the logic of awk arrays. I have been doing some reading but I dont understand this:
#!/usr/bin/gawk -f
{
arr++;
}
end
{
for(i in arr)
{
print arr,i
}
}
As I understand arr refs the arrays index, so while $2 is a string that cant... (2 Replies)
Discussion started by: chronics
2 Replies
7. Shell Programming and Scripting
Hi, buddies
I am new to shell scripting and trying to solve a problem. I read about arrays in awk that they are quite powerful and are associative in nature.
Awk Gurus Please help!
I have a file:
Id1 pp1 0t4 pp8 xy2
Id43 009y black
Id6 red xy2
Id12 new pp1 black
I have... (5 Replies)
Discussion started by: geli21
5 Replies
8. Shell Programming and Scripting
Hi,
I need a logic for processing 2 arrays at a same time.
x=a,b,c
y=d,e
now the sequence to be followed is (a,d) , (b,e) , (c,d) , (a,e) , (b,d) , (c,e)
and again...(a,d)
The sequence should be maintained.
Thanks (3 Replies)
Discussion started by: giri_luck
3 Replies
9. Shell Programming and Scripting
So I'm back once again beating my head off a wall trying to figure out how to get this to work.
My end goal is to take input such as what's below, which will be capture in real time with a tail -f from a file or piped output from another command:
... (5 Replies)
Discussion started by: ShadowBlade72
5 Replies
10. Programming
Hello,
I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this :
This is the output of ls command : I stored the output in a file filelist
1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies
LEARN ABOUT MOJAVE
syscallbysysc.d
syscallbysysc.d(1m) USER COMMANDS syscallbysysc.d(1m)
NAME
syscallbysysc.d - syscalls by syscall. Uses DTrace.
SYNOPSIS
syscallbysysc.d
DESCRIPTION
syscallbysysc.d is a DTrace OneLiner to a report of the number of each type of system call made.
This is useful to identify which system call is the most common.
Docs/oneliners.txt and Docs/Examples/oneliners_examples.txt in the DTraceToolkit contain this as a oneliner that can be cut-n-paste to run.
Since this uses DTrace, only users with root privileges can run this command.
EXAMPLES
This samples until Ctrl-C is hit.
# syscallbysysc.d
FIELDS
first field
This is the system call type. Most have man pages in section 2.
second field
This is the count, the number of occurrances for this system call.
DOCUMENTATION
See the DTraceToolkit for further documentation under the Docs directory. The DTraceToolkit docs may include full worked examples with ver-
bose descriptions explaining the output.
EXIT
syscallbysysc.d will sample until Ctrl-C is hit.
AUTHOR
Brendan Gregg [Sydney, Australia]
SEE ALSO
procsystime(1M), dtrace(1M), truss(1)
version 1.00 May 15, 2005 syscallbysysc.d(1m)