Sponsored Content
Top Forums UNIX for Dummies Questions & Answers i don't understand the "sort" command Post 17419 by xyyz on Thursday 14th of March 2002 07:23:45 PM
Old 03-14-2002
i don't understand the "sort" command

i have been trying to understand this chapter titled "Searching for Files and Text" for a few weeks now.

unfortunately, this chapter is one of those things, that no matter how hard you try and how long you try for, you are incapable of understanding (at least in my case)

this entire chapter, grep and it's derivatives and the sort command have been extremely frustrating.

i am hung up on the sort command more so than the others, but there are certain features that are especially difficult to understand.

this is what the book says about the sort command:

sort -options filenames(s)

the following two options are killing me:

-n performs a numeric sort.
(+|-)n begins (+n) or ends (-n) the sort with the field following the n
field

consider the following two examples, that have 8 columns (do columns=fields ?):

sort -rn +4 list -o num.list
sort -rn -3 list -o num2.list
sort +5n list -o update.list

first i would like some clarification with the (+|-)n option.

in the first example, the +4 says that we start counting from the 5th field (5th field because we start counting from 0, not 1 right?)... so when we count, we use fields 5,6,7 right?

in the second example, the -3 says we start counting from the 4th field backwards right? so 3,2,1,0?

next, i'm confused with what I see with the first two examples and the last. I notice that in the first two examples the +/- numbers (+4 and -3) are isolated options, but in the last example, +5n, the two options I mentioned earlier are combined. I don't understand why this is done, or what it means. shouldn't it be +5 -n instead of +5n? is +5 -n different from +5n?

can anyone please help reduce my confusion with this command?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

sed 's/~/\^J/g' how to get "^J" on same line as rest of the command.

when ever i type it in it always looks like so echo $file | sed 's/~/\ /g' how can i get it on one line? (6 Replies)
Discussion started by: Optimus_P
6 Replies

2. Solaris

"mail" command sort by date

Hello experts, I am using SunFire T200. When I start reading the mail with "mail" command it comes older mail first. From MAILER-DAEMON Sat Mar 28 06:02:48 2009 Return-Path: <MAILER-DAEMON@emarn1> Received: from localhost (localhost) .... .... I want to see the most recent mail... (1 Reply)
Discussion started by: thepurple
1 Replies

3. Shell Programming and Scripting

don't understand a command "."

Hi all, I have a script with those two lines : test -f $PWD/mysetup.txt . $PWD/mysetup.txt I understand the first one, but could anyone explain me the role of the second one? All the thing I find is the usage : Thx in advance (3 Replies)
Discussion started by: Moumou
3 Replies

4. Red Hat

Understand output of "free" command

Hi Friends, I am really confused with the output of "free" command on redhat linux. I can see caching and buffer output on two different areas on the output. Please let me know whats the difference of these two different outputs. Here I am pasting the command output of my server. # free... (3 Replies)
Discussion started by: arumon
3 Replies

5. Shell Programming and Scripting

Meaning of "b" modifier in "sort" command

I need to sort the following file by the rhdiskpower devices in the last column: Total_MB Free_MB OS_MB Name Failgroup Library Label UDID Product Redund Path 1024 851 1024 OCRVOT1_0000 OCRVOT1_0000 System UNKNOWN ... (3 Replies)
Discussion started by: wjssj
3 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

Is it Possible to sort a list of hexadecimal numbers using "sort" command?

Hello Everybody :) !!!. i have question in mind, is it possible to sort a list of hexadecimal numbers using "sort" command? (9 Replies)
Discussion started by: Kesavan
9 Replies

8. UNIX for Dummies Questions & Answers

New to Unix command line and have a question about the "sort" command

I am going through the Unix Made Easy second edition book by John Muster. So far it's been very informative and I can tell it may be a bit out of date. In one of the exercises it talks about the "sort" command and using it to sort column's of data etc. The "sort" command has changed a bit and... (1 Reply)
Discussion started by: budfoxcat
1 Replies

9. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

10. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies
DVDXCHAP(1)							   User Commands						       DVDXCHAP(1)

NAME
dvdxchap - Extract chapter information from DVDs SYNOPSIS
dvdxchap [options] DVD-SOURCE DESCRIPTION
This program extracts chapter information from a DVD and displays it in a form usable by ogmmerge(1). -t, --title num Use title 'num'. Default is 1. -c, --chapter start[-end] Only output the given range of chapters and adjust all timecodes so that they start at 0. The default is to output all chapters. -v Increase verbosity -V Show version information -h Show help EXAMPLES
The output generated by dvdxchap will have the form CHAPTER01=00:01:35.240 CHAPTER01NAME=Chapter 01 CHAPTER02=00:03:40:300 CHAPTER02NAME=Chapter 02 etc. You should pipe its output to a file, edit the chapter names and use the resulting file as an input for ogmmerge(1). AUTHOR
dvdxchap was written by Moritz Bunkus <moritz@bunkus.org>. Some ideas were taken from Chapter-X-Tractor (<http://christophe.paris.free.fr/main.php3>) <<http://christophe.paris.free.fr/main.php3>> written by Christophe Paris. SEE ALSO
ogmmerge(1), ogmsplit(1), ogminfo(1), ogmdemux(1) WWW
The newest version can always be found at <http://www.bunkus.org/videotools/ogmtools/> <http://www.bunkus.org/videotools/ogmtools/> dvdxchap v1.5 November 2004 DVDXCHAP(1)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy