FacebookTwitter
Hatrack River Forum   
my profile login | search | faq | forum home

  next oldest topic   next newest topic
» Hatrack River Forum » Active Forums » Books, Films, Food and Culture » sort command in Linux may need help on this one

   
Author Topic: sort command in Linux may need help on this one
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
Is there a way to pipe the "ls" output to a sort by filetype? Cuz I'm recreating teh tree command in a bash script.
IP: Logged | Report this post to a Moderator
Mindbowels
Member
Member # 7407

 - posted      Profile for Mindbowels           Edit/Delete Post 
ls | sort
Posts: 57 | Registered: Feb 2005  |  IP: Logged | Report this post to a Moderator
luthe
Member
Member # 1601

 - posted      Profile for luthe   Email luthe         Edit/Delete Post 
quote:
Originally posted by Mindbowels:
ls | sort

Doesn't sort by filetype like the OP is looking for

I have no idea how to sort by file type in bash, however there is a version of tree for linux. Some quick googling even indicates that there are packages for at least a few distros

Posts: 1458 | Registered: Feb 2001  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
OP???

Umm this is for an assignment and I don't quite know how to FTP something from my home PC to the Linux serv at school I can fool around with Linux here but I'm not quite sure how to FTP it, I think they're may be a chapter or two on it I'ld have to check it.

IP: Logged | Report this post to a Moderator
Minerva
Member
Member # 2991

 - posted      Profile for Minerva           Edit/Delete Post 
type in "man ls" or "man ftp" respectively. That will give you all of the options.
Posts: 289 | Registered: Jan 2002  |  IP: Logged | Report this post to a Moderator
luthe
Member
Member # 1601

 - posted      Profile for luthe   Email luthe         Edit/Delete Post 
OP = Original Poster

Edit: I can't spell

Posts: 1458 | Registered: Feb 2001  |  IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
Doesn't the -k option of sort allow you to select which characters on a line to sort by? If filetype is in the same position in each line of ls output, it should be trivial.
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
But what do you mean by position? Sure .* ... wait, would being a directory even show as a filetype?
IP: Logged | Report this post to a Moderator
Dagonee
Member
Member # 5818

 - posted      Profile for Dagonee           Edit/Delete Post 
quote:
But what do you mean by position?
The number of characters from the start of each ls entry to whatever text indicates file type.
Posts: 26071 | Registered: Oct 2003  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
umm, that won't work, the filenames could be anything.
IP: Logged | Report this post to a Moderator
luthe
Member
Member # 1601

 - posted      Profile for luthe   Email luthe         Edit/Delete Post 
do you just want the file extensions? if so
code:
ls | cut -f2 -d.

will print them
Posts: 1458 | Registered: Feb 2001  |  IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
also, umm it get a "ommitting file directory" when I try to copy files, what am I doing wrong?

say I'm in:

home/cs326_2/Tree and I want to copy from ../../dan/treedata to my tree folder, and its giving me that error what am I doing wrong?

IP: Logged | Report this post to a Moderator
Blayne Bradley
unregistered


 - posted            Edit/Delete Post 
nvm i figured out while it compains when i copy directories.
IP: Logged | Report this post to a Moderator
   

   Close Topic   Feature Topic   Move Topic   Delete Topic next oldest topic   next newest topic
 - Printer-friendly view of this topic
Hop To:


Contact Us | Hatrack River Home Page

Copyright © 2008 Hatrack River Enterprises Inc. All rights reserved.
Reproduction in whole or in part without permission is prohibited.


Powered by Infopop Corporation
UBB.classic™ 6.7.2