ls vs. ls -l

Please compose all posts in Emacs.

Moderators: phlip, Moderators General, Prelates

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

ls vs. ls -l

Postby enk » Sun Dec 16, 2007 4:16 pm UTC

Subjecting myself to the danger of asking a stupid question like vi vs. vim...

So, everyone knows ls, but who really uses it in its raw form?

Personally, I have trouble reading the two dimensional output of ls, so I've aliased lf to ls -l.
phlip wrote:Ha HA! Recycled emacs jokes.

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Re: ls vs. ls -l

Postby zenten » Sun Dec 16, 2007 4:27 pm UTC

I find the ls -l has too much extraneous information that makes it hard to look through. I use it when I need it, but that's not often.

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Sun Dec 16, 2007 7:00 pm UTC

If all that info annoyed me, I'd use ls -1 so I got the output in one column. I find several columns harder to look through both when I can't remember exactly what I'm looking for or if it's something specific.

The only advantage of pure ls I can see is that it crams more filenames into one screen, which is useful in folders with a lots of content. And then again, if that output fills more than one screen, ls -x would make it easier too look through. Or even ls -m :)
phlip wrote:Ha HA! Recycled emacs jokes.

User avatar
Dingbats
Posts: 921
Joined: Tue Mar 20, 2007 12:46 pm UTC
Location: Sweden
Contact:

Re: ls vs. ls -l

Postby Dingbats » Sun Dec 16, 2007 7:01 pm UTC

I use ls normally, and ls -l when I need to know the permissions/sizes/etc of stuff.

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Re: ls vs. ls -l

Postby zenten » Sun Dec 16, 2007 8:35 pm UTC

enk wrote:If all that info annoyed me, I'd use ls -1 so I got the output in one column. I find several columns harder to look through both when I can't remember exactly what I'm looking for or if it's something specific.

The only advantage of pure ls I can see is that it crams more filenames into one screen, which is useful in folders with a lots of content. And then again, if that output fills more than one screen, ls -x would make it easier too look through. Or even ls -m :)


I don't have an issue with columns. It's matching up entries in a column that takes more brainpower.

User avatar
wing
the /b/slayer
Posts: 1876
Joined: Tue May 29, 2007 5:56 am UTC

Re: ls vs. ls -l

Postby wing » Sun Dec 16, 2007 9:30 pm UTC

I use raw ls. It's cool when I have less than a screenfull of stuff to be displayed anyway. If I have more, ls | less which arranges it into a single column.

I only use ls -l when I need the extra info.
I AM A SEXY, SHOELESS GOD OF WAR!
Akula wrote:Our team has turned into this hate-fueled juggernaut of profit. It's goddamn wonderful.

User avatar
Elenion
Posts: 204
Joined: Mon Nov 26, 2007 9:18 pm UTC
Location: Norway
Contact:

Re: ls vs. ls -l

Postby Elenion » Sun Dec 16, 2007 9:40 pm UTC

I use ls. Only use ls -l if i need the extra info for some reason. But then again, I only use unix when at uni, at home I use windows..^^
Image
22/f/Oslo - Picz - Cyber

..it's not the end that I fear with each breath, it's life that scares me to death..

User avatar
OmenPigeon
Peddler of Gossamer Lies
Posts: 673
Joined: Mon Sep 25, 2006 6:08 am UTC
Contact:

Re: ls vs. ls -l

Postby OmenPigeon » Sun Dec 16, 2007 10:47 pm UTC

If you were really desperate for the output of ls in one column without all the extra stuff and without using less you could do something like 'ls -l | cut -c 54-', but that seems a little excessive. It also makes the pretty colors go away.
As long as I am alive and well I will continue to feel strongly about prose style, to love the surface of the earth, and to take pleasure in scraps of useless information.
~ George Orwell

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: ls vs. ls -l

Postby EvanED » Sun Dec 16, 2007 11:06 pm UTC

Code: Select all

alias ls 'ls \!* | ~/bin/natsort -f'
Sorta screws up when you pass other arguments to ls (like -lah), but optimize for the common case.

HappySmileMan
Posts: 52
Joined: Fri Nov 09, 2007 11:46 pm UTC

Re: ls vs. ls -l

Postby HappySmileMan » Mon Dec 17, 2007 12:02 am UTC

Dingbats wrote:I use ls normally, and ls -l when I need to know the permissions/sizes/etc of stuff.

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 12:39 am UTC

wing wrote:I use raw ls. It's cool when I have less than a screenfull of stuff to be displayed anyway. If I have more, ls | less which arranges it into a single column.


OmenPigeon wrote:If you were really desperate for the output of ls in one column without all the extra stuff and without using less you could do something like 'ls -l | cut -c 54-', but that seems a little excessive. It also makes the pretty colors go away.


You can't use cut for that, as the widths of the first columns depend on the content.

Instead of piping ls, you can use ls -1 (it's a "one"). And about the pretty colors, try ls --color=always | cat. And if you pipe it to less or an editor, you can see the terminal control codes :wink:

@EvanED: What does ls \!* do? Doesn't do anything in my bash.. or do you just have a lot of filenames beginning with "!"?
Edit: Ah..... I see someone's using zsh. But still, what is it? :o
phlip wrote:Ha HA! Recycled emacs jokes.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: ls vs. ls -l

Postby EvanED » Mon Dec 17, 2007 12:48 am UTC

enk wrote:@EvanED: What does ls \!* do? Doesn't do anything in my bash.. or do you just have a lot of filenames beginning with "!"?
Edit: Ah..... I see someone's using zsh. But still, what is it? :o

csh actually. This is school account, and I haven't changed the default. (zsh isn't available there, or I would.)

It substitutes arguments. Otherwise, if I said "ls blah.txt", I'm pretty sure it would do something like "ls | natsort -f blah.txt", which isn't what I want. I want "ls blah.txt | natsort -f".

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 1:15 am UTC

EvanED wrote:
enk wrote:@EvanED: What does ls \!* do? Doesn't do anything in my bash.. or do you just have a lot of filenames beginning with "!"?
Edit: Ah..... I see someone's using zsh. But still, what is it? :o

csh actually. This is school account, and I haven't changed the default. (zsh isn't available there, or I would.)

It substitutes arguments. Otherwise, if I said "ls blah.txt", I'm pretty sure it would do something like "ls | natsort -f blah.txt", which isn't what I want. I want "ls blah.txt | natsort -f".


So \!* is for only used in aliases? I was curious so I installed csh, and that's what it seemed like to me. But here it seems to work fine sending the arguments to ls...

Btw. natsort is nice (if it works like the natsort in php). It's built into Windows explorer too... (but on the other hand, it makes my sed scripts inserting zeroes in filenames superfluous :? )
phlip wrote:Ha HA! Recycled emacs jokes.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: ls vs. ls -l

Postby EvanED » Mon Dec 17, 2007 1:42 am UTC

enk wrote:So \!* is for only used in aliases? I was curious so I installed csh, and that's what it seemed like to me. But here it seems to work fine sending the arguments to ls...

I think so. It doesn't work for me if I leave it out:

Code: Select all

9. emperor10 ~/temp: alias t 'ls | ~/bin/natsort -f'
10. ~/temp: t
1-File
2-File
10-File
file1
file2
File3
file10
File11
11. ~/temp: t file*
1-File
2-File
10-File
file1
file2
File3
file10
File11
12. ~/temp: alias t 'ls \!* | ~/bin/natsort -f'
13. ~/temp: t file*
file1
file2
file10
14. ~/temp:

(I used t as the alias for this demo because I felt like it.)

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 1:50 am UTC

Well, just saying since you said earlier that it screws up when you pass other arguments to ls (like -lah).
phlip wrote:Ha HA! Recycled emacs jokes.

User avatar
adlaiff6
Posts: 274
Joined: Fri Nov 10, 2006 6:08 am UTC
Location: Wouldn't you rather know how fast I'm going?
Contact:

Re: ls vs. ls -l

Postby adlaiff6 » Mon Dec 17, 2007 2:34 pm UTC

Code: Select all

alias l=ls; alias ll='ls -l'
3.14159265... wrote:What about quantization? we DO live in a integer world?

crp wrote:oh, i thought you meant the entire funtion was f(n) = (-1)^n
i's like girls u crazy

User avatar
pieaholicx
The cake is a lie!
Posts: 531
Joined: Mon Oct 22, 2007 12:51 pm UTC
Contact:

Re: ls vs. ls -l

Postby pieaholicx » Mon Dec 17, 2007 2:38 pm UTC

adlaiff6 wrote:

Code: Select all

alias ll='ls -l'

That part I like, and do. Otherwise I just use ls. What really screws me up is when I try to use ls on Windows. It doesn't like it for some crazy reason.
It's okay, I'm Chaotic Neutral. I can kill him over the loot.
Overexposure to pieaholicx may, in semi-rare cases, emancipate dental fillings, crowns, tooth enamel, and teeth.

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 4:28 pm UTC

pieaholicx wrote:What really screws me up is when I try to use ls on Windows. It doesn't like it for some crazy reason.


I have various GNU tools on my Windows. They followed with the Ch C interpreter, but I guess Cygwin would be a more common way of getting them :)
phlip wrote:Ha HA! Recycled emacs jokes.

User avatar
adlaiff6
Posts: 274
Joined: Fri Nov 10, 2006 6:08 am UTC
Location: Wouldn't you rather know how fast I'm going?
Contact:

Re: ls vs. ls -l

Postby adlaiff6 » Mon Dec 17, 2007 7:07 pm UTC

pieaholicx wrote:
adlaiff6 wrote:

Code: Select all

alias ll='ls -l'

That part I like, and do. Otherwise I just use ls. What really screws me up is when I try to use ls on Windows. It doesn't like it for some crazy reason.

I also have

Code: Select all

alias la='ls -a'; alias lla='ls -la'
, but I use those less often.
3.14159265... wrote:What about quantization? we DO live in a integer world?

crp wrote:oh, i thought you meant the entire funtion was f(n) = (-1)^n
i's like girls u crazy

User avatar
Pobega
Posts: 103
Joined: Sun Jul 29, 2007 1:50 am UTC
Location: Staten Island, NY
Contact:

Re: ls vs. ls -l

Postby Pobega » Mon Dec 17, 2007 7:15 pm UTC

It really depends what I'm doing. If I'm looking for a file I tend to use ls piped with grep/less, but if I'm looking for permissions/ownership/date I use ls -l. It's all situational.

I'd find it weird if someone out there used ls -l for tasks that just ls can accomplish. There's no reason to clog your screen up with useless information.

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 8:32 pm UTC

Pobega wrote:I'd find it weird if someone out there used ls -l for tasks that just ls can accomplish. There's no reason to clog your screen up with useless information.


It seems I'm the only one... If I didsn't use ls -l, I'd use ls -1 (single column) for readability, but that takes up same number of lines, so using ls -l all the time has all the other info ready for when I need it. It doesn't disturb me when I don't need it, in fact I feel sorta lonely without it. It's not useless to me.

Besides ls -l (alias: lf), I use ls -al (la), ls -ld .* (l.). And time sorting -t / -tr once in a while. If it's not a color terminal I'll throw in -F as well for any ls.

I've even made my own shell functions, that combine cd with ls.

Code: Select all

c() { clear ; cd $1 ; pwd -P ; echo ; ls --color=auto -l ; }
ca() { clear ; cd $1 ; pwd -P ; echo ; ls --color=auto -al ; }


It takes bash to a whole new level.
phlip wrote:Ha HA! Recycled emacs jokes.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: ls vs. ls -l

Postby EvanED » Mon Dec 17, 2007 8:54 pm UTC

One of these days I need to go through and start adding some customizations. Anther one I like is something like 'alias mk 'mkdir /!* ; cd /!*'' (untested, no clue if it should work) to make a directory and immediately cd into it. 95% of the time I make a directory that's what I do next anyway. (Vista actually does this in explorer, and it's quite nice. The above idea dates to before I knew that though. ;-))

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Mon Dec 17, 2007 9:22 pm UTC

EvanED wrote:One of these days I need to go through and start adding some customizations. Anther one I like is something like 'alias mk 'mkdir /!* ; cd /!*'' (untested, no clue if it should work) to make a directory and immediately cd into it. 95% of the time I make a directory that's what I do next anyway. (Vista actually does this in explorer, and it's quite nice. The above idea dates to before I knew that though. ;-))


I use this in bash:

Code: Select all

mkcd() { mkdir $1 ; cd $1 ; }
phlip wrote:Ha HA! Recycled emacs jokes.

LikwidCirkel
Posts: 169
Joined: Thu Nov 08, 2007 8:56 pm UTC
Location: on this forum (duh)
Contact:

Re: ls vs. ls -l

Postby LikwidCirkel » Mon Dec 17, 2007 10:03 pm UTC

I hardly even use ls at all anymore when I've got the double tab listing capabilities of bash!

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Re: ls vs. ls -l

Postby zenten » Tue Dec 18, 2007 3:20 am UTC

pieaholicx wrote:
adlaiff6 wrote:

Code: Select all

alias ll='ls -l'

That part I like, and do. Otherwise I just use ls. What really screws me up is when I try to use ls on Windows. It doesn't like it for some crazy reason.


Just stick "dir" in a batch file called ls, and stick that in your path.

User avatar
wisnij
Posts: 427
Joined: Mon Jun 26, 2006 5:03 pm UTC
Location: a planet called Erp
Contact:

Re: ls vs. ls -l

Postby wisnij » Tue Dec 18, 2007 9:11 am UTC

I have

Code: Select all

alias l='ls -Fl --time-style="+%Y-%m-%d %H:%M:%S" --si'
in my .bashrc. It works for me.
I burn the cheese. It does not burn me.

User avatar
enk
Posts: 754
Joined: Mon Sep 10, 2007 12:20 am UTC
Location: Aalborg, Denmark
Contact:

Re: ls vs. ls -l

Postby enk » Tue Dec 18, 2007 1:35 pm UTC

LikwidCirkel wrote:I hardly even use ls at all anymore when I've got the double tab listing capabilities of bash!


Now if I could only get bash to list stuff in a single column....
Vim can do it in a single row, but that's not as good :P


Also, if I could get bash to list file sizes in bytes and human-readable at the same time... and if would list the size of the content of folders instead.... Is this possible?
(and I want it in the same column as the file sizes - otherwise I'll use du -s */)
phlip wrote:Ha HA! Recycled emacs jokes.

zenten
Posts: 3799
Joined: Fri Jun 22, 2007 7:42 am UTC
Location: Ottawa, Canada

Re: ls vs. ls -l

Postby zenten » Wed Dec 19, 2007 12:40 pm UTC

LikwidCirkel wrote:I hardly even use ls at all anymore when I've got the double tab listing capabilities of bash!


Is there any way to give the entries colours like with ls?

LikwidCirkel
Posts: 169
Joined: Thu Nov 08, 2007 8:56 pm UTC
Location: on this forum (duh)
Contact:

Re: ls vs. ls -l

Postby LikwidCirkel » Wed Dec 19, 2007 4:09 pm UTC

enk wrote:
LikwidCirkel wrote:I hardly even use ls at all anymore when I've got the double tab listing capabilities of bash!


Now if I could only get bash to list stuff in a single column....
Vim can do it in a single row, but that's not as good :P


Also, if I could get bash to list file sizes in bytes and human-readable at the same time... and if would list the size of the content of folders instead.... Is this possible?
(and I want it in the same column as the file sizes - otherwise I'll use du -s */)

That actually might be possible to set up!

http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion

Bash uses some config stuff to call compgen, or complete, or something like that, depending on the program that you're trying to invoke. This can take options like
-A builtin
Names of shell builtin commands. May also be specified as -b.

In theory, you should be able to use an ls command with options to do autocomplete. I think you might have to specify the behavior of each program that this would work for though, but cd would be a good start.

Now you've got me fascinated, and I'll have to dig deeper.

ToLazyToThink
Posts: 83
Joined: Thu Jun 14, 2007 1:08 am UTC

Re: ls vs. ls -l

Postby ToLazyToThink » Wed Dec 19, 2007 6:45 pm UTC

Count me in on the ls -l.

On the previous system I worked on I had ls aliased to ls -la, haven't gotten around to adding that on the new servers I'm working on.

Another common alias was lsd (ls -l | grep "^d").

Note: not the actual aliases used, I'd have to dig through backups to find exactly what was used, but I know it was more resilient to added options.

User avatar
adlaiff6
Posts: 274
Joined: Fri Nov 10, 2006 6:08 am UTC
Location: Wouldn't you rather know how fast I'm going?
Contact:

Re: ls vs. ls -l

Postby adlaiff6 » Fri Dec 21, 2007 6:07 am UTC

LikwidCirkel wrote:
enk wrote:
LikwidCirkel wrote:I hardly even use ls at all anymore when I've got the double tab listing capabilities of bash!


Now if I could only get bash to list stuff in a single column....
Vim can do it in a single row, but that's not as good :P


Also, if I could get bash to list file sizes in bytes and human-readable at the same time... and if would list the size of the content of folders instead.... Is this possible?
(and I want it in the same column as the file sizes - otherwise I'll use du -s */)

That actually might be possible to set up!

http://www.gnu.org/software/bash/manual/bashref.html#Programmable-Completion

Bash uses some config stuff to call compgen, or complete, or something like that, depending on the program that you're trying to invoke. This can take options like
-A builtin
Names of shell builtin commands. May also be specified as -b.

In theory, you should be able to use an ls command with options to do autocomplete. I think you might have to specify the behavior of each program that this would work for though, but cd would be a good start.

Now you've got me fascinated, and I'll have to dig deeper.

At the risk of smearing the boundaries between threads, why not just use zsh and get it all over with?
3.14159265... wrote:What about quantization? we DO live in a integer world?

crp wrote:oh, i thought you meant the entire funtion was f(n) = (-1)^n
i's like girls u crazy

User avatar
Hurduser
Posts: 285
Joined: Tue Dec 04, 2007 6:14 pm UTC
Location: Esperantujo

Re: ls vs. ls -l

Postby Hurduser » Fri Dec 21, 2007 7:21 am UTC

I like the multi-common output of dir /w on my FreeDOS-box and the ls on Linux-boxen without framebuffer and/or X11. If I have to suffer through normal text-modes it is advantageous not to have to scroll.
Frag mal nach im IRC
'zum Kotzen' das heisst dort XP.
Win2k, nur so zum staunen,
hat mehr Bugs als nur zweitausend.

benizi
Posts: 3
Joined: Sat Dec 22, 2007 7:45 am UTC

Re: ls vs. ls -l

Postby benizi » Sat Dec 22, 2007 11:31 am UTC

adlaiff6 wrote:At the risk of smearing the boundaries between threads, why not just use zsh and get it all over with?


++ to that. It always kills me going back to bash for lack of (at least by default - maybe these are tucked away somewhere)

  1. auto_cd - just tab-completing a directory name and hitting enter cd's to it.
  2. simple 'for' - for l in stuff ; command - not: for l in stuff ; do command ; done - (drop the 'do' and 'done')
  3. globamahol - for l in **/*foo*(.) ; process $l == process all regular files (.), in any subdirectory **/, with foo in their name. Don't want 'barfoo', though? **/*foo*~*barfoo(.)

But back to the topic at hand. I'm surprised more people don't like to sort by time. I rarely care about old files in a given directory. Here's my 'ls' alias list:

Code: Select all

alias l='ls --color=auto -trl'
alias ll='ls --color=auto -trlL'
alias lll='ls --color=auto -trl | less'
alias la='ls --color=auto -trlA'
alias lsd='ls --color=auto -trld'
alias lsda='ls --color=auto -trldA'
alias lss='ls --color=auto -Srl'
alias lsr='ls --color=auto -Sl'


All except the last two sort by date, with the most recent at the end.

I use 'l' the most, 'lsd' and 'la' pretty often. The ones that sort by size are mainly for when I'm looking to kill off some files hogging disk space (lss), but don't feel like using filelight, or while cleaning up my home dir (lll, lsr).

User avatar
evilbeanfiend
Posts: 2650
Joined: Tue Mar 13, 2007 7:05 am UTC
Location: the old world

Re: ls vs. ls -l

Postby evilbeanfiend » Thu Jan 03, 2008 3:10 pm UTC

mostly i use dired in emacs, which in terms of display is pretty much ls -l
in ur beanz makin u eveel


Return to “Religious Wars”

Who is online

Users browsing this forum: No registered users and 11 guests