Write a bash script

>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?

Attached: ba.png (1200x506, 53.7K)

Post the script so we can laugh at you.

>fpbp
>no response from op

idk
i use perl and it just werks

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

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

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

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

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

lmao

lol

works on my machine

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

That's some hilarious shit, thanks for sharing.

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.

BAHAHAHAHHAHAHAHA
Good one user. Are You the same fag 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.

You know, shit like parallel and xargs exist right?

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

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 retarded bash wrapper.

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

stop writing shitty scripts and blaming bash?