I am wondering if someone could please break down and explain the following sort command for me:
I have tried working it out using 'man sort', but on AIX there is not a great explanation of this function. I know that it searches the source directory for the named file and returns the name of the latest dated, but I am particularly confused as to what
is doing.
Thanks in advance.
This is not a sort command, it is a pipeline containing three commands: ls, sort, and head
The sort command in the middle of this makes no sense: The options are interpreted as follows: -r reverses the sort order, -t the next argument (in this case -k) should be a single character which is used as the field delimiter separating fields in the input that is to be sorted. I don't believe that you have shown us what this argument is. The -k option with the option argument 4,4n says to sort the input data based on the 4th field and sort the values numerically (rather than alphabetically).
The first command in the pipeline (ls ${DEST_LOCATION}/${FILES}) will provide a list of files (one per line) that match the pattern to which ${DEST_LOCATION}/${FILES} expands. Without knowing how DEST_LOCATION and FILES were set, I have no idea what filenames are going to be sorted by the sort command. When the sort is completed, the last command in the pipeline (head -1) will print the 1st line and ignore everything else.
Please recheck this command line. For this pipeline to make any sense there has to be another argument to the ls command or the argument (-rt) to sort would have to be just -r instead, and there would need to be options given to ls to produce multi-column output with the 4th field being a numeric value. If the command was:
the output would be a long format listing of the largest file matched by the pattern specified by ${DEST_LOCATION}/${FILES}.
Hi,
Could you please explain me the below statement -- phrase wise.
sed -e :a -e '$q;N;'$cnt',$D;ba' abc.txt > xyz.txt
if suppose $cnt contains value: 10
it copies last 9 lines of abc.txt to xyz.txt
why it is copying last 9 rather than 10.
and also what is ba and $D over there in... (4 Replies)
Hello everyone,
I found this command line in a website:
perl -pi.bak -we's/\z/Your new line\n/ if $. == 2;' your_text_file.txt
With this command line you can insert a new line anywhere you want in a text without overwriting what's in it.
-p causes perl to assume a loop around your... (4 Replies)
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)
sed '$!N; /^\(.*\)\n\1$/!P; D'
i found this file which removes duplicates irrespective for sorted or unsorted file. keep first occurance and remove the further occurances.
can any1 explain how this is working..
i need to remove duplicates following file. duplicate criteria is not the... (3 Replies)
can anyone please tell me what does this expression means , i am under probation and need some explanation :)
$AUDIT_DIR -type f -mtime +$AUDIT_EXPIRE \ -exec rm {} > /dev/null 2>&1 \;
AUDIT_DIR="/var/log/"
AUDIT_EXPIRE='30'
Please use code tags! (4 Replies)
Hi All
I ran a script in Linux.
In the script i have lines like
&& echo "Failed: Missing ${CM_ENV_FILE} \n" && return 1
. ${CM_ENV_FILE}
Where CM_ENV_FILE = /data/ds/dpr_ebicm_uat//etl/cm3_0/entities/BBME/parameters/cm.env
But its taking this path... (1 Reply)
I tried to use sort utility and typed sort --help, read one of lines; its -k option, and part of it:
I am really not getting it
Anyone do me a useful favor to save me out of my ignorance ?
Please use correct tags as required by forum rules! (1 Reply)
Hi Folks,
I am struggling to understand nawk command which was used by another developer.
Can you please explain what each character or string is doing here below:
if ; then (3 Replies)