Sponsored Content
Top Forums UNIX for Advanced & Expert Users merging multiple timestamps into one Post 302172441 by jim mcnamara on Monday 3rd of March 2008 05:16:40 PM
Old 03-03-2008
I see one problem at least. There are limits to filename length on a lot of unix filesystems.
If you have more than two files, you could start getting in trouble. Some filesystems may be okay. I dunno what filesystems you have.

That said, try something this ksh script:
Code:
#!/bin/ksh
set -A arr test*
cat ${arr[*]} > tmpfile
newname="test"
for i in test*
do
     t1=${i#test}
     t2=${t1%.txt}
     newname=$newname"_$t2"
done
newname=$newname".txt"
mv tmpfile $newname

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

merging multiple log files

Hello, I have 8 sql loader scripts which produce ".bad" file if there is any errors, how can I join the contents of these files together in one column? file 1 CA-94061-TSS Tkb Sport Shop CA-95133-V Vollyrite ... (3 Replies)
Discussion started by: jack1981
3 Replies

2. Shell Programming and Scripting

Merging columns from multiple files in one file

Hi, I want to select columns from multiple files and combine them in one file. The files are simulation-data-files with 23 columns each and about 50 rows. I now use: cut -f 11 Sweep?wing-30?scale=0.?0?fan2?.txt | pr -3 | awk '{printf("\n%s\t%s\t%s",$1,$2,$3)}' > ../Data_Processed/output.txtI... (1 Reply)
Discussion started by: isgoed
1 Replies

3. UNIX for Advanced & Expert Users

Merging multiple .so files

Hi All, How to merge independent .so files into an executable. Thanks in Advance, Regards, Kusu (2 Replies)
Discussion started by: Kusu
2 Replies

4. Shell Programming and Scripting

Merging columns from multiple files

Hello, I have a number of tab delimited data files consists of two columns. Like that: File1 800.000000 0.002744 799.000000 0.002517 798.000000 0.002836 797.000000 0.002553 FIle2 800.000000 0.000261 799.000000 0.000001 798.000000 0.000551 797.000000 0.000275 File3... (19 Replies)
Discussion started by: erden
19 Replies

5. Shell Programming and Scripting

Bash script to copy timestamps of multiple files

Hi, I have a bunch of media files in a directory that have been converted (from MTS to MOV format), so my directory contains something like this: clip1.mts clip1.mov clip2.mts clip2.mov The problem is that the .mov files that have been created have the timestamps of the conversion task,... (2 Replies)
Discussion started by: Krakus
2 Replies

6. Shell Programming and Scripting

Merging multiple files from multiple columns

Hi guys, I have very basic linux experience so I need some help with a problem. I have 3 files from which I want to extract columns based on common fields between them. File1: --- rs74078040 NA 51288690 T G 461652 0.99223 0.53611 3 --- rs77209296 NA 51303525 T G 461843 0.98973 0.60837 3... (10 Replies)
Discussion started by: bartman2099
10 Replies

7. Shell Programming and Scripting

Perl - multiple keys and merging two files

Hi, I'm not a regular coder but some times I write some basic perl script, hence Perl is bit difficult for me :). I'm merging two files a.txt and b.txt into c.txt: a.txt ------ x001;frtb70;xyz;109 x001;frvt65;sec;239 x003;wqax34;jul;659 x004;yhud43;yhn;760 b.txt ------... (8 Replies)
Discussion started by: Lokesha
8 Replies

8. Shell Programming and Scripting

Merging Multiple Columns between two files

Hello guys, I have 2 CSV files which goes like this: CSV1: Breaking.csv: UTF-8 "Name","Description","Occupation","Email" "Walter White","","Chemistry Teacher","w.w@bb.com" "Jessie Pinkman","","Junkie","j.p@bb.com" "Hank Schrader","","DEA Agent","h.s@bb.com" CSV2: Bad.csv... (7 Replies)
Discussion started by: jeffreybsu
7 Replies

9. Shell Programming and Scripting

Merging multiple files into one

Hi guys, could you please help me with this? I have multiple files with this structure: file1 xxx1 1.0 xxx2 3.5 xxx3 2.4 xxx4 3.0 … xxx1890 5.7 file2 xxx1 8.0 xxx3 7.5 xxx4 5.5 …. (4 Replies)
Discussion started by: coppuca
4 Replies

10. Shell Programming and Scripting

Merging multiple lines

I do have a text file with multiple lines on it. I want to put the lines of text into a single line where ever there is ";" for example ert, ryt, yvig, fgr; rtyu, hjk, uio, hyu, hjo; ghj, tyu, gho, hjp, jklo, kol; The resultant file I would like to have is ert, ryt, yvig, fgr;... (2 Replies)
Discussion started by: Kanja
2 Replies
TCPSLICE(1)						      General Commands Manual						       TCPSLICE(1)

NAME
tcpslice - extract pieces of and/or merge together tcpdump files SYNOPSIS
tcpslice [ -DdlRrt ] [ -w file ] [ start-time [ end-time ] ] file ... DESCRIPTION
Tcpslice is a program for extracting portions of packet-trace files generated using tcpdump(l)'s -w flag. It can also be used to merge 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 earliest time of the first packet in any of the input files; 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 1990y9m25d20h51m38s765400u. 2 or 4 digit years may be used; 2 digits can specify years from 1970 to 2069. 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 merges the packets from the various input files into the single output file. Nor- mally, this merge is done based on the value of the timestamps in the packets in the individual files. (Tcpslice assumes that within each input file, packets are in timestamp order.) If the -l option is used, the value used for ordering is the timestamp of a given packet minus the timestamp of the first packet in the input file in which the given packet occurs. When merging files, by default tcpslice will discard any duplicate packet it finds in more than one file. A duplicate is a packet that has an identical timestamp (either relative or absolute) and identical packet contents (for as much as was captured) as another packet previ- ously seen in a different file. Note that it is possible for the network to generate true replicates of packets, and for systems that can return the same timestamp for multiple packets, these can be mistaken for duplicates and discarded. Accordingly, tcpslice will not discard duplicates in the same trace file. In addition, you can use the -D option to suppress any discarding of duplicates. A different issue arises if a file contains timestamps that skip backwards. tcpslice will include these in the output, even if they pre- cede the minimum time requested. There should probably be an option to suppress these. Another problem relating to backwards timestamps is that tcpslice uses random access to seek through a file looking for packets correspond- ing to the desired range of time. While doing so leads to a major performance benefit for very large trace files, it also means that in the presence of backwards timestamps tcpslice can fail to find the true earliest occurrence of a packet matching the time interval crite- ria. There should probably be an option to specify not to use random access but just read the file linearly. 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 Do not discard duplicate packets seen when merging multiple trace files. -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. -l When merging more than one file, merge on the basis of relative time, rather than absolute time. Normally, when merging files is done, packets are merged based on absolute timestamps. With -l packets are merged based on the relative time between the start of the file in which the packet is found and the timestamp of the packet itself. The timestamp of packets in the output file is calcu- lated as the relative time for the packet within its file plus first time. -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(l) AUTHOR
Vern Paxson, of Lawrence Berkeley Laboratory, University of California, Berkeley, CA. The current version is available via anonymous ftp: ftp://ftp.ee.lbl.gov/tcpslice.tar.Z BUGS
Please send bug reports to tcpslice@ee.lbl.gov. 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 two 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). Adding -l has broken some compatibility with older versions, since tcpslice now merges its input files, rather than (approximately) con- catenating them together as it did previously. It would sometimes be convenient if you could specify a clock offset to use with the -l option. It would be nice if tcpslice supported more general editing of trace files. 24 February 2000 TCPSLICE(1)
All times are GMT -4. The time now is 02:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy