• gnu utils

    From MeaTLoTioN@1337:1/101 to All on Tue Jan 11 13:07:10 2022
    Something I've seen lots of people do in examples/videos/tutorials keeps on grating on me, and I thought I would share my frustration, and see if anyone else shares it. It's totally a non problem, just one of the many things that irks me daily lol.

    When trying to get some info from a text file, or command output people tend to do something like;

    $ cat somefile.txt | grep something | wc -l

    This would spit out the contents of somefile.txt, pipe it into grep to filter out just "something" and then count how many lines contain that "something", perfectly a normal thing to do, but it's so bloated and irks me to no end. Instead of this overly bloated command one-liner, this can all be achieved in just a simple one command;

    $ grep -c something somefile.txt

    only one process is run, for grep, and it does the exact same job as the overly bloated one-liner.

    Now I do understand that I shouldn't be worried by such trivial things, but it just gets to me, when someone is doing a tutorial, for eg a YT video, they are assuming the role of a "teacher" of sorts, and should know better.

    I dunno, that's just me, my quirkiness lol. Don't judge me =)

    ---
    |14Best regards,
    |11Ch|03rist|11ia|15n |11a|03ka |11Me|03aTLoT|11io|15N

    |07── |08[|10eml|08] |15ml@erb.pw |07── |08[|10web|08] |15www.erb.pw |07───┐ |07── |08[|09fsx|08] |1521:1/158 |07── |08[|11tqw|08] |151337:1/101 |07┬──┘ |07── |08[|12rtn|08] |1580:774/81 |07─┬ |08[|14fdn|08] |152:250/5 |07───┘
    |07── |08[|10ark|08] |1510:104/2 |07─┘

    ... WOMAN.ZIP - Great program but no documentation

    --- Mystic BBS v1.12 A47 2021/12/13 (Linux/64)
    * Origin: thE qUAntUm wOrmhOlE, rAmsgAtE, uK. bbs.erb.pw (1337:1/101)
  • From 0zZ-U@1337:3/106 to MeaTLoTioN on Tue Jan 11 11:13:54 2022
    When trying to get some info from a text file, or command output people tend to do something like;

    $ cat somefile.txt | grep something | wc -l

    This would spit out the contents of somefile.txt, pipe it into grep to filter out just "something" and then count how many lines contain that "something", perfectly a normal thing to do, but it's so bloated and
    irks me to no end. Instead of this overly bloated command one-liner,
    this can all be achieved in just a simple one command;

    $ grep -c something somefile.txt

    I think I've been guilty on doing that on the occasion. Completely
    forgetting that I can just simple feed grep the text file...but
    in my defense I do not make YT or any other video tutorials LOL
    But yes, I agree, any one that "teaches" this stuff should know better.

    Oh and BTW , I've started eliminating the empty space right after the
    pipe character. I blame that on you ;)


    .:[ Exit stage left ]:.

    --- Mystic BBS v1.12 A45 2020/02/18 (Linux/64)
    * Origin: The Bottomless Abyss BBS * bbs.bottomlessabyss.net (1337:3/106)
  • From MeaTLoTioN@1337:1/101 to 0zZ-U on Tue Jan 11 16:47:00 2022
    On 11 Jan 2022, 0zZ-U said the following...

    I think I've been guilty on doing that on the occasion. Completely forgetting that I can just simple feed grep the text file...but
    in my defense I do not make YT or any other video tutorials LOL
    But yes, I agree, any one that "teaches" this stuff should know better.

    Yeah I think we all do it, until we learn we don't need to, it's just those that "teach" you things you _should_ do, yet they do it wrong themselves just straight up feeds my frustration lol. I mean, don't get me wrong, kudos for making the effort in teaching others, but at least teach accurately if you're gonna try lol.

    Oh and BTW , I've started eliminating the empty space right after the pipe character. I blame that on you ;)

    Hahaha yes, sorry... I just don't see the need to add spaces either side of the pipe, it doesn't need to be there, and looks better without it imho. I only added them in my example earlier to make more obvious.

    ---
    |14Best regards,
    |11Ch|03rist|11ia|15n |11a|03ka |11Me|03aTLoT|11io|15N

    |07── |08[|10eml|08] |15ml@erb.pw |07── |08[|10web|08] |15www.erb.pw |07───┐ |07── |08[|09fsx|08] |1521:1/158 |07── |08[|11tqw|08] |151337:1/101 |07┬──┘ |07── |08[|12rtn|08] |1580:774/81 |07─┬ |08[|14fdn|08] |152:250/5 |07───┘
    |07── |08[|10ark|08] |1510:104/2 |07─┘

    ... If a pig loses its voice, is it disgruntled?

    --- Mystic BBS v1.12 A47 2021/12/13 (Linux/64)
    * Origin: thE qUAntUm wOrmhOlE, rAmsgAtE, uK. bbs.erb.pw (1337:1/101)
  • From deon@1337:2/101 to MeaTLoTioN on Wed Jan 12 07:48:50 2022
    Re: gnu utils
    By: MeaTLoTioN to All on Tue Jan 11 2022 01:07 pm

    Howdy,

    When trying to get some info from a text file, or command output people tend to do something like;
    $ cat somefile.txt | grep something | wc -l
    This would spit out the contents of somefile.txt, pipe it into grep to filter out just "something" and then count how many lines
    contain
    that "something", perfectly a normal thing to do, but it's so bloated and irks me to no end. Instead of this overly bloated command
    one-liner, this can all be achieved in just a simple one command;

    I dunno, that's just me, my quirkiness lol. Don't judge me =)

    So this is "old school" or somebody who was taught "old school".

    When I learnt unix all those decades ago, I was introduced to unix as a "suite of single functional tools" - in that you can combine the tools together to get a complex job done - without having to write that complex tool.

    I too often find myself doing

    cat somefile | less

    when I could just "less somefile", but I normally do that because I am actually planning on greping, awking, wcing, etc...

    I find it easier knowing that what I want will come from STDIN, and send it to STDOUT, so that the next tool can do its bit, rather than figuring out (often very different) switches to get file read.


    ...δεσ∩
    --- SBBSecho 3.14-Linux
    * Origin: I'm playing with ANSI+videotex - wanna play too? (1337:2/101)
  • From acn@1337:1/108.1 to MeaTLoTioN on Wed Jan 12 16:13:00 2022
    Am 11.01.22 schrieb MeaTLoTioN@1337:1/101 in TQW_LINUX:

    Hallo Meatlotion,

    $ cat somefile.txt | grep something | wc -l

    vs.

    $ grep -c something somefile.txt

    While you are totally right that the latter is much shorter and might
    also be quicker, you have to _know_ and _remember_ that grep is able
    to count on its own.

    Not unlike deon said, the UNIX principle is that you have small tools
    with one functionality each and the UNIX power is the possibility to
    connect them.

    And while the first line is absolutely a good example for a "useless
    use of cat" (that even I wouldn't have written), it is also an example
    for that: get the contents of a file, filter it and count the
    resulting lines.

    To achieve that, you 'only' have to know how to filter using grep and
    how to count lines using wc. That knowledge can be used for many other
    tasks as well.
    Whereas knowing that "-c" in grep can count the occurances of a
    certain thing in a file is kind of a one-off knowledge that might be forgotten sooner than later...

    Regards,
    Anna

    --- OpenXP 5.0.51
    * Origin: Imzadi Box Point (1337:1/108.1)
  • From paulie420@1337:3/129 to MeaTLoTioN on Wed Jan 12 22:22:50 2022
    Something I've seen lots of people do in examples/videos/tutorials keeps on grating on me, and I thought I would share my frustration

    When trying to get some info from a text file, or command output people tend to do something like;

    $ cat somefile.txt | grep something | wc -l

    this can all be achieved in just a simple one command;
    $ grep -c something somefile.txt

    they are assuming the role of a "teacher" of sorts, and should
    know better.

    Happy to know and remember that certain commands have flags and options that might help do things quicker - however, we aren't hurting for CPU these days.... and I'd rather teachers teach the methods they know than to not teach at all - does show, IMO, how these platforms could use better community options and plugs to allow the users to help the teacher. :P

    Remember, theres 100 ways to skin a cat - and I'm always happy to learn a better, faster way. Me0w.



    |07p|15AULIE|1142|07o
    |08.........

    --- Mystic BBS v1.12 A47 2021/12/24 (Raspberry Pi/32)
    * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (1337:3/129)
  • From deon@1337:2/101 to acn on Thu Jan 13 21:04:58 2022
    Re: Re: gnu utils
    By: acn to MeaTLoTioN on Wed Jan 12 2022 04:13 pm

    While you are totally right that the latter is much shorter and might
    also be quicker, you have to _know_ and _remember_ that grep is able
    to count on its own.

    Whereas knowing that "-c" in grep can count the occurances of a
    certain thing in a file is kind of a one-off knowledge that might be forgotten sooner than later...

    The other point to keep in mind, is that different "unixes" have different "options" - but most unixes have the same core basic commands "cat", "grep", "wc", "awk" etc.

    So while and argument might work in Linux (like grep -c), the same argument in BSD might mean something different (in this case, with grep, it doesnt). (I've certainly come across that situation at times).


    ...δεσ∩
    --- SBBSecho 3.14-Linux
    * Origin: I'm playing with ANSI+videotex - wanna play too? (1337:2/101)
  • From MeaTLoTioN@1337:1/101 to acn on Thu Jan 13 11:50:14 2022
    On 12 Jan 2022, acn said the following...

    Am 11.01.22 schrieb MeaTLoTioN@1337:1/101 in TQW_LINUX:

    Hallo Meatlotion,

    Hej Anna =)

    While you are totally right that the latter is much shorter and might also be quicker, you have to _know_ and _remember_ that grep is able
    to count on its own.

    Yes, you are correct, you do have to _know_ and _remember_ that grep can do this, there are others too that can count... I was only using grep as an example as it's probably the most common useless use of cat that I can think of, and it happened to be that exact thing on a video I was watching.

    I have also been thinking that when on the CLI doing something interactively, it might be that you "cat somefile", then just up arrow into the last command and add a " | grep something" and build a command. I guess that's ok, but when scripting it's just bad form in my opinion to do something like that, although I'm pretty sure I have done that in scripts myself without thinking.

    Another gripe I have, more aesthetics of a command over function, is adding spaces either side of the pipe, I would rather;

    somecommand arg1 arg2|grep something|awk '{print $1}'
    vs
    somecommand arg1 arg2 | grep something | awk '{ print $1 }'

    You may laugh, I guess I am too reading this back, but when I "CLI" having spaces with pipes just makes me feel so wrong lol.

    I know someone who won't even have blank lines in scripts, I feel that's taking it a little too far, but at the same time I get it.

    Also, I'm a double-space guy and not a tab guy :P


    Oh well, welcome to the inner workings of my head hahaha

    ---
    |14Best regards,
    |11Ch|03rist|11ia|15n |11a|03ka |11Me|03aTLoT|11io|15N

    |07── |08[|10eml|08] |15ml@erb.pw |07── |08[|10web|08] |15www.erb.pw |07───┐ |07── |08[|09fsx|08] |1521:1/158 |07── |08[|11tqw|08] |151337:1/101 |07┬──┘ |07── |08[|12rtn|08] |1580:774/81 |07─┬ |08[|14fdn|08] |152:250/5 |07───┘
    |07── |08[|10ark|08] |1510:104/2 |07─┘

    ... Honk if you love peace and quiet!

    --- Mystic BBS v1.12 A47 2021/12/13 (Linux/64)
    * Origin: thE qUAntUm wOrmhOlE, rAmsgAtE, uK. bbs.erb.pw (1337:1/101)
  • From hyjinx@1337:2/104 to deon on Sat Mar 19 22:31:06 2022
    deon said:
    So this is "old school" or somebody who was taught "old school".
    of single functional tools" - in that you can combine the tools together t a complex job done - without having to write that complex tool.

    Yep, same here. I learned my first outing in UNIX in 1997 or so at college.
    It was SCO UNIX of some variatey. I believe the teacher taught us about
    piping and cat was commonplace. I don't even know if less was even in that version of UNIX, just more, but I was brought up old school like deon and it stuck with me way too long. In the end I un-taught myself that muscle memory, and whilst I do believe it is un-necessary wasted compute cycles, the
    machines of today shouldn't really cough on it too much, and using cat to
    help explain standard input and output then piping to another command is a
    very clear way to demonstrate the purpose of piping, so I don't go too hard
    on those that would teach this ;)

    Al


    hyjinx // Alistair Ross
    Author of 'Back to the BBS' Documentary: https://bit.ly/3tRINeL (YouTube) alsgeeklab.com

    --- Mystic BBS v1.12 A46 2020/08/26 (Linux/64)
    * Origin: Sent from Al's Geek Lab 1337:2/104 (1337:2/104)