Sponsored Content
Top Forums Shell Programming and Scripting Getting date in seconds with decimals Post 302716319 by Skrynesaver on Tuesday 16th of October 2012 07:40:15 AM
Old 10-16-2012
Code:
printf "%0.2f\n" $(date +%s.%N)
1350386830.08

The %N nanosecond format is just the nanosecond offset, it is formatted output rather than a precision flag
This User Gave Thanks to Skrynesaver For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

how to get the milli seconds from date in sun unix

hi all how do we get the milli seconds in sun unix? i am using date +%Y%m%d%H%M%S to get the unique id and create the file based on this. but the problem is that if process to load the table takes only less than 1 sec i am getting errror on my table which have the primary key. how... (2 Replies)
Discussion started by: r2b
2 Replies

2. Shell Programming and Scripting

how to get the milli seconds from date in sun unix

hi all how do we get the milli seconds in sun unix? i am using date +%Y%m%d%H%M%S to get the unique id and create the file based on this. but the problem is that if process to load the table takes only less than 1 sec i am getting errror on my table which have the primary key. how... (1 Reply)
Discussion started by: r2b
1 Replies

3. HP-UX

a simple way of converting a date in seconds to normal date

Hi all! I'm working on a HPUX system, and I was wondering if there is a simple way to convert a date from seconds (since 1970) to a normal date. Thanks (2 Replies)
Discussion started by: travian
2 Replies

4. Shell Programming and Scripting

convert Regular decimals to Packed decimals

Hi, I am trying to find if there is a way to convert regular decimal values to Paced decimal values. I tried to find a c program but I could get a Packed converted to regular decimal not the other way round. If not unix please let me know if any other progrimming language I can use to do... (2 Replies)
Discussion started by: mgirinath
2 Replies

5. Shell Programming and Scripting

Converting past date to seconds

Need a little help developing a ksh script. Have read through Perderabo's datecalc routine and it does not seem to fit the function I am looking for. Basically what I am trying to do is find any file (in a specific directory) that was created within the last five minutes. I am not a programming... (3 Replies)
Discussion started by: synergy_texas
3 Replies

6. UNIX for Dummies Questions & Answers

Current system date in terms of seconds

Hello Friends, I've been struggling with extreme nagios passive service checks. In order to trigger a nagios passive service im going to write an easy shell script like below and will run it in crontab. As im working on Solaris 10 servers i used "S" instead of lowercase "s" below #!/bin/sh... (2 Replies)
Discussion started by: EAGL€
2 Replies

7. Shell Programming and Scripting

Date format in micro seconds

Can i get date format in micro seconds in unix example 2012-01-27- 12.22.04.568722 Any help is appreciable (2 Replies)
Discussion started by: srichunduru
2 Replies

8. Shell Programming and Scripting

Change the seconds value in date column

Hello, I have a file with below contents and need to set seconds value to 00 (as you can see few time stamps are with 01 seconds) 18:16:00 8192 7301 89 11 18:21:00 8192 7305 89 11 18:26:00 8192 7306 89 11 18:31:00 8192 7306 ... (6 Replies)
Discussion started by: reddyr
6 Replies

9. Shell Programming and Scripting

Regex match date and seconds format

Hi $ awk '{print $1," ",$4}' access.log | sort | uniq -c| sort -nr | head -n20 62 192.168.10.6 How can get the result like 62, 192.168.10.6, 14:40 62, 192.168.10.32, 47:57 I tried modifying - $ awk '{print $1," ",$4}' access.log | sort | uniq -c| sort -nr | head -n20 | awk... (3 Replies)
Discussion started by: ashokvpp
3 Replies

10. Shell Programming and Scripting

Subtract Seconds from Date Command

Hi, Need to subtract 5 seconds after syncing my Linux server from NTP like; #ntpdate time.myorg.int. This script will only run once in each morning at 9 AM. Please help me. (4 Replies)
Discussion started by: refra
4 Replies
nl_printf(3int) 														   nl_printf(3int)

Name
       nl_printf, nl_fprintf, nl_sprintf - print formatted output

Syntax
       #include <stdio.h>

       int nl_printf ( format [, arg ] ...  )
       char *format;

       int nl_fprintf ( stream, format [, arg ] ...  )
       FILE *stream;
       char *format;

       int nl_sprintf ( s, format [, arg ] ...	)
       char *s, format;

Description
       The  international  functions and are identical to and have been superceded by the international functions and in a library. You should use
       the and functions when you write new calls to print formatted output in an international program. For more information on these	functions,
       see the reference page.

       You  can  continue  to use existing calls to the or international functions.  These functions remain available for compatibility with XPG-2
       conformant software, but may not be supported in future releases of the ULTRIX system.

       The and international functions are similar to the standard I/O function. (For more information about the standard I/O  function,  see  the
       reference  page.)   The	difference is that the international functions allow you to use the I%digit$ conversion sequence in place of the %
       character you use in the standard I/O functions. The digit is a decimal digit n from 1 to 9.  The international functions apply conversions
       to the n th argument in the argument list, rather than to the next unused argument.

       You  can  use  %  conversion character in the international functions.  However, you cannot mix the % conversion character with the %digit$
       conversion sequence in a single call.

       You can indicate a field width or precision by an asterisk (*), instead of a digit string, in strings containing the %  conversion  charac-
       ter.  If  you  use  an asterisk, you can supply an integer argument that specifies the field width or precision.  In strings containing the
       %digit$ conversion character, you can indicate field width or precision by the sequence *digit$.  You use a decimal digit from 1  to  9	to
       indicate which argument contains an integer that specifies the field width or precision.

       The conversion characters and their meanings are identical to

       You must use each digit argument at least once.	The results of not using an argument are undefined.

   International Environment
       LC_NUMERIC     If  this	environment  is set and valid, uses the international language database named in the definition to determine radix
		      character rules.

       LANG	      If this environment variable is set and valid uses the international language database named in the definition to  determine
		      collation and character classification rules.  If is defined, its definition supercedes the definition of LANG.

Examples
       The following example illustrates using an argument to specify field width:
       nl_printf ("%1$d:%2$.*3$d:%4$.*3$d
",
			   hour, min, precision, sec);
       The format string *3$ indicates that the third argument, which is named precision, contains the integer field width specification.

       To print the language independent date and time format, use the following statement:
       nl_printf (format, weekday, month, day, hour, min);
       For United States of America use, could be a pointer to the following string:
       "%1$s,  %2$s %3$d, %4$d:%5$.2d
"
       This string produces the following message:
       Sunday, July 3, 10:02
       For use in a German environment, could be a pointer to the following string:
       "%1$s, %3$d. %2$s, %4$d:%5$.2d
"
       This produces the following message:
       Sonntag, 3. Juli, 10:02

See Also
       intro(3int), setlocale(3), nl_scanf(3int), printf(3int), scanf(3int), printf(3s), putc(3s), scanf(3s), stdio(3s)
       Guide to Developing International Software

																   nl_printf(3int)
All times are GMT -4. The time now is 09:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy