Category: | Utility Scripts |
Author/Contact Info | /msg me |
Description: | wrapper for "ls" that supplies default args and paged output
I got tired of typing "ls -halt ... | less -E". Now I just run this script, which I've named "sl". Usage:
|
#!/usr/local/bin/perl # Quote each argument. # When you run "sl *a*", the shell interprets the "*a*" and passes a l +ist of files # in @ARGV. I noticed that things broke on a file named "#blah#" (lik +e emacs creates), # and quoting each argument fixed that. map {$_ = "\"$_\""} @ARGV; my $hasLess = 1 unless ($^O eq 'aix'); # change as needed # (-E Causes less to automatically exit the first time it reaches +end-of-file.) my $pager = $hasLess ? 'less -E' : 'more'; # put the command together $command = "ls -halt @ARGV | $pager"; # debugging # print "$command\n"; # You probably don't need this anymore but I think it's # harmless. (see $| in "perldoc -f exec".) $| = 1; # run the command and exit exec $command; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: expanded "ls"
by chanio (Priest) on Aug 10, 2005 at 03:37 UTC | |
Re: expanded "ls"
by nothingmuch (Priest) on Aug 11, 2005 at 10:27 UTC |