Top "Bash" questions

For questions about scripts written for the Bash command shell.

Make a Bash alias that takes a parameter?

I used to use CShell (csh), which lets you make an alias that takes a parameter. The notation was something …

bash alias
Check if a Bash array contains a value

In Bash, what is the simplest way to test if an array contains a certain value?

arrays bash
How do I run a shell script without using "sh" or "bash" commands?

I have a shell script which I want to run without using the "sh" or "bash" commands. For example: Instead …

bash shell alias sh
How to get the list of files in a directory in a shell script?

I'm trying to get the contents of a directory using shell script. My script is: for entry in `ls $search_…

bash shell directory-listing
How can I remove the first line of a text file using bash/sed script?

I need to repeatedly remove the first line from a huge text file using a bash script. Right now I …

bash scripting sed
How to get the primary IP address of the local machine on Linux and OS X?

I am looking for a command line solution that would return me the primary (first) IP address of the localhost, …

bash unix ip ifconfig
How can I use ":" as an AWK field separator?

Given the following command, echo "1: " | awk '/1/ -F ":" {print $1}' why does AWK output: 1: ?

bash awk
Pipe to/from the clipboard in Bash script

Is it possible to pipe to/from the clipboard in Bash? Whether it is piping to/from a device handle …

linux bash macos clipboard
Length of string in bash

How do you get the length of a string stored in a variable and assign that to another variable? myvar="…

bash variables string-length
Difference between sh and bash

When writing shell programs, we often use /bin/sh and /bin/bash. I usually use bash, but I don't know …

bash shell unix sh