Questions tagged [bash]

Bash is the Bourne Again SHell, the successor to the classic Unix sh (shell).

bash is the Bourne Again SHell, the successor to the classic Unix Bourne shell (sh). It's the default shell on many Linux distributions, including RedHat, CentOS, Debian, and Ubuntu.

The premier online guide is the BashGuide.

3527 questions
37
votes
9 answers

Multi-select menu in bash script

I'm a bash newbie but I would like to create a script in which I'd like to allow the user to select multiple options from a list of options. Essentially what I would like is something similar to the example below: #!/bin/bash …
user38939
  • 495
  • 1
  • 4
  • 7
36
votes
4 answers

How to repeatedly call rsync until files are sucessfully transferred

I'm trying to syncronize files from a remote server that is not reliable, meaning the connection tends to fail "randomly" with rsync: connection unexpectedly closed Rsync is called with --partial, so I'd like to be able to call rsync in a loop…
Bruno Lopes
  • 615
  • 2
  • 6
  • 8
36
votes
8 answers

Is there any reason to use bash over zsh?

I'm curious about why one would want to run bash instead of zsh. I mean zsh is fully backwards-compatible with bash. Don't get me wrong: I don't dislike bash or anything. I just genuinely want to know if there are any advantages to using it over…
Jason Baker
  • 1,229
  • 6
  • 20
  • 26
36
votes
1 answer

Recover a running script from a terminal session

So I'm using GNU Screen to manage multiple running scripts/programs. The multiplexing & detachability is quite helpful. I removed a script from disk and now I'm having some trouble finding the backup. However, one of the terminal sessions was…
Fdo
  • 463
  • 4
  • 6
36
votes
16 answers

Can't run AWS CLI from CRON (credentials)

Trying to run a simple AWS CLI backup script. It loops through lines in an include file, backs those paths up to S3, and dumps output to a log file. When I run this command directly, it runs without any error. When I run it through CRON I get an…
binaryorganic
  • 6,021
  • 4
  • 18
  • 19
36
votes
7 answers

Determine if file is in the process of being written upon?

I need to deploy an automated process (via 1 min cron script) that looks for tar files in a specific directory. If a tar file is found, it is untarred to the appropriate location and then the tar file is deleted. The tar files are automatically…
Jake Wilson
  • 8,814
  • 29
  • 97
  • 125
35
votes
2 answers

How to disable "WARNING: apt does not have a stable CLI interface..."

I'm trying to write a script which will output the number of upgrade-able packages from apt. However it keeps giving me this warning with it also: # sudo apt update | grep packages | cut -d '.' -f 1 WARNING: apt does not have a stable CLI…
CorruptComputer
  • 453
  • 1
  • 4
  • 5
35
votes
7 answers

Can't log in via SSH to any accounts using /bin/bash shell on Synology NAS

I'm trying to install bash as the default shell on a ARM Linux running on an embedded device (Synology DS212+ NAS). But there's something really wrong, and I can't figure out what it is. Symptoms: 1) Root has /bin/bash as default shell, and can log…
Gui Ambros
  • 1,339
  • 2
  • 13
  • 17
35
votes
9 answers

How can I execute a bash function with sudo?

I have a bash function defined in a global bashrc, which requires root privileges to work. How can I run it with sudo, e.g. sudo myfunction. By default it gives an error: sudo: myfunction: command not found
Eugene Yarmash
  • 2,433
  • 5
  • 34
  • 54
35
votes
6 answers

Merge 2 directory trees in Linux without copying?

I have two directory trees with similar layouts, i.e. . |-- dir1 | |-- a | | |-- file1.txt | | `-- file2.txt | |-- b | | `-- file3.txt | `-- c | `-- file4.txt `-- dir2 |-- a | |-- file5.txt | `--…
bajafresh4life
  • 613
  • 2
  • 6
  • 8
34
votes
3 answers

How to totally remove a certbot-created SSL certificate?

I use Ubuntu 16.04 with Nginx and I've installed Nginx Certbot on my operating system (Ubuntu 16.04) with: apt-get update -y add-apt-repository ppa:certbot/certbot -y apt-get update -y apt-get upgrade python-certbot-nginx -y I setted Nginx…
Arcticooling
  • 1
  • 3
  • 7
  • 22
34
votes
4 answers

How to escape ! in password?

How might one escape the exclamation point in a password: $ mysql -umyuser -pone_@&!two -bash: !two: event not found Trying the obvious backslash did not help: $ mysql -umyuser -pone_@&\!two [1] 22242 -bash: !two: command not found name@domain.com…
dotancohen
  • 2,590
  • 2
  • 25
  • 39
33
votes
4 answers

Why does the $PATH of an ssh remote command differ from that of an interactive shell?

I have a user that has made no modifications to the $PATH in any dot-files: it is exactly the system default setting. From a login shell: $ ssh example.com user@example.com:~$ cat /tmp/hello.hs #!/bin/bash echo "$SHELL" echo…
troutwine
  • 1,452
  • 5
  • 18
  • 33
32
votes
8 answers

Rsync seems incompatible with .bashrc (causes "is your shell clean?")

It turns out rsync can't work with a remote server which has a .bashrc file? At local client i got when run rsync: protocol version mismatch -- is your shell clean? (see the rsync man page for an explanation) rsync error: protocol incompatibility…
Computist
  • 473
  • 1
  • 5
  • 7
32
votes
4 answers

What is /bin/dash?

I thought /bin/sh was a symlink to my shell of choice. I've always used bash, so I assumed that /bin/sh would point to /bin/bash. It turns out, though, that it points to /bin/dash. It gets funnier. I start dash and do echo $SHELL and it prints…
aioobe
  • 371
  • 1
  • 4
  • 16