Sponsored Content
Top Forums Shell Programming and Scripting sort with different delimiters Post 302579360 by oldman2 on Monday 5th of December 2011 01:42:00 PM
Old 12-05-2011
sort with different delimiters

I have a file with the following lines in it:
Code:
Inbound1:remote - - 01/Nov/2011:08:29:51 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound1:remote - - 02/Dec/2011:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound3:remote - - 01/Oct/2011:08:29:52 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound4:remote - - 02/Oct/2011:08:29:52 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound5:remote - - 01/Dec/2010:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound6:remote - - 01/Dec/2011:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound7:remote - - 01/Oct/2011:08:20:21 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound9:remote - - 02/Nov/2011:08:29:51 -0500 "GET / HTTP/1.1" 404 2098 HTTP

I would like to sort the file by the date and time oldest first:
(Example of how I would like to see the output)
Code:
Inbound5:remote - - 01/Dec/2010:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound7:remote - - 01/Oct/2011:08:20:21 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound3:remote - - 01/Oct/2011:08:29:52 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound1:remote - - 01/Nov/2011:08:29:51 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound6:remote - - 01/Dec/2011:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound4:remote - - 02/Oct/2011:08:29:52 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound9:remote - - 02/Nov/2011:08:29:51 -0500 "GET / HTTP/1.1" 404 2098 HTTP
Inbound1:remote - - 02/Dec/2011:08:31:42 -0500 "GET / HTTP/1.1" 404 2098 HTTP

The different delimiters (space, slash, and colon) has me confused on how I could use the sort (AIX ksh) command. Anyone have any suggestions on how I can sort it?
Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 12-05-2011 at 03:41 PM.. Reason: code tags, please!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delimiters missing

Hi I have a pipe-delimited file where I eventually need to replace a string stored on the 3th field on a specific record. This is how the file looks like: A|Mike|Lvl 1|... B|... A|Maria|Lvl 1|... C|... B|... A|Jimmy|Lvl 2|... C|... A|Carry|Lvl 0|... C|... B|... A|John|Lvl 8|...... (2 Replies)
Discussion started by: Indalecio
2 Replies

2. Solaris

To extract everything between two delimiters

My input file looks like " @$SCRIPT/atp_asrmt_adj.sql $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1005w.pls $SCRIPT/dba2000.scr -s / @$SCRIPT/cim1006w.pls start $SCRIPT/cim1020d.sql;^M spool $DATA/cim1021m.sql @$DATA/cim1021m.sql ! rm $DATA/cim1021m.sql spool $DATA/cim1021m.sql... (1 Reply)
Discussion started by: dowsed4u8
1 Replies

3. Shell Programming and Scripting

Problems with delimiters

Hello, I have data in a file something like this - UNB+UNOA:1+006415160:1+AR0000012360:ZZ+080701:0552+2++DELFOR++++T'UNH+2+DELFOR:D:97A:UN Here, the delimiters used are + , : and ' . I have a set of such files in which these delimiters vary from one file to another. I am developing a... (4 Replies)
Discussion started by: The Observer
4 Replies

4. Shell Programming and Scripting

How to Sort Floating Numbers Using the Sort Command?

Hi to all. I'm trying to sort this with the Unix command sort. user1:12345678:3.5:2.5:8:1:2:3 user2:12345679:4.5:3.5:8:1:3:2 user3:12345687:5.5:2.5:6:1:3:2 user4:12345670:5.5:2.5:5:3:2:1 user5:12345671:2.5:5.5:7:2:3:1 I need to get this: user3:12345687:5.5:2.5:6:1:3:2... (7 Replies)
Discussion started by: daniel.gbaena
7 Replies

5. Shell Programming and Scripting

Split using two delimiters

I'm trying to do a split using two delimiters. The first delimiter is ": " (or we could call it :\s). The second is "\n". How can or these delimiters so I can toss the values into an array without issue? I tried @array = split /:\s|\n/, $myvar; This doesn't seem to be working. Any an... (3 Replies)
Discussion started by: mrwatkin
3 Replies

6. UNIX for Advanced & Expert Users

Script to sort the files and append the extension .sort to the sorted version of the file

Hello all - I am to this forum and fairly new in learning unix and finding some difficulty in preparing a small shell script. I am trying to make script to sort all the files given by user as input (either the exact full name of the file or say the files matching the criteria like all files... (3 Replies)
Discussion started by: pankaj80
3 Replies

7. Shell Programming and Scripting

Help with sort word and general numeric sort at the same time

Input file: 100%ABC2 3.44E-12 USA A2M%H02579 0E0 UK 100%ABC2 5.34E-8 UK 100%ABC2 3.25E-12 USA A2M%H02579 5E-45 UK Output file: 100%ABC2 3.44E-12 USA 100%ABC2 3.25E-12 USA 100%ABC2 5.34E-8 UK A2M%H02579 0E0 UK A2M%H02579 5E-45 UK Code try: sort -k1,1 -g -k2 -r input.txt... (2 Replies)
Discussion started by: perl_beginner
2 Replies

8. Shell Programming and Scripting

Sort help: How to sort collected 'file list' by date stamp :

Hi Experts, I have a filelist collected from another server , now want to sort the output using date/time stamp filed. - Filed 6, 7,8 are showing the date/time/stamp. Here is the input: #---------------------------------------------------------------------- -rw------- 1 root ... (3 Replies)
Discussion started by: rveri
3 Replies

9. Shell Programming and Scripting

Inserting Delimiters

Hi Team, I am trying to get the data in below format Jan 01 | 19:00:32 | xyz | abc | sometext | string however I am not sure of the total number strings which can come in the record hence i cant use something like below as it can end $6 or it can go further cat file| awk... (8 Replies)
Discussion started by: rakesh_411
8 Replies

10. Shell Programming and Scripting

Delimiters with awk?

I have a file which is separated by delimiter "|", but the prob is one of my column do contain delimiter as description so how can i differentiate it? PS : the delmiter does have backslash coming before it, if occurring in column Annual|Beleagured|Desc|Denver... (2 Replies)
Discussion started by: nikhil jain
2 Replies
ppmtosixel(1)						      General Commands Manual						     ppmtosixel(1)

NAME
ppmtosixel - convert a portable pixmap into DEC sixel format SYNOPSIS
ppmtosixel [-raw] [-margin] [ppmfile] DESCRIPTION
Reads a portable pixmap as input. Produces sixel commands (SIX) as output. The output is formatted for color printing, e.g. for a DEC LJ250 color inkjet printer. If RGB values from the PPM file do not have maxval=100, the RGB values are rescaled. A printer control header and a color assignment table begin the SIX file. Image data is written in a compressed format by default. A printer control footer ends the image file. OPTIONS
-raw If specified, each pixel will be explicitly described in the image file. If -raw is not specified, output will default to com- pressed format in which identical adjacent pixels are replaced by "repeat pixel" commands. A raw file is often an order of magni- tude larger than a compressed file and prints much slower. -margin If -margin is not specified, the image will be start at the left margin (of the window, paper, or whatever). If -margin is speci- fied, a 1.5 inch left margin will offset the image. PRINTING
Generally, sixel files must reach the printer unfiltered. Use the lpr -x option or cat filename > /dev/tty0?. BUGS
Upon rescaling, truncation of the least significant bits of RGB values may result in poor color conversion. If the original PPM maxval was greater than 100, rescaling also reduces the image depth. While the actual RGB values from the ppm file are more or less retained, the color palette of the LJ250 may not match the colors on your screen. This seems to be a printer limitation. SEE ALSO
ppm(5) AUTHOR
Copyright (C) 1991 by Rick Vinci. 26 April 1991 ppmtosixel(1)
All times are GMT -4. The time now is 01:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy