I've been a professional C, Perl, PHP and Python developer.
I'm an ex-sysadmin from the late 20th century.
These days I do more Javascript and CSS and whatnot, and promote UX and accessibility.
I like this, because there are loads of ways you could do it.
You could use cut -d, -f2 instead of the awk. You could use tr "\n" "+" instead of the sed to transform one character (though you might have to fudge that).
You can get rid of the cat and use tail +2 shopping.csv.
You can use grep to do almost all the heavy lifting if you want, because you can tell it to only print the matching text with -o, which has the added benefit of skipping the first line entirely so you no longer need the cator the tail.
I'd go with this combo, which uses paste to join the lines:
grep-o"[0-9.]\+" shopping.csv | paste-s-d+ | bc
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I like this, because there are loads of ways you could do it.
You could use
cut -d, -f2instead of theawk. You could usetr "\n" "+"instead of thesedto transform one character (though you might have to fudge that).You can get rid of the
catand usetail +2 shopping.csv.You can use grep to do almost all the heavy lifting if you want, because you can tell it to only print the matching text with
-o, which has the added benefit of skipping the first line entirely so you no longer need thecator thetail.I'd go with this combo, which uses
pasteto join the lines: