Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Wednesday August 01, 2007
04:33 AM

'cat' eq 'ls'

[ #33944 ]

I'm so sick and tired of typing "cat $some_dir" or "ls $some_file" that I'm thinking of writing bash functions that will switch the two around, as needed. The cat $some_dir is particularly bad as it really screws up my terminal settings by spewing junk across the screen.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • On Linux, "less" can handle both:

    less dir/

    less file.txt

    However, on the FreeBSD machines I use, "less" can't handle directories, so I don't depend on it for that.

    • less dir/ only works for me when $ENV{LESSOPEN} is set to an appropriate script, regardless of Linux or BSD.
  • cat spews junk? All I get is

    $ cat .
    cat: .: Is a directory

    Btw, blindly typing reset + Enter on a screwed terminal will often fix it.

    • The reset command breaks my backspace key, though. I could probably source my .bashrc as I think I have something in there to fix it, but I can't recall.

    • Linux typically generates errno=EISDIR on open(".", O_WRONLY) and read(dirfd, …).  IIRC, the latter varies by filesystem on BSD.
  • I don't know about swapping but my (z)shell alias 'm' handles directories (ls -sF | less) and files (less), and for certain types of files it does Magic (TM), e.g. for .tar.bz2 it pipes bzip2 -d foo.tar.bz2 | tar tvf - to less (I don't do tar jtvf because I don't have gtar everywhere). Kinda like open(1) in Mac OS X.