LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2016, 04:57 PM   #1
PleaseHelpMeUnderstand
Member
 
Registered: Apr 2016
Posts: 32

Rep: Reputation: Disabled
Sort Command


I want to sort the information a file by file size with the file size is in the 5th field from the left.

I have researched man sort but I am still not comprehending how to do this. Please help. Please and thank you
 
Old 05-14-2016, 05:08 PM   #2
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
What have you tried so far? If I understand what you want to do correctly, you don't need the sort command, you can do it with ls.
 
1 members found this post helpful.
Old 05-14-2016, 05:10 PM   #3
PleaseHelpMeUnderstand
Member
 
Registered: Apr 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by arizonagroovejet View Post
What have you tried so far? If I understand what you want to do correctly, you don't need the sort command, you can do it with ls.
the file is called etclist. So far I tried ls -lSh and I also tried ls -lSh ~/etclist
 
Old 05-14-2016, 05:19 PM   #4
arizonagroovejet
Senior Member
 
Registered: Jun 2005
Location: England
Distribution: openSUSE, Fedora, CentOS
Posts: 1,078

Rep: Reputation: 195Reputation: 195
Thumbs down

Quote:
Originally Posted by PleaseHelpMeUnderstand View Post
the file is called etclist. So far I tried ls -lSh and I also tried ls -lSh ~/etclist
When you post commands and such like, use CODE tags for readability. E.g.
Code:
ls -lSh ~/etclist
Look for the # button when composing your post.

ls isn't going to show you the contents of a file. I didn't understand what you want to do correctly, I pretty much ignored "I want to sort the information a file" part of your post because it didn't make sense to me, I thought you were trying to sort a directory listing, rather than a directory listing that's in a file. I think the -k and -n options of sort are what you want. Maybe this
Code:
sort -k5 -n ~/etclist
It might help if you posted part of the file in question.
 
Old 05-14-2016, 05:22 PM   #5
PleaseHelpMeUnderstand
Member
 
Registered: Apr 2016
Posts: 32

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by arizonagroovejet View Post
When you post commands and such like, use CODE tags for readability. E.g.
Code:
ls -lSh ~/etclist
Look for the # button when composing your post.

ls isn't going to show you the contents of a file. I didn't understand what you want to do correctly, I pretty much ignored "I want to sort the information a file" part of your post because it didn't make sense to me, I thought you were trying to sort a directory listing, rather than a directory listing that's in a file. I think the -k and -n options of sort are what you want. Maybe this
Code:
sort -k5 -n ~/etclist
It might help if you posted part of the file in question.
lol you're right it didn't make sense now that I've re-read it. This is what I needed. Thank you kindly
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sort command coffee arabia Linux - Newbie 3 10-29-2010 06:10 PM
sort command fallloveuni Programming 3 01-24-2010 09:31 PM
Sort command djfog Linux - Newbie 17 07-03-2008 04:05 AM
Sort Command saravanan1979 Programming 1 10-03-2004 12:36 PM
The SORT command Rezon Programming 2 10-30-2003 05:14 PM


All times are GMT -5. The time now is 11:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration