This is topic sort command in Linux may need help on this one in forum Books, Films, Food and Culture at Hatrack River Forum.


To visit this topic, use this URL:
http://www.hatrack.com/ubb/main/ultimatebb.php?ubb=get_topic;f=2;t=039841

Posted by Blayne Bradley (Member # 8565) on :
 
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.
 
Posted by Mindbowels (Member # 7407) on :
 
ls | sort
 
Posted by luthe (Member # 1601) on :
 
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
 
Posted by Blayne Bradley (Member # 8565) on :
 
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.
 
Posted by Minerva (Member # 2991) on :
 
type in "man ls" or "man ftp" respectively. That will give you all of the options.
 
Posted by luthe (Member # 1601) on :
 
OP = Original Poster

Edit: I can't spell
 
Posted by Dagonee (Member # 5818) on :
 
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.
 
Posted by Blayne Bradley (Member # 8565) on :
 
But what do you mean by position? Sure .* ... wait, would being a directory even show as a filetype?
 
Posted by Dagonee (Member # 5818) on :
 
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.
 
Posted by Blayne Bradley (Member # 8565) on :
 
umm, that won't work, the filenames could be anything.
 
Posted by luthe (Member # 1601) on :
 
do you just want the file extensions? if so
code:
ls | cut -f2 -d.

will print them
 
Posted by Blayne Bradley (Member # 8565) on :
 
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?
 
Posted by Blayne Bradley (Member # 8565) on :
 
nvm i figured out while it compains when i copy directories.
 


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