Non-standard utility msort allows you to specify fields from the right as well as the left:
producing:
The msort utility is available in many repositories, distributions of Linux, FreeBSD (ports), etc.
See the URL in the comment in the script for more ways to get msort.
Hi at all,
I have to sort a log file on timestamp field. That's field is the third!
a log file sample.....
1|EVTVOD-1-20060709_000614|2006/07/09-0:11:23|0.3.8
1|EVTVOD-1-20060709_000614|2006/07/09-0:11:16|0.3.8
1|EVTVOD-1-20060709_000614|2006/07/09-0:11:20|0.3.8... (3 Replies)
Hi,
I have a list of files that take on the format ABCDE_yymmdd and wish to sort them in ascending date order. I can't use the unix time stamp for the file as this could possibly be different from the date given in the file name.
Does anyone know of any way this can be done using unix shell... (14 Replies)
Hi guys... I've been trying to do this for ages. Maybe you can help.
I have log files like the examples below and I have grepped out certain lines from the files so that I can get an idea of who is logging on and how. So now I have the information in a new file but it is now in a different order... (7 Replies)
I'm not sure if this really belongs anywhere on this forum but my previous experiences on here have shown me that you guys are very helpful so I figure I may as well try.
I have a bunch of large 2d arrays in matlab and each has a column for a date that each row corresponds to. The format is... (1 Reply)
I am trying to sort by two columns. The first column in an ID, the second is a date in the form yyyy-mm-dd. I need to sort by the ID column, then in ascending order for the date column (earliest date to most recent date compared to today).
Input data:
012-abc 2012-04-25 ... (3 Replies)
Hello.
Sorting data file by date and time with the following issues:
Date is in the following format m/d/yyyy, no leading zeros
Time is in the following format h:m:s AM/PM, no leading zeros
Any ideas on how to sort data when the above issues?
Could the date/time be converted inline to... (5 Replies)
I have file having below data
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-JUN-13 2.38.11.00.100089 IN 1514 0000764631
01-NOV-13 2.38.11.00.100089 IN 1514 0000856571
01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531
01-JUN-13 2.38.19.00.100000 IN 2698 0000764493
01-JUL-13... (2 Replies)
I have file a.txt having below data
cat a.txt
01-MAY-13 2.38.11.00.100089 IN 4512 0000741881
01-JUN-13 2.38.11.00.100089 IN 1514 0000764631
01-NOV-13 2.38.11.00.100089 IN 1514 0000856571
01-NOV-13 2.38.15.00.100015 IN 300.32 0000856531
01-JUN-13 2.38.19.00.100000 IN 2698 0000764493... (5 Replies)
Hi all,
I have a file with a list of rpm's that have different dates. I am trying to just grab the latest rpm and install date, and discard the rest. The file has 1000's of entries all with different names and dates.
I have tried sort -k on the file and I am not grabbing the info,
... (4 Replies)
Discussion started by: gartie
4 Replies
LEARN ABOUT CENTOS
which
WHICH(1) General Commands Manual WHICH(1)NAME
which - shows the full path of (shell) commands.
SYNOPSIS
which [options] [--] programname [...]
DESCRIPTION
Which takes one or more arguments. For each of its arguments it prints to stdout the full path of the executables that would have been exe-
cuted when this argument had been entered at the shell prompt. It does this by searching for an executable or script in the directories
listed in the environment variable PATH using the same algorithm as bash(1).
This man page is generated from the file which.texinfo.
OPTIONS --all, -a
Print all matching executables in PATH, not just the first.
--read-alias, -i
Read aliases from stdin, reporting matching ones on stdout. This is useful in combination with using an alias for which itself. For
example
alias which='alias | which -i'.
--skip-alias
Ignore option `--read-alias', if any. This is useful to explicity search for normal binaries, while using the `--read-alias' option in
an alias or function for which.
--read-functions
Read shell function definitions from stdin, reporting matching ones on stdout. This is useful in combination with using a shell func-
tion for which itself. For example:
which() { declare -f | which --read-functions $@ }
export -f which
--skip-functions
Ignore option `--read-functions', if any. This is useful to explicity search for normal binaries, while using the `--read-functions'
option in an alias or function for which.
--skip-dot
Skip directories in PATH that start with a dot.
--skip-tilde
Skip directories in PATH that start with a tilde and executables which reside in the HOME directory.
--show-dot
If a directory in PATH starts with a dot and a matching executable was found for that path, then print "./programname" rather than the
full path.
--show-tilde
Output a tilde when a directory matches the HOME directory. This option is ignored when which is invoked as root.
--tty-only
Stop processing options on the right if not on tty.
--version,-v,-V
Print version information on standard output then exit successfully.
--help
Print usage information on standard output then exit successfully.
RETURN VALUE
Which returns the number of failed arguments, or -1 when no `programname' was given.
EXAMPLE
The recommended way to use this utility is by adding an alias (C shell) or shell function (Bourne shell) for which like the following:
[ba]sh:
which ()
{
(alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}
export -f which
[t]csh:
alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
This will print the readable ~/ and ./ when starting which from your prompt, while still printing the full path when used from a script:
> which q2
~/bin/q2
> echo `which q2`
/home/carlo/bin/q2
BUGS
The HOME directory is determined by looking for the HOME environment variable, which aborts when this variable doesn't exist. Which will
consider two equivalent directories to be different when one of them contains a path with a symbolic link.
AUTHOR
Carlo Wood <carlo@gnu.org>
SEE ALSO bash(1)WHICH(1)