Sponsored Content
Full Discussion: date time stamps in bash
Top Forums Shell Programming and Scripting date time stamps in bash Post 302714991 by justbow on Saturday 13th of October 2012 12:27:08 PM
Old 10-13-2012
Code:
~]$ TZ=PDT date +"%d/%m/%y %H:%M:%S:%s %Z"
13/10/12 16:23:40:1350145420 PDT

you may also can use TZ as time zone

Last edited by justbow; 10-13-2012 at 01:29 PM.. Reason: quote
This User Gave Thanks to justbow For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

List files with date and time stamps only

Hi there, I'm using terminal on mac and using the ls -l command to list all the files in a directory. However, I only want to display the date and time stamp of each file rather than permissions, owner, group etc... Is this possible? Many thanks in advance Dave (2 Replies)
Discussion started by: davewg
2 Replies

2. UNIX for Dummies Questions & Answers

Adding Date & time stamps to filename

I need to edit the file name with date and time while writing the script. please help. (1 Reply)
Discussion started by: manish.s
1 Replies

3. UNIX for Dummies Questions & Answers

comparing time stamps

Hello All, I'm generating timestamps (file creation timestamps) for all the files in a directory. I need to compare all the timestamps. for example if i have 4 files and their timestamps are 20091125114556, 20091125114556,20091125114556,20091125114556 respectively. I need to differentiate... (1 Reply)
Discussion started by: RSC1985
1 Replies

4. Shell Programming and Scripting

comparing time stamps

Hello All, I'm generating timestamps (file creation timestamps) for all the files in a directory. I need to compare all the timestamps. for example if i have 4 files and their timestamps are 20091125114556, 20091125114556,20091125114556,20091125114556 respectively. I need to differentiate... (9 Replies)
Discussion started by: RSC1985
9 Replies

5. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies

6. Shell Programming and Scripting

Time difference between two time stamps

Hi Friends, I have 2 varaibles which contain START=`date '+ %m/%d/%y %H:%M:%S'` END=`date '+ %m/%d/%y %H:%M:%S'` i want the time difference between the two variables in Seconds. Plz help. (2 Replies)
Discussion started by: i150371485
2 Replies

7. Shell Programming and Scripting

Increment time stamps.

Hi Gents. Please can you help me to solve a problem. I have a long list of files, which I need to change the time stamp. -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000009.segd -r--r--r-- 1 geo2 geovect 47096216 Feb 8 10:40 00000010.segd -r--r--r-- 1 geo2 geovect 47096216 Feb ... (11 Replies)
Discussion started by: jiam912
11 Replies

8. Shell Programming and Scripting

How to get the Logs between two Time Stamps?

Hi, I have been working on the error Log script, where errors are pulled from server. I need to pull the data of the error logs between two dates & time, for example : 22/12/2014 20:00:00 22/12/2014 22:00:00 Whatever error have came during this duration. Now the question is the record... (6 Replies)
Discussion started by: amitgpta90
6 Replies

9. Shell Programming and Scripting

Controlling time stamps in a bash script

Hi, I have a bash script that generates CSV (.txt) files at fairly regular time intervals. I'm currently time stamping each batch of measurements at the time I write the rows into a MySQL database. As the result, one set of data might get the time 12:01:32 and the next set of data gets the time... (18 Replies)
Discussion started by: Zooma
18 Replies

10. Windows & DOS: Issues & Discussions

Cygwin_openssh time stamps

I've installed cygwin_openssh on Windows 2012 R2 and it's working great. My issue is when a file is uploaded say from a different timezone, when it is uploaded, it doesnt pick up the sftp servers time.. Is there a way to fix that? i.e. When someone in PST uploads a file to this server in EST,... (0 Replies)
Discussion started by: MikeAdkins
0 Replies
TCPSLICE(8)						      System Manager's Manual						       TCPSLICE(8)

NAME
tcpslice - extract pieces of and/or glue together tcpdump files SYNOPSIS
tcpslice [ -dRrt ] [ -w file ] [ start-time [ end-time ] ] file ... DESCRIPTION
Tcpslice is a program for extracting portions of packet-trace files generated using tcpdump(1)'s -w flag. It can also be used to glue together several such files, as discussed below. The basic operation of tcpslice is to copy to stdout all packets from its input file(s) whose timestamps fall within a given range. The starting and ending times of the range may be specified on the command line. All ranges are inclusive. The starting time defaults to the time of the first packet in the first input file; we call this the first time. The ending time defaults to ten years after the starting time. Thus, the command tcpslice trace-file simply copies trace-file to stdout (assuming the file does not include more than ten years' worth of data). There are a number of ways to specify times. The first is using Unix timestamps of the form sssssssss.uuuuuu (this is the format specified by tcpdump's -tt flag). For example, 654321098.7654 specifies 38 seconds and 765,400 microseconds after 8:51PM PDT, Sept. 25, 1990. All examples in this manual are given for PDT times, but when displaying times and interpreting times symbolically as discussed below, tcp- slice uses the local timezone, regardless of the timezone in which the tcpdump file was generated. The daylight-savings setting used is that which is appropriate for the local timezone at the date in question. For example, times associated with summer months will usually include daylight-savings effects, and those with winter months will not. Times may also be specified relative to either the first time (when specifying a starting time) or the starting time (when specifying an ending time) by preceding a numeric value in seconds with a `+'. For example, a starting time of +200 indicates 200 seconds after the first time, and the two arguments +200 +300 indicate from 200 seconds after the first time through 500 seconds after the first time. Times may also be specified in terms of years (y), months (m), days (d), hours (h), minutes (m), seconds (s), and microseconds(u). For example, the Unix timestamp 654321098.7654 discussed above could also be expressed as 90y9m25d20h51m38s765400u. When specifying times using this style, fields that are omitted default as follows. If the omitted field is a unit greater than that of the first specified field, then its value defaults to the corresponding value taken from either first time (if the starting time is being specified) or the starting time (if the ending time is being specified). If the omitted field is a unit less than that of the first speci- fied field, then it defaults to zero. For example, suppose that the input file has a first time of the Unix timestamp mentioned above, i.e., 38 seconds and 765,400 microseconds after 8:51PM PDT, Sept. 25, 1990. To specify 9:36PM PDT (exactly) on the same date we could use 21h36m. To specify a range from 9:36PM PDT through 1:54AM PDT the next day we could use 21h36m 26d1h54m. Relative times can also be specified when using the ymdhmsu format. Omitted fields then default to 0 if the unit of the field is greater than that of the first specified field, and to the corresponding value taken from either the first time or the starting time if the omitted field's unit is less than that of the first specified field. Given a first time of the Unix timestamp mentioned above, 22h +1h10m speci- fies a range from 10:00PM PDT on that date through 11:10PM PDT, and +1h +1h10m specifies a range from 38.7654 seconds after 9:51PM PDT through 38.7654 seconds after 11:01PM PDT. The first hour of the file could be extracted using +0 +1h. Note that with the ymdhmsu format there is an ambiguity between using m for `month' or for `minute'. The ambiguity is resolved as follows: if an m field is followed by a d field then it is interpreted as specifying months; otherwise it specifies minutes. If more than one input file is specified then tcpslice first copies packets lying in the given range from the first file; it then increases the starting time of the range to lie just beyond the timestamp of the last packet in the first file, repeats the process with the second file, and so on. Thus files with interleaved packets are not merged. For a given file, only packets that are newer than any in the pre- ceding files will be considered. This mechanism avoids any possibility of a packet occurring more than once in the output. OPTIONS
If any of -R, -r or -t are specified then tcpslice reports the timestamps of the first and last packets in each input file and exits. Only one of these three options may be specified. -d Dump the start and end times specified by the given range and exit. This option is useful for checking that the given range actu- ally specifies the times you think it does. If one of -R, -r or -t has been specified then the times are dumped in the correspond- ing format; otherwise, raw format ( -R) is used. -R Dump the timestamps of the first and last packets in each input file as raw timestamps (i.e., in the form sssssssss.uuuuuu). -r Same as -R except the timestamps are dumped in human-readable format, similar to that used by date(1). -t Same as -R except the timestamps are dumped in tcpslice format, i.e., in the ymdhmsu format discussed above. -w Direct the output to file rather than stdout. SEE ALSO
tcpdump(1) AUTHORS
The original author was: Vern Paxson, of Lawrence Berkeley Laboratory, University of California, Berkeley, CA. It is currently being maintained by tcpdump.org. The current version is available in the ``tcpslice'' module of the CVS tree at tcpdump.org; see the tcpdump.org home page at http://www.tcpdump.org/ for information on anonymous CVS access. The original distribution is available via anonymous ftp: ftp://ftp.ee.lbl.gov/tcpslice.tar.Z BUGS
Please send problems, bugs, questions, desirable enhancements, etc. to: tcpdump-workers@tcpdump.org Please send source code contributions, etc. to: patches@tcpdump.org An input filename that beings with a digit or a `+' can be confused with a start/end time. Such filenames can be specified with a leading `./'; for example, specify the file `04Jul76.trace' as `./04Jul76.trace'. tcpslice cannot read its input from stdin, since it uses random-access to rummage through its input files. tcpslice refuses to write to its output if it is a terminal (as indicated by isatty(3)). This is not a bug but a feature, to prevent it from spraying binary data to the user's terminal. Note that this means you must either redirect stdout or specify an output file via -w. tcpslice will not work properly on tcpdump files spanning more than one year; with files containing portions of packets whose original length was more than 65,535 bytes; nor with files containing fewer than three packets. Such files result in the error message: `couldn't find final packet in file'. These problems are due to the interpolation scheme used by tcpslice to greatly speed up its processing when dealing with large trace files. Note that tcpslice can efficiently extract slices from the middle of trace files of any size, and can also work with truncated trace files (i.e., the final packet in the file is only partially present, typically due to tcpdump being ungracefully killed). 21 December 1996 TCPSLICE(8)
All times are GMT -4. The time now is 10:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy