>Write a bash script. >It takes 15 seconds to execute. >Rewrite it in javascript

>Write a bash script
>It takes 15 seconds to execute
>Rewrite it in javascript
>The execution time is down to 1 second
Why are we still using bash, remind me?

It's All Fucked Shirt $22.14

DMT Has Friends For Me Shirt $21.68

It's All Fucked Shirt $22.14

  1. 2 years ago
    Anonymous

    Post the script so we can laugh at you.

    • 2 years ago
      Anonymous

      Ok
      Bash script:
      #!/bin/sh
      hashes=$((qbt torrent list -F json | grep -i "hash" | awk '{print $2}' | sed 's/[",]//g'))
      total=0
      for i in ${hashes[@]}
      do
      otal=$(($(qbt torrent properties $i -F json | grep -i uploaded" | awk '{print $2}' | sed 's/,//') + $total))
      done
      echo $(($total / 1073741824))

      With javascript:
      #!/bin/sh
      qbt torrent list -F json > qbt-buffer.json
      echo "const fs = require("fs");
      const rawData = fs.readFileSync("qbt-buffer.json");
      const parsedData = Array.from(JSON.parse(rawData));
      const devider = 1024 * 1024 * 1024;
      let totalUploaded = 0;
      let totalDownloaded = 0;
      parsedData.forEach(data => { totalUploaded += data.uploaded;
      totalDownloaded += data.downloaded;
      });
      console.log(`Downloaded: ${Math.round(totalDownloaded / devider)}GB nUploaded: ${Math.round(totalUploaded / devider)}GB`);" > torrents.js
      node torrents.js
      rm qbt-buffer.json torrents.js

      • 2 years ago
        Anonymous

        >Array.from(JSON.parse(rawData))
        Good morning, sir!

      • 2 years ago
        Anonymous

        yeah this sort of thing si really not what i would use bash for, text processing, actually using bash arrays, it's just not good
        you can do all of what you wrote just in awk alone btw

      • 2 years ago
        Anonymous

        lmao

        • 2 years ago
          Anonymous

          lol

          works on my machine

      • 2 years ago
        Anonymous

        lol

      • 2 years ago
        Anonymous

        Why are you calling qbt in a loop in bash but not in js?

        • 2 years ago
          Anonymous

          Looks like I was full of shit. I rewrote it without repeated qbt calls and it takes 2 seconds to execute now.
          Although js would probably execute faster too if I wasn't too lazy to learn how to execute commands from node directly instead of using a moronic bash wrapper.

          • 2 years ago
            Anonymous

            sh = require('shelljs')

      • 2 years ago
        Anonymous

        That's some hilarious shit, thanks for sharing.

      • 2 years ago
        Anonymous

        BAHAHAHAHHAHAHAHA
        Good one anon. Are You the same gay who got really angry over bash sometime ago?
        You created an entire thread with "post the worst programing languages, i'll start" and complained that your shitty script with arrays doesn't work.

        • 2 years ago
          Anonymous

          And in the end Perl won

          • 2 years ago
            Anonymous

            >perl
            makes too much sense to have a role in the current meta

          • 2 years ago
            Anonymous

            what?

      • 2 years ago
        Anonymous

        You know, shit like parallel and xargs exist right?

        • 2 years ago
          Anonymous

          Also, all of that can be done in awk not bash

      • 2 years ago
        Anonymous

        Just write in python, lua, or golang like a normal scripter

        • 2 years ago
          Anonymous

          >golang
          >script
          Dumbfrick, that should be Perl

          • 2 years ago
            Anonymous

            no one uses perl anymore, dunno why you can't comprehend that, you must be unemployed

          • 2 years ago
            Anonymous

            tbh if youre a sysadmin and you are writing scripts in perl instead of python most places wont give a shit. its still very popular among boomers

          • 2 years ago
            Anonymous

            zoom zoom

          • 2 years ago
            Anonymous

            tbh if youre a sysadmin and you are writing scripts in perl instead of python most places wont give a shit. its still very popular among boomers

            look at these homosexuals still using perl, fricking dumb zoomer troonys KEK. perl sucks wiener, never seen it in the wild. gayS

      • 2 years ago
        Anonymous

        >echoing the program to a file in bash and running node on it, then removing it
        my fricking sides
        OP as always a homosexual

        • 2 years ago
          Anonymous

          >you are not allowed to be new to scripting

          • 2 years ago
            Anonymous

            OP needed to read the sticky before he made another thinly veiled tech support thread

          • 2 years ago
            Anonymous

            Being new to scripting is fine. Fricking up and blaming an entire shell is another thing entirely.

          • 2 years ago
            Anonymous

            you literally blamed bash for you being a moron

      • 2 years ago
        Anonymous

        I'm sure this would take 2 or 3 lines of perl, but I want to see an example output of
        qbt torrent list -F json
        and
        qbt torrent properties $i -F json

        • 2 years ago
          Anonymous

          The only thing good about perl, is it's regex engine

          • 2 years ago
            Anonymous

            5ms startup time
            practical cli flags
            easy syntax which doesn't require parentheses
            functions taking a list and returning a list
            grep (filter), map
            closures
            both lexical and dynamic scoping

            >its regex engine
            not only the engine itself but how it interfaces seamlessly with the language, with a syntax for it, special operators and match variables set each time a match attempt is made

            But sure sweety, whatever to help you sleep better

      • 2 years ago
        Anonymous

        Well you are using javascript's data sructure in the bash script, try coding a javascript script with unix csv files.

        The right tool for the right job or something.

        Also bash runs in like 10kb in machines as old as 1991. To run js you need to get pozzed by downloading at least a couple of Gs

      • 2 years ago
        Anonymous

        lmfao your shitty script doesn't even work

      • 2 years ago
        Anonymous

        there's no way this is real, this is too moronic to be believed. i can tell whoever wrote this is indian.

      • 2 years ago
        Anonymous

        >echo to file outside of /tmp
        >execute file
        >remove file
        Good day Sir

      • 2 years ago
        Anonymous

        learn to use /tmp you fricking curryeater

      • 2 years ago
        Anonymous

        how's the weather in rampajesh, delhi good sir have you done the needful benchod

      • 2 years ago
        Anonymous

        there's so much wrong in your bash script I don't know where to begin

      • 2 years ago
        Anonymous

        >json to grep to awk to sed for json parsing
        >one uses an external program another doesnt
        anon i...

      • 2 years ago
        Anonymous

        $ time perl -MJSON="from_json" -E 'my ($u, $d); map { $d += $_->{downloaded}; $u += $_->{uploaded}; } @{ from_json qx/qbt torrent list -F json/}; say "Downloaded : $dnUploaded : $u";'
        Downloaded : 104381889869
        Uploaded : 2402172754
        perl -MJSON="from_json" -E 0,61s user 0,02s system 96% cpu 0,646 total

        • 2 years ago
          Anonymous

          Ok I forgot to divide the up/download values by 1024^3, but it doesn't matter in the end
          $ time perl -MJSON="from_json" -E 'my ($u, $d); map { $d += $_->{downloaded} / 1024**3; $u += $_->{uploaded} / 1024**3; } @{ from_json qx/qbt torrent list -F json/}; say "Downloaded : $d GBnUploaded : $u GB";'
          Downloaded : 97.2132104160264 GB
          Uploaded : 2.23719771392643 GB
          perl -MJSON="from_json" -E 0,60s user 0,02s system 96% cpu 0,638 total

        • 2 years ago
          Anonymous

          JSON::XS anon, JSON::XS

      • 2 years ago
        Anonymous

        Jesus christ

      • 2 years ago
        Anonymous

        that's some horrendous JavaScript holy shit

        • 2 years ago
          Anonymous

          Untested:

          const data = require("./qbt-buffer.json");
          const sum = {
          downloaded: data.reduce((a, b) => a.downloaded + b.downloaded, 0),
          uploaded: data.reduce((a, b) => a.uploaded + b.uploaded, 0),
          };

          console.table(sum);

      • 2 years ago
        Anonymous

        >grep awk sed in the same line
        >create and remove de same file

      • 2 years ago
        Anonymous

        is this the power of javascript shills?

      • 2 years ago
        Anonymous

        you fricking suck and should stop using computers entirely.

      • 2 years ago
        Anonymous

        use jq

      • 2 years ago
        Anonymous

        Good Looking, Perfect for gorgeous looks, can push asap

  2. 2 years ago
    Anonymous

    >fpbp
    >no response from op

    • 2 years ago
      Anonymous

      I don't sit here refreshing the page 20 times per second, Black person.

      • 2 years ago
        Anonymous

        >refreshing the page 20 times per second
        turn on auto update moron

  3. 2 years ago
    Anonymous

    idk
    i use perl and it just werks

  4. 2 years ago
    Anonymous

    bash is useful for piping programs together and otherwise executing stuff in order
    doing that with node/python/etc involves writing lots of exec() calls where you just write the bash into the script
    so the benefits of the language dont really offer much at all in this case
    that's why we have bash

  5. 2 years ago
    Anonymous

    Why does it even have to be fast? It's a shell, not a programming language.
    If you want the system do do baka for you, on a system level, use a shell.
    If you want to process data, use interpreted langs.

  6. 2 years ago
    Anonymous

    stop writing shitty scripts and blaming bash?

  7. 2 years ago
    Anonymous

    bruh put a & at the end so it gets done all at once
    #!/bin/sh
    hashes=$((qbt torrent list -F json | grep -i "hash" | awk '{print $2}' | sed 's/[",]//g'))
    total=0
    for i in ${hashes[@]}
    do
    otal=$(($(qbt torrent properties $i -F json | grep -i uploaded" | awk '{print $2}' | sed 's/,//') + $total)) &
    done
    wait
    echo $(($total / 1073741824))

    then put a 'wait' just before the final echo

    • 2 years ago
      Anonymous

      also you used 'otal' instead of 'total' in the loop but i didn't fix it.

      • 2 years ago
        Anonymous

        I didn't it's an epic copypaste failure.

        • 2 years ago
          Anonymous

          personally i love bash its really easy

          • 2 years ago
            Anonymous

            >greps cat output out of convenience
            Guilty as frick
            >grep cat output in a loop and use carriage returns so as not to not clutter the terminal
            Also guilty

          • 2 years ago
            Anonymous

            One thing that I enjoy about BASH and UNIX scripting are pipes. Pipes are amazing. They take the idea of composition and extend it in a very elegant way. Instead of following the functions you follow the flow of data.

            function application notation:
            f(g(h))

            pipes:
            h | g | f

            Its honestly pretty based to write your programs so that they can be piped in this way. You get to ignore values at this level. You're moving the data from one program to another without having to worry about the data itself. You only worry about the data when you're writing the program itself. Different programming styles at different levels.The use of pipes also allows you to reason about your programs algebraically.

            That's the beauty of *nix. You implement your software in an imperative language like C where you have strict types. Once it reaches the level of programs sending values to one another, you're in the realm of things like pipes.

            Check out concatenative languages. They're kind of in the realm of "toy languages" but they have interesting properties. Really makes you appreciate pipes. Also download "data oriented programming: unlearning objects". Excellent book. Data Oriented Programming is basically what React tries to implement in JS.

            Cheers from an insomniac

          • 2 years ago
            Anonymous

            Pipes are the epitome of UNIX brainrot. The reason is so simple that you can see it right there in your post.
            f | g | h ≠ h(g(f(*~~
            Every program needs a weird extra input that is sometimes there and sometimes not. Any other programming language would obviously ditch this moronic misfeature. Imagine if all Python functions had a random bonus stream input. It would be completely moronic. Any competent language designer would make x | y = y(x()), that would be so simple.
            Why not do that in sh?
            Because they needed a stream as input but designed a system so stupid that every function can only except strings. Instead of taking a step back and re-evaluating the design of the language when they hit this issue, they just give every function in it one extra input of the type they need.

            Python of all languages actually solves this quite neatly, though it's syntax isn't suited for shell scripting. Instead of every function being an executable with a main entry point, you have libraries that are loaded and then wrapped in Python functions with FFI. That way you can do all of your shell scripting in a real programming language with types.
            If Python had a bash-like syntax you could, without too much effort, set it up as a shell that is far better than POSIX sh.

            Isn't it crazy how much better the python way is?
            You can write a + b and have it actually add them together. You could have a program that takes numbers as inputs. You could have a program with two input streams. One that works on a stream of integers instead of a stream of characters. A program could have multiple functions in it. You wouldn't need to have every program implement its own parser for the inputs. In turn this might eliminate all those different key/value file formats since a program could just take a dictionary of its settings as an input, and leave reading the file up to the shell.
            It's hard to overstate how many things about personal computing would be improved by this small change.

          • 2 years ago
            Anonymous

            Well, there's this
            https://xon.sh/
            Doesn't sound too stable, as most of Python's ecosystem, but neat regardless.

          • 2 years ago
            Anonymous

            Fascinating, will check this out

          • 2 years ago
            Anonymous

            Is a neat idea but i think i now understand why it didn't take off. Python's dependencies and package manager. Under the traditional model, is already kinda tricky to provide a base Python interpreter to do system tasks while giving the user room to install and manage another, probably better one (which you'll eventually if you work with Python) now you'd have to maintain a xonsh-like shim and ensure its modules play well along with the rest of the system (specially from a security perspective) and ensure xonsh doesn't do anything funny if it has a conflict trying to call the ones that come with user's custom Python version.
            In theory, xonsh developer are smart enough and ensures its core functionality won't break if you put in your path another Python version within a bare minimum (i.e. 3.6 and beyond like it is right now) so xonsh can be a global module and let the user pick whatever version they want, and as the distros' official package manager wouldn't offer an older version than xonsh' minimum requirement, is on user's side burden if they get out of their way to frick it. However, hat's not an easy task to keep up for volunteers, and there's the deal with using venvs to maintaing legacy projects (that puts and old ass Python version in your path), or if xonsh just happen to update too fast.

          • 2 years ago
            Anonymous

            >f | g | h ≠ h(g(f(*~~
            How?

          • 2 years ago
            Anonymous

            $ sed $(echo test) 's/e/w/'
            sed: can't find label for jump to `est'
            $ echo test | sed 's/e/w/'
            twst

          • 2 years ago
            Anonymous

            For a start, filename goes after the substitution string and you should be using <() not $(). I don't have bash in this PC but I'm sure if you wrote it as this you'd get the same result:
            $ sed s/e/w/ <(echo test)
            But anyway, parameters and stdin are different things. You wrote
            >f | g | h ≠ h(g(f(*~~
            f, g and h would include the parameters.
            f := cat test
            g := sed s/e/w/
            h := less
            cat test | sed /s/e/w/ | less
            Is always the same thing as
            cat test > file
            sed /s/e/w/ file > file2
            less file2

          • 2 years ago
            Anonymous

            There is no formal equivalence here. Just because some programs happen to interpret their last argument as a file and open it doesn't mean those things are always the same.
            In fact it is trivial that they are different.
            If:
            f = echo p
            g = sed file -f
            $ echo contents > file

            For f | g
            $ echo p | sed file -f
            sed: option requires an argument -- 'f'

            For g(f())
            $ echo p > script
            $ sed file -f script
            contents
            contents

            ∴ f | g ≢ g(f())

            >For a start, filename goes after the substitution string and you should be using <() not $()
            I am not making an error by accident. The $() is to pass the argument to the command to facilitate the proof that f | g ≠ g(f()).
            All you do case is rewrite a pipe to look a little different. $() actually passes it as an argument.

          • 2 years ago
            Anonymous

            I'm unsure what your point is

          • 2 years ago
            Anonymous

            I don't get what your point is.
            You didn't like my original justification for my claim, and said that it would hold if the functions where called in a specific order, so I gave you a counterpoint using that order.
            If you don't get my overall point, I encourage you to go back and read

            Pipes are the epitome of UNIX brainrot. The reason is so simple that you can see it right there in your post.
            f | g | h ≠ h(g(f(*~~
            Every program needs a weird extra input that is sometimes there and sometimes not. Any other programming language would obviously ditch this moronic misfeature. Imagine if all Python functions had a random bonus stream input. It would be completely moronic. Any competent language designer would make x | y = y(x()), that would be so simple.
            Why not do that in sh?
            Because they needed a stream as input but designed a system so stupid that every function can only except strings. Instead of taking a step back and re-evaluating the design of the language when they hit this issue, they just give every function in it one extra input of the type they need.

            Python of all languages actually solves this quite neatly, though it's syntax isn't suited for shell scripting. Instead of every function being an executable with a main entry point, you have libraries that are loaded and then wrapped in Python functions with FFI. That way you can do all of your shell scripting in a real programming language with types.
            If Python had a bash-like syntax you could, without too much effort, set it up as a shell that is far better than POSIX sh.

            Isn't it crazy how much better the python way is?
            You can write a + b and have it actually add them together. You could have a program that takes numbers as inputs. You could have a program with two input streams. One that works on a stream of integers instead of a stream of characters. A program could have multiple functions in it. You wouldn't need to have every program implement its own parser for the inputs. In turn this might eliminate all those different key/value file formats since a program could just take a dictionary of its settings as an input, and leave reading the file up to the shell.
            It's hard to overstate how many things about personal computing would be improved by this small change.

            .
            If a pipe was (as it should be) partial function application, they would be much easier to use. The issue is that you can't just move the pipe input to an argument because shell has no way to pass a stream to a function.
            Their solution was to make every function take a single stream as an input.
            Instead of streams being a simple and useful data structure, they have to be the basis for the entire shell. Even then you can only pass one of them to a given function.
            It is blatantly horrible design.

          • 2 years ago
            Anonymous

            >$ cat schedule.txt
            >$
            My sides

    • 2 years ago
      Anonymous

      that doesn't seem safe

  8. 2 years ago
    Anonymous

    >Write a bash script
    >It takes 15 seconds to execute
    >Rewrite it in javascript
    >feel the urge to take estrogen supplements

  9. 2 years ago
    Anonymous

    take the PowerShell pill anon

    >Why yes, I do append -ExecutionPolicy Bypass everytime I execute a powershell command. How could you tell?

  10. 2 years ago
    Anonymous

    How are you going to execute JS on any system with no internet? Checkmate, autist.

    • 2 years ago
      Anonymous

      >How are you going to execute JS on any system with no internet?
      you can't run JS without internet? that sounds like BS anon ngl

      • 2 years ago
        Anonymous

        it isn't. You can't run Python either because it's not installed by default on many systems unlike Bash. Bash is for max compatibility.

        • 2 years ago
          Anonymous

          python is barely compatible with python

          • 2 years ago
            Anonymous

            That's a part of it. Can't expect to execute 3 on systems with 2 and that's why, I believe, some Yandex tools were rewritten in 2 after a quick prototype in 3.

          • 2 years ago
            Anonymous

            factual. reason i quit using python

        • 2 years ago
          Anonymous

          >it's not installed by default
          Then install it.

        • 2 years ago
          Anonymous

          >because it's not installed by default
          >yeah bro just write your torrenting script in bash in case the machine you're torrenting on doesn't have internet so you can't install node on it
          lol
          lmao

          • 2 years ago
            Anonymous

            > works on my machine
            The question was
            > Why are we still using bash
            Because "we" support airgapped and proxied networks. Frick your torrent or whatever, you can DL it with utorrent and never bother with Linux in the first place, for all I know.

      • 2 years ago
        Anonymous

        no its true

        If it's not a builtin or keyword, is it really bash?
        OK ok it's a command interpreter as well as a shell, but is calling half a dozen external binaries in a script really bash?

        are calling external libraries that use other languages really using those languages?

        is not everything just binary? aren't we all binary programmers, at the end of the day?

        maybe we're just atom programmers.

        • 2 years ago
          Anonymous

          >no its true
          but it works tho

  11. 2 years ago
    Anonymous

    If it's not a builtin or keyword, is it really bash?
    OK ok it's a command interpreter as well as a shell, but is calling half a dozen external binaries in a script really bash?

  12. 2 years ago
    Anonymous

    We use zsh

  13. 2 years ago
    Anonymous

    Bash is better or worse suited for certain tasks regarding on what you want to do. Overall, if what you need to do with a shell requires calling TOO MANY external processes and rely on the correctness of their output to give it to something else (as opposed to, let's say, just throw a bunch of stuff to xargs and/or parallels and let them do the job) you're better off using something else in the long run, if you're relying on summoning external tools the language you choose doesn't matter much, all of them have to summon native processes, the point is taking advantage of the language's features to not do that when possible, and a real programming language has many of them over Bash's, i.e. Python's builtin JSON parser or requests instead of calling jq or curl.

  14. 2 years ago
    Anonymous

    Maybe if you stopped pipping sed into awk into grep into tr into sed into sort into uniq into wc and started learning Perl you wouldn't have this problem

    • 2 years ago
      Anonymous

      >learn this deprecated shit language because you're moronic in the language you should be using
      moron

      • 2 years ago
        Anonymous

        Perl, as bash on steroids, is eternal. It's only deprecated as a universal language.

        • 2 years ago
          Anonymous

          https://www.tiobe.com/tiobe-index/perl/
          pffffffffffffffffftttttHAHAHAHAHAHAHA

          • 2 years ago
            Anonymous

            not him but this contradicts nothing he said

          • 2 years ago
            Anonymous

            you're right, you can still use obscure languages no one will ever use ever again if you really want to. you can use Pascal or Fortran if you really wanted to. good luck using those languages in any real setting though

          • 2 years ago
            Anonymous

            >muh obscure
            this still contradicts nothing he said and makes no point against using perl over bash
            try harder zoomer-kun

          • 2 years ago
            Anonymous

            >MUST DEFEND SHIT LANGUAGE
            pffffffftthahahahaha

          • 2 years ago
            Anonymous

            that's a nice baby duck syndrome you got there

            >they still can't make a single point against using perl over bash
            heh

          • 2 years ago
            Anonymous

            >they still can't make a single point against using fortran over bash
            heh

          • 2 years ago
            Anonymous

            sure i can, fortran isn't convenient for unix scripting, unlike perl which is not only more convenient but also faster than bash.
            keep coping though

          • 2 years ago
            Anonymous

            >muh convenient
            convenient is a matter of opinion

          • 2 years ago
            Anonymous

            kek, but speed isn't

            perl is slow as shit. cope. there are much more convenient and fast languages, you're an idiot haha

            >there are much more convenient
            for unix scripting? for example?
            >and fast languages
            perl is infinitely faster than bash while at the same time being convenient to script in.
            C is obviously faster than perl, but scripting and string manipulation is infinitely more convenient in perl. using C for op's json parsing problem would be moronic for example

          • 2 years ago
            Anonymous

            You could even use perl to prototype a C program.
            Perl gives you easy access to fork, pipe, select, fifos, sockets...

          • 2 years ago
            Anonymous

            perl is slow as shit. cope. there are much more convenient and fast languages, you're an idiot haha

          • 2 years ago
            Anonymous

            Still faster than any gayman approved interpreted language out there by a sizeable margin.

          • 2 years ago
            Anonymous

            >gayman approved
            IQfy meme idiot detected
            >i need a fast language to run bash terminal commands
            absolute fricking idiot as usual on IQfy
            >doesn't know how to script
            obviously

          • 2 years ago
            Anonymous

            >i need a fast language to run bash terminal commands
            How's Perl any slower and less suited for this task then? I amn't the one claiming that is slow as shit.

          • 2 years ago
            Anonymous

            if you think you need a fast programming language to run shell commands then you've just revealed yourself to not know what you're doing and why, there's really no way around this OP

          • 2 years ago
            Anonymous

            >if you think you need a fast programming language to run shell commands then you've just revealed yourself to not know what you're doing and why,
            if you think that op's script would translate to a bunch of shell commands but in perl then you've just revealed yourself to not know what you're talking about. the only shell command he needs to run is that first qbt torrent one to get the json and then do all the looping and string manipulation with just perl, making the script much faster, which is what he was complaining about initially.

          • 2 years ago
            Anonymous

            I amn't the one claiming that Perl is unsuitable to replace bash because is slow shit. You tell me. You're the one telling that speed doesn't matter for this task, i am just pointing out this.
            For the record, i use Python frecuently, but when is pertinent, but Perl one liners are much more convenient when mixed on shell scripts compared with the different flavours and versions of AWK/Sed/Grep supporting different syntaxis and features present across a lot of different Unix boxes, and certainly better than dealing with different Python versions' for the right tasks.

          • 2 years ago
            Anonymous

            >if you think you need a fast programming language to run shell commands then you've just revealed yourself to not know what you're doing and why,
            if you think that op's script would translate to a bunch of shell commands but in perl then you've just revealed yourself to not know what you're talking about. the only shell command he needs to run is that first qbt torrent one to get the json and then do all the looping and string manipulation with just perl, making the script much faster, which is what he was complaining about initially.

            use posix shell, you overengineering moron pajeets are so fricking dumb. MUH SPEED. for shell commands? no, moron

          • 2 years ago
            Anonymous

            >for shell commands
            again, that's where you're wrong. it's not a "shell command" script. it's a string manipulation script, which perl happens to excel at. using posix sh or bash for this forces you do said string manipulation with shell commands, which makes your script slower. perl is objectively an upgrade over shell in this case.

          • 2 years ago
            Anonymous

            for string manipulation i would just use python, you don't need speed, just use the most popular thing. why make your life difficult

          • 2 years ago
            Anonymous

            Python's regex is very similar to PCRE anyways. Besides, is handy for one offs. Nobody is writing deployment scripts on Perl but that doesn't stop it from being useful to clean up some logs ocassionally. Is just a tool that does it fine for problems of a smaller scope.

          • 2 years ago
            Anonymous

            >you don't need speed
            that's literally what this thread is about. op was complaining about the speed of his pajeet tier script, which he then rewrote in a slower language with better json support, giving the impression that it's faster
            >just use the most popular thing. why make your life difficult
            how does this correlate? a language's popularity has absolutely no impact on how well suited that language is for a given task, and the point i'm arguing is that perl is a better tool for this task than bash, and people started seething

          • 2 years ago
            Anonymous

            Are you going to keep contradicting yourself just to not admit a non gayman tool can be handy for certain tasks?

          • 2 years ago
            Anonymous

            anything i don't like is something called "gayman"

          • 2 years ago
            Anonymous

            that's a nice baby duck syndrome you got there

          • 2 years ago
            Anonymous

            >they still can't make a single point against using fortran over bash
            heh

            Fortran is still widely used in scientific computing. Keep coping though zoomzooms

          • 2 years ago
            Anonymous

            >TIOBE
            pffffffffffffffffftttttHAHAHAHAHAHAHA

          • 2 years ago
            Anonymous

            >TIOBE
            let's compare x86, Python, Java and Fortan
            LOL

          • 2 years ago
            Anonymous

            [...]
            Fortran is still widely used in scientific computing. Keep coping though zoomzooms

            [...]
            look at these homosexuals still using perl, fricking dumb zoomer troonys KEK. perl sucks wiener, never seen it in the wild. gayS

            use posix, then bash, then python, then c. that's it. everything else is totally irrelevant and for pedos

          • 2 years ago
            Anonymous

            Anyone who thinks POSIX is anything more than a sad joke is an idiot, and their opinion can be safely discarded.

            this thread is the biggest fricking cope. no one even uses perl anymore, what absurd level of cope is this?

            >I do not use it so no one does

          • 2 years ago
            Anonymous

            I use Perl any time I can. It helps that modern JS is incredibly similar to modern Perl, and its hard to avoid having to use JS these days. The biggest differences are sigils, the order in which functions/keywords are chained together, and JS being slightly less expressive than Perl. Also you'll have a hard time finding a *nix that doesn't have Perl installed by default, and unless you're using some legacy unsupported release you'll have a very easy time dealing with whatever you're trying to do. Its ridiculously easy to bundle 3rd party CPAN modules too, so you don't have to worry about users not having those installed. I will say though, the core modules leave a fair amount of things to be desired. All of the <module name>::Tiny with lots of community support and large user bases should be included by default, and so should popular DB drivers.

            factual. reason i quit using python

            use python you moron autists, cya

          • 2 years ago
            Anonymous

            Python is garbage at everything. Perl is also garbage for most things, but it is at least good for text processing.

          • 2 years ago
            Anonymous

            >still defending perl
            kek unreal

          • 2 years ago
            Anonymous

            I accept your concession.

          • 2 years ago
            Anonymous

            I don't like being forced to use whitespace the way they want me to, and I'm pretty sure their variable scoping is pretty fricked. At least Perl and JS provide keywords and other restrictions to ensure you're using the variable you intend on using

            By the way did they ever fix variable scoping in PHP? Last I checked you could declare one inside of a block but still have access to it outside of said block? That's insanity

            is this the power of javascript shills?

            use python, bye guys! 🙂

          • 2 years ago
            Anonymous

            Python breaks almost every three minor versions, defeats the purpose of cross platform scripting. Is OK with Anaconda or docker but i wouldn't trust it for anything that touches files or network rules on more than a single bare system.

          • 2 years ago
            Anonymous

            >Python breaks almost every three minor versions
            nice lie, IQfy homosexual, it doesn't. the issue is you making up shit. python doesn't break, you're just a stupid homosexual. do you understand?

          • 2 years ago
            Anonymous

            python sucks shit and only poojeets like yourself should use it.

          • 2 years ago
            Anonymous

            You never have used it for anything but requests, right? Is a tool, not your ego. It has uses and flaws like everything else and lying about them doesn't change them. Or were the 3.6.x shitfests just a bunch of people on StackOverflow making shit up.

          • 2 years ago
            Anonymous

            >Is a tool
            the esl eurotard always reveals himself, fricking stupid homosexual europoor piece of dog shit is always the stupidest person on the planet

          • 2 years ago
            Anonymous

            I don't like being forced to use whitespace the way they want me to, and I'm pretty sure their variable scoping is pretty fricked. At least Perl and JS provide keywords and other restrictions to ensure you're using the variable you intend on using

            By the way did they ever fix variable scoping in PHP? Last I checked you could declare one inside of a block but still have access to it outside of said block? That's insanity

          • 2 years ago
            Anonymous

            tiobe's methodology is moronic, they basically put "(language) programming" into a some search engines and use that to determine their rankings. They have a detailed explanation here:

            https://www.tiobe.com/tiobe-index/programminglanguages_definition/

          • 2 years ago
            Anonymous

            sounds like someone is butthurt that their favorite language they can't give up is long dead

  15. 2 years ago
    Anonymous

    man history.3
    history -cr my_bash_one_liners.txt && history -w

  16. 2 years ago
    Anonymous

    OP doesn't have a job, it's pretty obvious

  17. 2 years ago
    Anonymous

    >parseing json in bash
    >without jq
    >piping awk to grep to sed

    OP by chance are you taking titty skittles?

  18. 2 years ago
    Anonymous

    what’s so bad about his bash script holy shit

    • 2 years ago
      Anonymous

      nothing, OP is a typical IQfy idiot not knowing what he's doing or why. bash is great, posix shell is awesome too. both great for most things where you don't need ultra efficient performance or data manipulation, which is like 70% of things

  19. 2 years ago
    Anonymous

    Bash runtime is tiny compared to JS runtime.

  20. 2 years ago
    Anonymous

    >op was complaining about the speed of his pajeet tier script
    shell commands don't need C language speed, stop a moron, posix or bash is fine, and if you need more of an ability to manipulate data use python. this whole "MUH REQUIREMENTS" thing is bullshit, just because someone says they need something doesn't mean they actually need it or know what they are talking about or know that they need or don't need what they're asking for

    • 2 years ago
      Anonymous

      >you don't NEED speed!!!! because i said so!!
      lmao anon, just give it up already. you can cope all you want about this but it doesn't change the fact that perl is the best tool for this task.

      • 2 years ago
        Anonymous

        >MUST CLING TO PERL
        cope

        • 2 years ago
          Anonymous

          i'm not clinging to anything, in fact i wouldn't use perl for anything too complicated since it can quickly become unreadable/unmaintainable. i'm literally just saying that perl is the best tool for simple string manipulation tasks like the one op is showing, and so far you've said nothing worthwhile or concrete against that

    • 2 years ago
      Anonymous

      >if you need more of an ability to manipulate data use python
      Good luck writing a python one liner

      • 2 years ago
        Anonymous

        Perl is suited for text transformation up to certain extend, there's a point where Python is preferable. Both are fine when the task requires it honestly.

  21. 2 years ago
    Anonymous

    Did OP just write a script to write a script then delete it.

    • 2 years ago
      Anonymous

      I think he didn't know how to use a native shell command to exec the qbt tool. 2bh, i don't know how, either, i have never used Javascript as a system scripting language. Is it even possible to invoke a shell command on Node.js at all? One might think that not because that's out of JS design scope, but i amn't a expert.

      • 2 years ago
        Anonymous

        yes it is possible
        https://nodejs.org/api/child_process.html#child_processexeccommand-options-callback
        this is clunkier than bash though by a lot, imho

        • 2 years ago
          Anonymous

          Looks like something on the lines of a Heredoc could be useful for a script like that one, like the answers on this blogpost
          https://scriptingosx.com/2021/11/the-unexpected-return-of-javascript-for-automation/
          Or this
          https://magnusviri.com/using-heredocs-in-apple-remote-desktop-to-run-perlpythonruby-code.html
          Fricking painful since it still follows the shell token expansion, but doable with a lot of quoting.

        • 2 years ago
          Anonymous

          much clunkier than bash, as clunky as python. shelljs makes it easier but that's an npm install away

          • 2 years ago
            Anonymous

            I think the quickest way to solve OP's problem would be with a Heredoc as this suggest

            Looks like something on the lines of a Heredoc could be useful for a script like that one, like the answers on this blogpost
            https://scriptingosx.com/2021/11/the-unexpected-return-of-javascript-for-automation/
            Or this
            https://magnusviri.com/using-heredocs-in-apple-remote-desktop-to-run-perlpythonruby-code.html
            Fricking painful since it still follows the shell token expansion, but doable with a lot of quoting.

            is not by any means something that would scale well but OP's script is quite short so it wouldn't take much to properly escape all dangerous characters.

          • 2 years ago
            Anonymous

            yeah op should deffo use a heredoc

          • 2 years ago
            Anonymous

            morons can't do that

  22. 2 years ago
    Anonymous

    >Why are we still using bash, remind me?
    Need more argument parsing errors. Funny online scripts that remove your home directory.

  23. 2 years ago
    Anonymous

    Licensing and momentum unironically. You can have two shells symlinked to the right spots, like Debian that uses dash for anything system wide and lets bash sit as the user interactive shell, so not that much usefulness on bash being POSIX compliant except on legacy systems. Features, process redirection aside, aren't groundbreaking enough to warrant the extra code surface and slowness (dash was created because bash was slow) in contrast with other modern shells that include many more at least. If bash hadn't come at the right moment and being the strongest GPL option available and integrated with the coreutils, i don't think it'd have gone too far.

  24. 2 years ago
    Anonymous

    why are YOU still using bash?

    • 2 years ago
      Anonymous

      Just werks for the right tasks.

  25. 2 years ago
    Anonymous

    this thread is the biggest fricking cope. no one even uses perl anymore, what absurd level of cope is this?

    • 2 years ago
      Anonymous

      I use Perl any time I can. It helps that modern JS is incredibly similar to modern Perl, and its hard to avoid having to use JS these days. The biggest differences are sigils, the order in which functions/keywords are chained together, and JS being slightly less expressive than Perl. Also you'll have a hard time finding a *nix that doesn't have Perl installed by default, and unless you're using some legacy unsupported release you'll have a very easy time dealing with whatever you're trying to do. Its ridiculously easy to bundle 3rd party CPAN modules too, so you don't have to worry about users not having those installed. I will say though, the core modules leave a fair amount of things to be desired. All of the <module name>::Tiny with lots of community support and large user bases should be included by default, and so should popular DB drivers.

  26. 2 years ago
    Anonymous

    bash is sexy and you are not

  27. 2 years ago
    Anonymous

    use posix, then bash, then python, then c. that's it. everything else is totally irrelevant and for pedos

  28. 2 years ago
    Anonymous

    i cannot believe someone is using perl still how moronic do you have to be kek that's dumb

    • 2 years ago
      Anonymous

      That's easy to surprass. There're people using Javascript for writing CLI tools right now.

  29. 2 years ago
    Anonymous

    perl isn't even used anymore, good luck getting a job KEK

    • 2 years ago
      Anonymous

      Jobs aside its a cleaner and more flexible version of bash and it's a great tool for system scripting. I still use it for prototyping web app backends but I accept that outside of maintaining legacy code and startups founded by autists such as myself there's next to no paying jobs for it

      • 2 years ago
        Anonymous

        [...]
        [...]
        use python, bye guys! 🙂

    • 2 years ago
      Anonymous

      that's like saying shell scripts and awk aren't used anymore

      • 2 years ago
        Anonymous

        shell is used all the time by everyone, so is awk. perl isn't. cya

        • 2 years ago
          Anonymous

          perl is just shell combined with awk so there's no reason to not use it

          • 2 years ago
            Anonymous

            shell is used all the time by everyone, so is awk. perl isn't. cya

  30. 2 years ago
    Anonymous

    >MUH ONE LINER
    >MUH PERFORMANCE
    >for shelll scripts
    why is IQfy this stupid?

    • 2 years ago
      Anonymous

      Unix is made of C and shell scripts. Shell scripting performance is extremely important to think about when most tasks are done on Unix-like systems.

    • 2 years ago
      Anonymous

      >MUH PERFORMANCE
      Yes that's what the thread is about

    • 2 years ago
      Anonymous

      95% of the use a shell should've is chaining one liners and you can cite a ton of experts that behemontly agree, you shot yourself in the foot for being le epic hackerman against a non trendy DSL.
      >Muh speed
      Speed matters for specific tasks even on a shell, that's why the Debian fiasco came to be.

  31. 2 years ago
    Anonymous

    You only need JavaScript and Node for everything. Nothing else matters.

  32. 2 years ago
    Anonymous

    for bash commands you only need bash

  33. 2 years ago
    Anonymous

    why bother with perl, no point other than severe baby duck syndrome

    • 2 years ago
      Anonymous

      Is faster than learning the differences among three versions of awk and sed and less limited than sticking to the POSIX ones, while still widespread enough among old and modern systems. Perl may not be the first language i'd reach to write CLI applications that handle lots of logic but the ability to do adhoc oneliners for text processing is handy when needed.

    • 2 years ago
      Anonymous

      i learned perl after python, and i use them both. python just isn't as good as a sed/awk replacement.

  34. 2 years ago
    Anonymous

    #!/bin/bash
    sleep 15

    • 2 years ago
      Anonymous

      the perfect script doesn't exi-

  35. 2 years ago
    Anonymous

    Well yeah if you're going to do web scripts JavaScript is fine. But I assume most scripts aren't web related.

  36. 2 years ago
    Anonymous

    Not that many scripts use Bash specifically. Besides aren't you supposed to use Python or something at the point when stuff gets too complicated for the standard shell?

    • 2 years ago
      Anonymous

      Mostly. There's a plethora of tools you'd use for CLI applications that outbeat old shell when you don't need portability, Python and Go (when you need something more reliably that doesn't involve data science) being the hottest kids on the yard lately, but there's also Perl, Lua, Tcl, some Scheme/Lisp implementations, Deno with Typescript, any JVM with GraalVM. Is all on personal taste and requirements. Overall, tying yourself to a single shell like Bash isn't worth unless your scope is narrow (only your own system or very homogeneus ones you've access to) for the inconsistence on availability of features (Bash 5.0 is different from Bash 4.0 and earlier, very corcening metacharacters interpretation bugs fixed on later releases i.e.) if you're going to deal with that, is better use a proper programming language.

  37. 2 years ago
    Anonymous

    Better type safety

  38. 2 years ago
    Anonymous

    There are people in this thread that don't have comfy jobs writing perl for 200k+?

    Sad.

    • 2 years ago
      Anonymous

      there are neets who aren't paid 200k an hour to write sed scripts?

  39. 2 years ago
    Anonymous

    ITT:
    >perl is bad because... because muh popularity contest! just settle for this inferior solution instead!
    kek do zoom zooms really?

  40. 2 years ago
    Anonymous

    bash is useful for command line work, python is useful for data manipulation, c for speed. that's really all you need. everything else is troony shit

  41. 2 years ago
    Anonymous

    What, are we chads running jash now?

    • 2 years ago
      Anonymous

      You mean this thing?
      https://sourceforge.net/projects/jash/
      What's the point when there's Groovy and soon Kotlin.

  42. 2 years ago
    Anonymous

    >bash comes pre-installed as the default shell on most GNU+Linux distributions
    >Requires zero downloads and thus scripts can be run out of the box
    This means absolutely no connection to the Internet is required and the scripts can be deployed to all machines quickly and easily.

    Though I'd love to see exactly what bash scripts take that long to execute, even on a fricking Raspberry Pi zero

    • 2 years ago
      Anonymous

      >Though I'd love to see exactly what bash scripts take that long to execute
      Strace with timestamps can probably help with that.

  43. 2 years ago
    Anonymous

    >Write a bash script
    >It takes 15 seconds to execute
    why are you lying on the internet? every bash script i've ever written takes less than 1 second. what are you trying to do? what is the task you're trying to accomplish? your issue obviously isn't with the speed of bash, the issue if that you're a bad coder

Your email address will not be published. Required fields are marked *