Nawk Time Function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Nawk Time Function
# 1  
Old 11-01-2007
Nawk Time Function

Hi All,

I am using solaris and nawk.
Is there any time function in nawk which is simliar to the shell `date` function ?
Can any experts show any examples?
# 2  
Old 11-01-2007
you can execute nawk's built-in system() function to execute `date` command: system(date)
# 3  
Old 11-01-2007
Hi Yogesh Sawant,

I tried to use the below but it's showing a zero after the display of date.
Why is that so ? Can you help me to remove it ?

Code:
$ nawk 'BEGIN{print system("date")}' web_awk
Thu Nov  1 15:33:55 SGT 2007
0

# 4  
Old 11-01-2007
Code:
nawk 'BEGIN {
	system("date")
}'

without system():

Code:
awk 'BEGIN { print | "date"; exit }'

# 5  
Old 11-01-2007
Hi radoulov,

Both codes work!!!
Thanks alot!!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

2. Shell Programming and Scripting

nawk time substracting

Nawk ‘BEGIN {printf “0t%d=Y\n”,srand () -1800}' | adb I know that printf is printing the value in %d which is for a day of the month and subtracting the value by -1800 (30 minutes). So if date is 14:25:45 subtracting from 1800 then time will equal to 13:55:45 I also know that srand () is... (1 Reply)
Discussion started by: INHF
1 Replies

3. Shell Programming and Scripting

time conversion using nawk

hi, i've got an input file that contains 12345678 AAA 12345679 BBB 12345680 CCC where 1st column is epoch time while the second column are some string. I'm using nawk to do regular expression on the 2nd column and i need to convert the epoch time to human readable time e.g. 'yyyymmdd... (5 Replies)
Discussion started by: bing
5 Replies

4. Shell Programming and Scripting

Help using SYSTEM function in NAWK

I am scanning a file (line by line) for format errors. A line could have multiple errors. Each field in the line is evaluated for errors and sent, along w/ any error messages, to a temporary file. Finally, if any errors were detected, this temporary file is then appended to the errorFile. The... (4 Replies)
Discussion started by: aschera
4 Replies

5. Shell Programming and Scripting

NAWK - looping with match() function

i'm trying to use the "before" output from the match() function as part of the results of each Regex match... but... My input data: (from an input file) i only show the first record in my file.. all other records are similar. mds_ar/bin/uedw92wp.ksh:cat $AI_SQL/wkly_inqry.sql... (2 Replies)
Discussion started by: danmauer
2 Replies

6. UNIX for Dummies Questions & Answers

time function

hello everybody! i want to post a question. So, I use the command 'time a.out' to time the duration of the program a.out. The return value of this function was: real 0m4.116s user 0m4.112s sys 0m0.016s What i want is! I try to find a way to get (NOT manually) the value of real time.... (2 Replies)
Discussion started by: nicos
2 Replies

7. Shell Programming and Scripting

NAWK getline function

Hi, I am using a Solaris OS here. My intention is to print the 2nd field if the first field matches "APPLE=". I am using the "getline" function here (shown below), but it doesn;t work. Can any experts give me some advice? Input: ORANGE= 10 APPLE= 20 MANGO= 30 GRAPES= 40 Output: 20 ... (5 Replies)
Discussion started by: Raynon
5 Replies

8. Programming

function time

Hello I have problem with function 'time' to test my program for file copying . How to run the function in my source code ? I try something like that: system("time"); < -- but this don't working (2 Replies)
Discussion started by: scotty_123
2 Replies

9. Shell Programming and Scripting

time function

Hi, I would like to display the exact time taken to complete running a particular tool or function or program to user I don't know the exact time functions in unix, please help me thanks in advance Example: $test.ksh output should be The... (10 Replies)
Discussion started by: hsekol
10 Replies

10. Shell Programming and Scripting

Nawk user-defined function

HELP!!!! I am in an on-line shell programming class and have a question. Here is the data: Mike Harrington:(510) 548-1278:250:100:175 Christian Dobbins:(408) 538-2358:155:90:201 Susan Dalsass:(206) 654-6279:250:60:50 (There are 12 contribuors total) This database contains names, phone... (1 Reply)
Discussion started by: NewbieGirl
1 Replies
Login or Register to Ask a Question