ahh

~$ which cat

top 50 comments

sorted by: hot top controversial new old
[–] 85 points 6 days ago* (6 children)

cat is misunderstood a lot. The purpose of cat is to combine multiple files together (it's literally short for "concatenate"), like cat *.log to combine all log files together.

If you're just using it for a single file, then you should just redirect the file to stdin. These two command lines behave similarly:

cat foo.txt | some-command
some-command < foo.txt

For head, tail, grep and some other commands, you can just pass in the file name directly as an argument (e.g. grep whatever foo.txt).

  • source
  • hideshow 12 child comments
  • [–] 74 points 6 days ago (1 child)
  • [–] [S] 18 points 6 days ago (2 children)

    awww what's a cat without a head and a tail?

  • source
  • parent
  • hideshow 4 child comments
  • [–] 18 points 6 days ago* (last edited 6 days ago) (4 children)

    If I just want to look at the file, is there a better way than cat foo.txt? I guess I can't just do < foo.txt

  • source
  • parent
  • hideshow 6 child comments
  • [–] 13 points 6 days ago* (last edited 6 days ago) (1 child)

    Admittedly I still use cat for this.

    This also works too, but it's more verbose:

    echo "$(<foo.txt)"
    

    It's mentioned in the Bash man pages:

    The command substitution $(cat file) can be replaced by the equivalent but faster $(< file).

    EDIT: I was just informed that simply <foo.txt works too.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 6 points 6 days ago (1 child)

    how in the world is this not a useless use of echo and equivalent to <foo.txt

  • source
  • parent
  • hideshow 2 child comments
  • load more comments (2 replies)
  • [–] 12 points 6 days ago (2 children)

    Fair, but in general I find it way more useful to use cat for piping.

    In most cases I'll do something like

    cat file | program
    cat file | program | grep
    cat file | program | grep | cut
    

    This gets more complicated if the file is at the end of the command.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 8 points 6 days ago (1 child)

    It wouldn't be at the end, since you'd still be piping into program

    program <file | grep | cut
    
  • source
  • parent
  • hideshow 2 child comments
  • [–] 11 points 6 days ago (1 child)

    I still like doing cat file.txt | grep thing because I often re-run it to find something else like cat file.txt | grep thing2 - and if I do that with grep, the pattern sits awkwardly in the middle instead of at the end

  • source
  • parent
  • hideshow 2 child comments
  • [–] 29 points 6 days ago (2 children)

    Another all-time favorite:

    $ man woman  
    No manual entry for woman  
    
  • source
  • hideshow 4 child comments
  • [–] 2 points 2 days ago

    Huh. ... I could have swore there was a woman. I even package searched, even in overlays... no woman.

    digit 20260807 tyson gentoo /home/digit % whereis woman
    woman:
    digit 20260807 tyson gentoo /home/digit % which woman
    which: no woman in (/bedrock/cross/pin/bin:/bedrock/bin:/usr/local/bin:/usr/local/sbin:/opt/bin:/opt/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/snap/bin:/home/digit/bin:/usr/games/bin:/usr/games:/bedrock/strata/devuan/usr/libexec/xscreensaver:/home/digit/.cargo/bin:/bedrock/cross/bin)
    digit 20260807 tyson gentoo /home/digit % apropos woman
    woman: nothing appropriate.
    
    digit 20260807 tyson gentoo /home/digit % man cry
    No manual entry for cry
    digit 20260807 tyson gentoo /home/digit % whereis cry
    cry:
    
    

    No woman.

    No cry.

  • source
  • parent
  • [–] 9 points 5 days ago

    I was today's years old to finally notice the cat-head-tail thing...

    But it also just recently dawned upon me why pacman has those weird "c" as progress indicators...

    I'm not a smart man...

  • source
  • [–] 8 points 5 days ago (3 children)

    For the past 30 years or so, my brain always tells me to type "last" instead of "tail". This usually results in some kind of "Permission denied" message that confuses me for a few seconds.

  • source
  • hideshow 3 child comments
  • load more comments (3 replies)
    [–] 21 points 6 days ago (1 child)

    tac is a cat but faced the other way

  • source
  • hideshow 2 child comments
  • [–] 16 points 6 days ago (2 children)

    I've been using a slightly customized bash-cat for years now. Still makes me smile when I see it

  • source
  • hideshow 3 child comments
  • load more comments (1 reply)
    [–] 12 points 6 days ago (3 children)
    load more comments (3 replies)
    [–] 8 points 6 days ago (1 child)

    Bat is my favorite command to date.

  • source
  • hideshow 2 child comments
  • [–] 11 points 6 days ago (1 child)
    [–] 9 points 6 days ago (2 children)

    I always thought it's

    head | cat | tail
    

    It, of course, waits for an input, which brings up the one and only question...

    Have you fed your cat?

  • source
  • hideshow 4 child comments
  • [–] 8 points 6 days ago* (1 child)
  • [–] 12 points 6 days ago (1 child)
  • [–] 6 points 6 days ago (1 child)
  • load more comments
    view more: next ›