01-18-2013
-F\| - records are split at |
_1 = $1 - save $1 into a variable because we need to modify it
sub(/[^ ]+ */, x, _1) - strip the leading part of the string currently in _1 (the part before and including the white space characters)
print _1, NR, $0 - for every record: print the modified value of _1, the current record number and the actual record
OFS=_ - set the output field separator to a custom string for easy manipulation with cut
Now the records are easy to sort: first by timestamp and by record number.
Last edited by radoulov; 01-18-2013 at 10:53 AM..
This User Gave Thanks to radoulov For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Here is an answer rather than a question that I thought I would share.
In my first attempt, I was using grep to find a list from file.1 within another file, file.2 which I then needed to paste the output from file.3 to file.1 in the same order. However, the results weren't what I wanted.
At... (2 Replies)
Discussion started by: Kelam_Magnus
2 Replies
2. Shell Programming and Scripting
Dear All,
I have the followoing requirement..
REQ-1:
Suppose I have the following files
XX_20070202000101.zip
XX_20080223000101.zip
XX_20080226000101.zip
XX_20080227000101.zip
XX_20080228000101.zip
XX_20080229000101.zip
Suppose sysdate = 29 Feb 2007
I need to delete all files... (3 Replies)
Discussion started by: sureshg_sampat
3 Replies
3. UNIX for Advanced & Expert Users
how to copy lines from a log file based on timestamp.
INFO (RbrProcessFlifoEventSessionEJB.java:processFlight:274) - E_20080521_110754_967: rbrAciInfoObjects listing complete!
INFO (RbrPnrProcessEventSessionEJB.java:processFlight:197) - Event Seq: 1647575217; Carrier: UA; Flt#: 0106; Origin:... (1 Reply)
Discussion started by: ranjiadmin
1 Replies
4. Shell Programming and Scripting
Hi
I have a requirement like below
I need to sort the files based on the timestamp in the file name and run them in sorted order and then archive all the files which are one day old to temp directory
My files looks like this
PGABOLTXML1D_201108121235.xml... (1 Reply)
Discussion started by: saidutta123
1 Replies
5. UNIX for Dummies Questions & Answers
Hi Friends,
Newbie to shell scripting
Currently i have used the below to sort data based on filenames and datestamp
$ printf '%s\n' *.dat* | sort -t. -k3,4
filename_1.dat.20120430.Z
filename_2.dat.20120430.Z
filename_3.dat.20120430.Z
filename_1.dat.20120501.Z
filename_2.dat.20120501.Z... (12 Replies)
Discussion started by: robertbrown624
12 Replies
6. Shell Programming and Scripting
I have a file in which the data is stored in pairs of lines. The first line (beginining with ">") is a header, the second line is a sequence.
I would like to sort the file by species name. Desired output for the example file:
I can use
sort -t'_' -k2
to alphabetize headers in the... (1 Reply)
Discussion started by: pathunkathunk
1 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I have requirement to list out files that are created after particular file.
ex. I have below files in my directory. I want to display files created after /dirdat/CG1/cg004440 file.
./dirdat/CG1/cg004438 09/07/14 0:44:05
./dirdat/CG1/cg004439 09/07/14 6:01:48 ... (3 Replies)
Discussion started by: tmalik79
3 Replies
8. Shell Programming and Scripting
Hi
I need to order these lines from a txt file my file looks like this
IMSI ........................ 1234567890
APN ......................... INTERNET.COM
APN ......................... MMS.COM
APN ......................... WAP.COM
APN ......................... BA.COM
IMSI... (4 Replies)
Discussion started by: alone77
4 Replies
9. Shell Programming and Scripting
Hi ,
I did the initial search but could not find what I was expecting for.
15606Always_9999999997_20160418.xml
15606Always_9999999998_20160418.xml
15606Always_9999999999_20160418.xml
9819Always_99999999900_20160418.xml
9819Always_99999999911_20160418.xmlAbove is the list of files I... (4 Replies)
Discussion started by: chillblue
4 Replies
10. UNIX for Beginners Questions & Answers
Dear Experts,
I have a log file that contains a timestamp, I would like to filter record from that file based on timestamp. For example refer below file -
cat sample.txt
Jan 19 20:51:48 mukul-Vostro-14-3468 systemd: pam_unix(systemd-user:session): session opened for user root by (uid=0)... (6 Replies)
Discussion started by: mukulverma2408
6 Replies
LEARN ABOUT ULTRIX
dwtresolvepartoffsets
DwtResolvePartOffsets(3Dwt) DwtResolvePartOffsets(3Dwt)
Name
DwtResolvePartOffsets - Allows writing of upward-compatible applications and widgets.
Syntax
void DwtResolvePartOffsets(widget_class, offset)
WidgetClass widget_class;
DwtOffsetPtr *offset;
Arguments
widget_class
Specifies the widget class pointer for the created widget.
offset Specifies the offset record.
Description
The use of offset records requires one extra global variable per widget class. The variable consists of a pointer to an array of offsets
into the widget record for each part of the widget structure. The DwtResolvePartOffsets function allocates the offset records needed by an
application to guarantee upward-compatible applications and widgets. These offset records are used by the widget to access all of the wid-
get's variables. A widget needs to take the following steps:
o Instead of creating a resource list, the widget creates an offset resource list. To help you accomplish this, use the DwtPartResource
structure and the DwtPartOffset macro. The DwtPartResource data structure looks just like a resource list, but instead of having one
integer for its offset, it has two shorts. This gets put into the class record as if it were a normal resource list. Instead of
using XtOffset for the offset, it uses DwtPartOffset.
o Instead of putting the widget size in the class record, the widget puts the widget part in the same field.
o Instead of putting XtVersion in the class record, the widget puts XtVersionDontCheck in the class record.
o The widget defines a variable to point to the offset record. This can be part of the widget's class record or a separate global vari-
able.
o In class initialization, the widget calls DwtResolvePartOffsets, passing it the offset address and the class record. This does sev-
eral things:
o Adds the superclass (which, by definition, has already been initialized) size field to the part size field.
o Allocates an array based upon the number of superclasses.
o Fills in the offsets of all the widget parts with the appropriate values, determined by examining the size fields of all super-
class records.
o Uses the part offset array to modify the offset entries in the resource list to be real offsets, in place.
o Instead of accessing fields directly, the widget must always go through the offset table. You will probably define macros for each
field to make this easier. Assume an integer field ``xyz'':
#define BarXyz(w) (*(int *)(((char *) w) + offset[BarIndex] +
XtOffset(BarPart,xyz)))
The DwtField macro helps you access these fields. Because the DwtPartOffset and DwtField macros concatenate arguments, you must
ensure there is no space before or after the part argument. For example, the following do not work because of the space before or
after the part (Label) argument:
DwtField(w, offset, Label, text, char *)
DwtPartOffset( Label, text).
Therefore, you must not have any spaces before or after the part (Label) argument, as illustrated here:
DwtField(w, offset,Label, text, char *)
See Also
Guide to the XUI Toolkit: C Language Binding
Guide to the XUI Toolkit Intrinsics: C Language Binding
DwtResolvePartOffsets(3Dwt)