Skip to content
Advertisement

Tag: shell

Prevent accidental history editing in bash

I recently switched from tcsh to bash, and one thing that keeps tripping me up is how bash handles history. I regularly bring up a previous history command and begin to edit it, but realize I need to run a different command first. In bash, this edits the original command, and I cannot see what I originally typed. In tcsh,

How to write a bash script which calls itself with python?

Can someone explain how this bash script works? The part I don’t understand is “””:”, what does this syntax mean in bash? test running result: Answer That’s clever! In Bash, the “””:” will be expanded into only :, which is the empty command (it doesn’t do anything). So, the next few lines will be executed, leading to exec. At that

How to repeat a dash (hyphen) in shell

How can I repeat the character – n times in shell? I have read and tried this, but this does not work for -. It throws error invalid option. Below is the exact command that I used: Original posted line: printf ‘-%0.s’ {1..100} I also tried escaping – by putting a but in that case it repeats – n

Run bash whiptail script after login with sudo

I’m creating a virtual machine configuration script using whiptail that I’d like to have automatically start after the user logs in. The thing is, that I don’t want the user to be root, however because the user will need to be able to change things like hostname, ip address, add directories, etc. they’ll need sudo privileges in order for the

Docker-compose – mongodb could not be authenticated

After installing Docker Toolbox on Windows 10 and starting docker-machine, I run docker-compose up, I run into this error: The following packages cannot be authenticated mongodb-org-shell The code in the dockerfile: RUN apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927 RUN echo “deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse” | tee /etc/apt/sources.list.d/mongodb-org-3.2.list RUN apt-get update RUN apt-get install -y mongodb-org-shell RUN apt-get install -y mongodb-org-tools

How to use source command within Jenkins pipeline script

I recently rewrite bash execution command into Jenkins pipeline. The old code is like Now I use pipeline script to wrap the command, like this However, I got an error, as…/.jenkins/script.sh: line 9: source: environment.sh: file not found. When I try to less environment.sh, it display correctly. So I suspect something wrong with source command within sh wrap. Before using

Get a radius of a circle in bash shell

I need to write a script to find radius of a circle and then find the area while the circumference is given The formula is: RADIUS=CIRCUMFERENCE/(2 * PI) The problem is I cant make this formula work because bash doesn’t accept decimal division I read a lot of answers there but still can’t get what I want I have something

Advertisement