Skip to main content
Share Your Experience: Take the 2024 Developer Survey
16 votes
Accepted

SSH passing your Public key to all the users on remote host

That looks crazy. But some constructive comments: Did you check for ssh-copy-id script, that is usually shipped with openssh? ...
Jakuje's user avatar
  • 316
16 votes
Accepted

Git delete all merged in local branches

Improve your file handling: Don't use a hard coded file name for temporary files. Don't spew temporary files into the current directory. Make sure you clean up temporary files even on error. The ...
jpmc26's user avatar
  • 1,233
15 votes

JSON Parsing in Bash

Bash is not well-suited for transforming JSON. But jq is. But calling jq 3 times for each line of input is certainly going to be ...
janos's user avatar
  • 111k
14 votes

Discover random web servers and print the index page title

Overall, the code is pretty clean. Some notes about the Python part: be consistent about the documentation string style - enclose them with triple quotes, start with an upper-case letter, end with a ...
alecxe's user avatar
  • 17.3k
14 votes

Git delete all merged in local branches

DRY - don't repeat yourself "Don't repeat yourself" is a popular programming principle. You could apply it here by not repeating your filename over and over. ...
chicks's user avatar
  • 2,863
14 votes

Git Push Bash script

Rather than make it interactive read -p "Continue? " yn I would make this more like other command line tools. You have default values and allow ...
Martin York's user avatar
  • 95.2k
13 votes
Accepted

Bash script to simplify Git deployment workflow

Use exit codes directly Instead of this: merge $SOURCE_BRANCH 'staging' status=$? if [ $status -ne 0 ] then echo "ERROR: STEP 1" >&2 exit 1 fi You ...
janos's user avatar
  • 111k
13 votes

Getting the current IP from the command line

I would use a different service that provides output in a format that is good for tools (not humans (html is for displaying for humans)). Hit this url: ...
Martin York's user avatar
  • 95.2k
13 votes
Accepted

Bash script to automate dev environment setup

I think you could benefit from using Ansible in this scenario then you can easily deploy your configuration to other machines and you will have learned a valuable IT skill. And rather than use bash ...
Kate's user avatar
  • 6,823
12 votes
Accepted

Setting up a development environment

Simplify Since $# cannot be both 0 and 1 at the same time, it would be better to join the two if conditions here: ...
janos's user avatar
  • 111k
12 votes
Accepted

Guessing the JDK home directory

Variables The line containing the JDK_ROOT_DIR=( … ) definition is so long that it's unreadable and unmaintainable. In fact, you listed ...
200_success's user avatar
12 votes

Bash script to automate dev environment setup

First of all, I would suggest using shellcheck when writing bash https://www.shellcheck.net/, it will point out many many errors, some trivial and some not so trivial. ...
Countingstuff's user avatar
11 votes
Accepted

Bash script that lowercases files

In my testing, constructing one Perl script and running it repeatedly is much faster (0.5s versus 3.6s) then running a new Perl instance for each replacement: ...
choroba's user avatar
  • 1,393
11 votes

Disallow `rm` to remove `*`

The vulnerability I see is that only the first two arguments are checked. You could check all of them: ...
Oh My Goodness's user avatar
11 votes
Accepted

Parallelized for loop in Bash

Some suggestions: The trailing slash in the mkdir command is redundant. $(…) is preferred over backticks for command ...
l0b0's user avatar
  • 8,927
11 votes
Accepted

Installing GNOME extension via CLI

First off, install Shellcheck and routinely run it on your scripts, or configure your editor to run it automatically. Now, Shellcheck is pretty rigorous and you would be forgiven for not solving all ...
Konrad Rudolph's user avatar
10 votes
Accepted

Getting the current IP from the command line

Your code is fine, except for the stray method. POST at that point isn't valid, and you will try to connect to a server called ...
Zeta's user avatar
  • 19.3k
10 votes
Accepted

Bob Marley is jamming on the wifi

Nothing would make a reviewer happier than help you jam the networks of an innocent neighborhood. (sarcasm) Mutually exclusive conditions Can line match ...
janos's user avatar
  • 111k
10 votes

Backup with Hanoi Strategy

Do not silently ignore invalid arguments Your script allows to specify the source directory (and other locations). Here is the relevant part in function parseArgs()...
Martin R's user avatar
  • 23.3k
10 votes

Wi-fi scheduler written in C

I will offer some suggestions. Please note I have no experience with Mac OS, but I believe most of it will still apply. Using system is not particularly bad in ...
Lev M.'s user avatar
  • 1,081
9 votes
Accepted

Fahrenheit / Celsius temperature converter

I don't know enough bash to offer you a technical review. But, more philosophically: Have you considered writing this more in the style of a "program" than a "Press 1 to convert another"-type ...
BenC's user avatar
  • 2,738
9 votes
Accepted

Project Euler 1 - Multiples of 3 and 5 by Loki

You can replace sort | uniq with sort -u. Note that (...) executes in a sub-shell. Grouping ...
janos's user avatar
  • 111k
9 votes
Accepted

Bash script to truncate subject line of incoming email

Be sure to read the relevant RFCs that govern e-mail headers! Specifically: RFC 2822, Section 1.2.2: Header names are case-insensitive. RFC 2822, Section 2.2.3: Header fields may be line-folded: 2....
200_success's user avatar
9 votes
Accepted

Weekly MySQL database backup

Overall This is totally decent code and not too difficult to maintain. Your variable names make sense and you've made some effort at not repeating yourself, other than the lack of a loop which you ...
chicks's user avatar
  • 2,863
8 votes
Accepted

Bash script to temporarily run a shell without certain group memberships

It's not an error to ask for help When -h is passed, the help() function shouldn't exit with non-zero status, because it's done ...
Toby Speight's user avatar
  • 76.1k
8 votes
Accepted

Upgrade Firefox Quantum from tarball

Pretty nice script, I have mostly minor suggestions. Always double-quote variables used in command arguments The parameters in these command should be double-quoted to protect from word splitting ...
janos's user avatar
  • 111k
8 votes

Disallow `rm` to remove `*`

Double-quote variables used in command parameters This is a bug: /bin/rm -i $@ What will happen if you try to delete file a b...
janos's user avatar
  • 111k
8 votes

Backup with Hanoi Strategy

Double-quote variables used as command arguments Although in many places in the posted code the variables used as command arguments are correctly double-quoted, there are more than a few exceptions, ...
janos's user avatar
  • 111k
8 votes
Accepted

Count line of code for a JavaScript project

fileExt="*.js" allFiles=$(find ./ -name $fileExt) This is a bug. The wildcard in $fileExt will be expanded by the shell, and ...
Oh My Goodness's user avatar
8 votes

Test to see if installed and if not, install it

Overall it's fine. My suggestions would be: Fix the indenting. If you find the comments helpful, great. Otherwise, consider saying "why" and not "what", e.g. ...
that other guy's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible