Top "Bash" questions

For questions about scripts written for the Bash command shell.

Running multiple commands in one line in shell

Say I have a file /templates/apple and I want to put it in two different places and then remove …

bash shell
Reliable way for a Bash script to get the full path to itself

I have a Bash script that needs to know its full path. I'm trying to find a broadly-compatible way of …

bash path
Multi-line string with extra space (preserved indentation)

I want to write some pre-defined texts to a file with the following: text="this is line one\n this …

string bash shell echo
Difference between wait and sleep

What is difference between wait and sleep?

bash shell wait sleep
How can I kill a process by name instead of PID?

Sometimes when I try to start Firefox it says "a Firefox process is already running". So I have to do …

linux bash shell
How to escape single quotes within single quoted strings

Let's say, you have a Bash alias like: alias rxvt='urxvt' which works fine. However: alias rxvt='urxvt -fg '#111111…

bash syntax quoting
How to use sed/grep to extract text between two words?

I am trying to output a string that contains everything between two words of a string: input: "Here is a …

string bash sed grep
What's the difference between .bashrc, .bash_profile, and .environment?

I've used a number of different *nix-based systems of the years, and it seems like every flavor of Bash I …

shell environment bash
What is the preferred Bash shebang?

Is there any Bash shebang objectively better than the others for most uses? #!/usr/bin/env bash #!/bin/bash #!/bin/…

bash shebang
Pseudo-terminal will not be allocated because stdin is not a terminal

I am trying to write a shell script that creates some directories on a remote server and then uses scp …

linux bash shell ssh