Sponsored Content
Full Discussion: sort / cut question
Top Forums Shell Programming and Scripting sort / cut question Post 302126861 by BearCheese on Friday 13th of July 2007 03:39:02 PM
Old 07-13-2007
Thank you!
Now I have a file with the content like this:
20070711172841 905994
20070711172822 905994
20070711171431 906608
20070711171412 906608
20070711171142 905994
20070711171140 905994
20070711171139 905994
20070711164813 905994

I would like to keep only one line where the second column is the same. But that line should be the most lastest entry (timestamp in 1st coloumn).
I tried command:
sort -u -k 2,2
but this keeps the oldest timestamp Smilie

I tought that -u suppress everything but the first match. The first match (that should be kept) should be :
20070711172841 905994

but my command magically keeps the oldest line:
20070711164813 905994

Could you please advise on why -u does not work as anticipated?

Thank you!
BearCheese
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with Last,uniq, sort and cut

Using the last, uniq, sort and cut commands, determine how many times the different users have logged in. I know how to use the last command and cut command... i came up with last | cut -f1 -d" " | uniq i dont know if this is right, can someone please help me... thanks (1 Reply)
Discussion started by: jay1228
1 Replies

2. Shell Programming and Scripting

using cut command with sort

how to cut for pattern in the file and then count each occurance? say, each line has unique pattern and u want to grep but at last, you want to see how many of them occur? say, cut -d'\" -f15 filename | sort -? or.. do i need to use sed or something.. i need to count lets say how... (5 Replies)
Discussion started by: hankooknara
5 Replies

3. UNIX for Dummies Questions & Answers

cut question

#!/bin/bash echo "UserName PID Command" ps -ef > ps.temp grep '^\{2,3\}\{4\}' ps.temp > ps.temp2 cut -f1,2,8 ps.temp2 rm ps.temp* I am having some problems with the cut command. I only want to display the UID (field 1), PID(field 2), and Command(field 8). Right now the whole ps -ef... (5 Replies)
Discussion started by: knc9233
5 Replies

4. UNIX for Dummies Questions & Answers

Cut Question

Hi, I have created a variable abc within my script which can have values as follows abc = Ram,Iam or it can be abc = Uam or it can be abc = Sam,Tam,Pam Basically it can have a max of 3 values , seperated by comma. I want to assign these 3 values to 3 different variables In case of... (2 Replies)
Discussion started by: samit_9999
2 Replies

5. Solaris

concatenate/sort/cut

I have the following requirement. 1. I have to concatenate the 10 fixed width files. 2. sort based on first 10 characters 3. after that i have remove first 10 chacters from the file. can you please tell me how to do it. Thanks in Advance Samba (1 Reply)
Discussion started by: samba
1 Replies

6. UNIX for Dummies Questions & Answers

Using the Sort, Cut, and Awk commands

Hello, I am trying, utilizing the few commands I know, to extract all records within my file that were generated in November of 2007. Each record within the file has a "date" field giving the month, day, and year (9-8-88). How do I extract those records to their own file? Once I extract... (4 Replies)
Discussion started by: babbabooey
4 Replies

7. Homework & Coursework Questions

Help with cut and sort

<B>andan100:Anders:Andersson:800101-1234:TNCCC_1:TDDB46 TDDB80:berbe101:Bertil:Bertilsson:800102-1234:TNCCC_1:TDDB46 TDDB80:The top is how it looks right now I want it t look like this under and I want it to be sorted. I have tried with cut -f -d studenter.txt and so on but it still doesnt work... (2 Replies)
Discussion started by: aannaann
2 Replies

8. Shell Programming and Scripting

Using a combination of sort/cut/grep/awk/join/paste/sed

I have a file and need to only select users that have a shell of “/bin/bash” in the line using awk or sed please help (4 Replies)
Discussion started by: boyboy1212
4 Replies

9. UNIX for Advanced & Expert Users

cut and sort

Please help. I have a file containing rows of information. The row needs to be broken down into blocks of 5 and then sorted. Example: 10381 1042010046 ... (4 Replies)
Discussion started by: Dolph
4 Replies

10. UNIX for Dummies Questions & Answers

Question on cut

Korn Shell I have a file whose values are delimited using colon ( : ) $ cat test.txt hello:myde:temp:stiker $ cut -d: -f2,4 test.txt myde:stikerI want field 2 and field 4 to be returned but separated by a hyphen. The output should look like myde-stiker How can do this ? (without awk... (11 Replies)
Discussion started by: kraljic
11 Replies
svlogd(8)						      System Manager's Manual							 svlogd(8)

NAME
svlogd - runit's service logging daemon SYNOPSIS
svlogd [-tttv] [-r c] [-R xyz] [-l len] [-b buflen] logs DESCRIPTION
logs consists of one or more arguments, each specifying a directory. svlogd continuously reads log data from its standard input, optionally filters log messages, and writes the data to one or more automati- cally rotated logs. Recent log files can automatically be processed by an arbitrary processor program when they are rotated, and svlogd can be told to alert selected log messages to standard error, and through udp. svlogd runs until it sees end-of-file on standard input or is sent a TERM signal, see below. LOG DIRECTORY A log directory log contains some number of old log files, and the current log file current. Old log files have a file name starting with @ followed by a precise timestamp (see the daemontools' tai64n program), indicating when current was rotated and renamed to this file. A log directory additionally contains the lock file lock, maybe state and newstate, and optionally the file config. svlogd creates neces- sary files if they don't exist. If svlogd has trouble opening a log directory, it prints a warning, and ignores this log directory. If svlogd is unable to open all log directories given at the command line, it exits with an error. This can happen on start-up or after receiving a HUP signal. LOG FILE ROTATION svlogd appends selected log messages to the current log file. If current has size bytes or more (or there is a new-line within the last len of size bytes), or is older than a specified amount of time, current is rotated: svlogd closes current, changes permission of current to 0755, renames current to @timestamp.s, and starts with a new empty current. If svlogd sees num or more old log files in the log directory, it removes the oldest one. Note that this doesn't decrease the number of log files if there are already more than num log files, this must be done manually, e.g. for keeping 10 log files: ls -1 @* |sort |sed -ne '10,$p' |xargs rm PROCESSOR If svlogd is told to process recent log files, it saves current to @timestamp.u, feeds @timestamp.u through ``sh -c "processor"'' and writes the output to @timestamp.t. If the processor finishes successfully, @timestamp.t is renamed to @timestamp.s, and @timestamp.u is deleted; otherwise @timestamp.t is deleted and the processor is started again. svlogd also saves any output that the processor writes to file descriptor 5, and makes that output available on file descriptor 4 when running processor on the next log file rotation. A processor is run in the background. If svlogd sees a previously started processor still running when trying to start a new one for the same log, it blocks until the currently running processor has finished successfully. Only the HUP signal works in that situation. Note that this may block any program feeding its log data to svlogd. CONFIG On startup, and after receiving a HUP signal, svlogd checks for each log directory log if the configuration file log/config exists, and if so, reads the file line by line and adjusts configuration for log as follows: If the line is empty, or starts with a ``#'', it is ignored. A line of the form ssize sets the maximum file size of current when svlogd should rotate the current log file to size bytes. Default is 1000000. If size is zero, svlogd doesn't rotate log files. You should set size to at least (2 * len). nnum sets the number of old log files svlogd should maintain to num. If svlogd sees more that num old log files in log after log file rotation, it deletes the oldest one. Default is 10. If num is zero, svlogd doesn't remove old log files. Nmin sets the minimum number of old log files svlogd should maintain to min. min must be less than num. If min is set, and svlogd can- not write to current because the filesystem is full, and it sees more than min old log files, it deletes the oldest one. ttimeout sets the maximum age of the current log file when svlogd should rotate the current log file to timeout seconds. If current is time- out seconds old, and is not empty, svlogd forces log file rotation. !processor tells svlogd to feed each recent log file through processor (see above) on log file rotation. By default log files are not pro- cessed. ua.b.c.d[:port] tells svlogd to transmit the first len characters of selected log messages to the IP address a.b.c.d, port number port. If port isn't set, the default port for syslog is used (514). len can be set through the -l option, see below. If svlogd has trouble send- ing udp packets, it writes error messages to the log directory. Attention: logging through udp is unreliable, and should be used in private networks only. Ua.b.c.d[:port] is the same as the u line above, but the log messages are no longer written to the log directory, but transmitted through udp only. Error messages from svlogd concerning sending udp packages still go to the log directory. pprefix tells svlogd to prefix each line to be written to the log directory, to standard error, or through UDP, with prefix. If a line starts with a -, +, e, or E, svlogd matches the first len characters of each log message against pattern and acts accordingly: -pattern the log message is deselected. +pattern the log message is selected. epattern the log message is selected to be printed to standard error. Epattern the log message is deselected to be printed to standard error. Initially each line is selected to be written to log/current. Deselected log messages are discarded from log. Initially each line is des- elected to be written to standard err. Log messages selected for standard error are written to standard error. PATTERN MATCHING
svlogd matches a log message against the string pattern as follows: pattern is applied to the log message one character by one, starting with the first. A character not a star (``*'') and not a plus (``+'') matches itself. A plus matches the next character in pattern in the log message one or more times. A star before the end of pattern matches any string in the log message that does not include the next character in pattern. A star at the end of pattern matches any string. Timestamps optionally added by svlogd are not considered part of the log message. An svlogd pattern is not a regular expression. For example consider a log message like this 2005-12-18_09:13:50.97618 tcpsvd: info: pid 1977 from 10.4.1.14 The following pattern doesn't match -*pid* because the first star matches up to the first p in tcpsvd, and then the match fails because i is not s. To match this log message, you can use a pattern like this instead -*: *: pid * OPTIONS
-t timestamp. Prefix each selected line with a precise timestamp (see the daemontools' tai64n program) when writing to log or to stan- dard error. -tt timestamp. Prefix each selected line with a human readable, sortable UTC timestamp of the form YYYY-MM-DD_HH:MM:SS.xxxxx when writ- ing to log or to standard error. -ttt timestamp. Prefix each selected line with a human readable, sortable UTC timestamp of the form YYYY-MM-DDTHH:MM:SS.xxxxx when writ- ing to log or to standard error. -r c replace. c must be a single character. Replace non-printable characters in log messages with c. Characters are replaced before pattern matching is applied. -R xyz replace charset. Additionally to non-printable characters, replace all characters found in xyz with c (default ``_''). -l len line length. Pattern matching applies to the first len characters of a log message only. Default is 1000. -b buflen buffer size. Set the size of the buffer svlogd uses when reading from standard input and writing to logs to buflen. Default is 1024. buflen must be greater than len. For svlogd instances that process a lot of data in short time, the buffer size should be increased to improve performance. -v verbose. Print verbose messages to standard error. SIGNALS
If svlogd is sent a HUP signal, it closes and reopens all logs, and updates their configuration according to log/config. If svlogd has trouble opening a log directory, it prints a warning, and discards this log directory. If svlogd is unable to open all log directories given at the command line, it exits with an error. If svlogd is sent a TERM signal, or if it sees end-of-file on standard input, it stops reading standard input, processes the data in the buffer, waits for all processor subprocesses to finish if any, and exits 0 as soon as possible. If svlogd is sent an ALRM signal, it forces log file rotation for all logs with a non empty current log file. SEE ALSO
sv(8), runsv(8), chpst(8), runit(8), runit-init(8), runsvdir(8), runsvchdir(8) http://smarden.org/runit/ AUTHOR
Gerrit Pape <pape@smarden.org> svlogd(8)
All times are GMT -4. The time now is 03:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy