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
2
votes
0 answers

How to auto init direnv on Google Cloud Shell?

my .bashrc has these lines at the bottom: if [ -f $HOME/tools/bashrc ]; then source $HOME/tools/bashrc fi and $HOME/tools/bashrc has this code at the bottom: eval "$(pyenv init -)" pyenv virtualenvwrapper_lazy eval "$(direnv hook…
2
votes
2 answers

Extract missing paths from bash array of paths

I have an array of paths: paths=( /foo/exists1 /foo/exists2 /foo/missing1 ) To find those that are missing: ls "${paths[@]}" 1>/dev/null Shows: ls: cannot access '/foo/missing1': No such file or directory Good. Now I want to clean this…
lonix
  • 896
  • 10
  • 23
2
votes
2 answers

Restart service when memory is used over 90%

I am not sure if it is even possible, but can I somehow restart service when memory has been already used over 90%? I mean script will check memory, and if memory has been used over 90% it will restart/execute restart of my service?
Delirium
  • 207
  • 4
  • 11
2
votes
1 answer

Bash - Math: Returns integer instead of float

Bash returns value 4 instead of 4.2 when dividing 21/5. And returns 36 when doing 9 * (21/5) instead of 37.8. echo "$(( 21/5 ))" 4 echo "21/5" | bc 4 Similarly 9 * ( 21/5 ) returns 36 but it should be 37.8; y = 9; num_lines = 21; w = 5; let…
Robert
  • 23
  • 2
2
votes
1 answer

SSH running in background (-f) with sshpass

My final goal is to use both ssh -f and sshpass together, although it is quite not works. ssh -f tries to fork from the ssh process and also sets stdin to read from /dev/null - what makes things difficult because sshpass gathers the ssh command,…
DR J
  • 21
  • 1
  • 2
1
vote
0 answers

KSH/Bash History for jailed SSH users

How can I keep a history of activities for chroot'd SSH (not SFTP) users? I've tried: created a .sh_history in their home with the proper permissions created a custom $HISTFILE in .profile and in its jailed /etc/profile exported HISTFILE after…
Dumb admin
  • 127
  • 12
1
vote
1 answer

Command work on terminal but not working as system service Ubuntu 18.04 server

I have checked again and again on terminal and ./go.sh both working but not able to start as service. I know i am doing it wrong but not sure what. /root/go.sh #!/usr/bin/env bash export PATH=/sbin:/usr/sbin:/bin:/usr/bin /root/goweb/bin/echoip…
Shimul D
  • 111
  • 3
1
vote
2 answers

my bash scripts are not working when called through supervisord

I'm using the following systems: Ubuntu 18.04.2 LTS bash 4.4.19(1)-release supervisord 3.3.1-1.1 I have written two scripts that work pretty well from the CLI, but when I try to use supervisord with them, they don't work. When I execute them by…
1
vote
1 answer

Accomplishing Ctrl-z + bg in one step?

We can use Ctrl-z to stop the current job followed by bg to send it to the background, but can we do this in one action that doesn't briefly pause the execution of the program? Is there a combined Ctrl-z + bg type command that we can use?
Wingsuit
  • 113
  • 3
1
vote
1 answer

setfacl inherit permissions without bash scripting

i have this script to add inherit permissions in all directory's, asd=$(find -type d); for a in $asd; do setfacl -d -m "u:pythoncrons:rwx" $a; done my question is, i can set inherit permissions recursive without bash script? like recursive set…
1
vote
1 answer

Pemission denied when I try to create a new file with a script

So, I have a bash script "get-data.sh that runs other two python scripts #!/bin/bash scripts=/root/scripts datos=/root/zabbixdata fecha=$(date +"%Y_%m_%d") sudo $scripts/filesystem.py > $datos/filesystem_$fecha.log & sudo $scripts/cpu.py >…
1
vote
2 answers

PuTTy - double SSH + remote command

I need to do SSH twice: ssh myname@server1 and later ssh myname@server2 and later I would like to execute a few Bash commands on server2, like e.g. htop. I need all of it to run when clicking PuTTY shortcut. Is it possible? How to do it in a way…
Alex
  • 11
  • 2
1
vote
1 answer

bash_completion fails to find function

I wrote a program (logit) that sets up logging and execs what ever follows it on the command line. That all works fine. I want to be able to do command completion, sudo works like logit, so being lazy, I do this in my .bashrc: complete -F _sudo…
Wayne Walker
  • 241
  • 2
  • 5
1
vote
3 answers

How to move and partially rename files on linux

I have versioned files which come out of a build pipeline. foo-1.3.4.war and I need to move these files to have the name foo-dev-1.3.4.war How would I go about this? I was thinking something like mv foo-*.war foo-dev-*.war but this will only…
user3383458
  • 113
  • 5
1
vote
1 answer

psql exit code 2 in bashscript

postgres 9.6 Debian GNU/Linux 9 is use following simplyfied bash script wich gets called from a users crontab, myid is a passed parameter: #!/bin/bash ... PGPASSFILE="/home/user/.pgpass" PGCONNECT=" psql -U myuser -w -h 000.000.000.000 -d mydatabase…
FatFreddy
  • 125
  • 1
  • 5