Top "Bash" questions

For questions about scripts written for the Bash command shell.

Echo tab characters in bash script

How do I echo one or more tab characters using a bash script? When I run this code res=' …

bash tabs echo spaces
How to convert DOS/Windows newline (CRLF) to Unix newline (LF) in a Bash script?

How can I programmatically (i.e., not using vi) convert DOS/Windows newlines to Unix? The dos2unix and unix2…

linux windows bash unix newline
How to define hash tables in Bash?

What is the equivalent of Python dictionaries but in Bash (should work across OS X and Linux).

bash dictionary hashtable associative-array
Find all storage devices attached to a Linux machine

I have a need to find all of the writable storage devices attached to a given machine, whether or not …

linux bash shell
How do I know the script file name in a Bash script?

How can I determine the name of the Bash script file inside the script itself? Like if my script is …

linux bash shell scripting
How to kill all processes with a given partial name?

I want to kill all processes that I get by: ps aux | grep my_pattern How to do it? This …

linux bash posix
Propagate all arguments in a bash shell script

I am writing a very simple script that calls another script, and I need to propagate the parameters from my …

bash command-line-arguments
How to check if a file contains a specific string using Bash

I want to check if a file contains a specific string or not in bash. I used this script, but …

bash shell grep
Read lines from a file into a Bash array

I am trying to read a file containing lines into a Bash array. I have tried the following so far: …

arrays bash
Get file directory path from file path

In Bash, if VAR="/home/me/mydir/file.c", how do I get "/home/me/mydir"?

bash