LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] displaying directory listings

[ILUG] displaying directory listings

P at draigBrady.com P at draigBrady.com
Mon Jul 25 15:48:34 IST 2005


P at draigBrady.com wrote:
> P at draigBrady.com wrote:
> 
>>
>> l() { cols=$1; width=`expr $cols '*' 40`; /bin/ls -F | pr -T$cols \ 
>> -W$width; }
>>
>> To display 1 column listing you issue "l 1" and for 4 columns "l 4"
> 
> 
> Oops you probably want to add the -a option to pr above
> so that the columns print across rather than down.

Also the following script would list one line
per letter, which may be easier to navigate?

#!/usr/bin/python
import os
letters={}
for path in os.popen("ls -F").readlines():
     path=path.strip()
     letters.setdefault(path[0].lower(),[]).append(path)
for letter in letters:
     for path in letters[letter]:
         print "%-38s"%path[0:39],
     print

-- 
Pádraig Brady - http://www.pixelbeat.org
--



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell