Top "Bash" questions

For questions about scripts written for the Bash command shell.

Capturing Groups From a Grep RegEx

I've got this little script in sh (Mac OSX 10.6) to look through an array of files. Google has stopped being …

bash shell grep
Difference between return and exit in Bash functions

What is the difference between the return and exit statement in Bash functions with respect to exit codes?

bash function return-value return exit
Using getopts to process long and short command line options

I wish to have long and short forms of command line options invoked using my shell script. I know that …

bash command-line-arguments getopt getopts
How can I write a heredoc to a file in Bash script?

How can I write a here document to a file in Bash script?

bash heredoc
Exit Shell Script Based on Process Exit Code

I have a shell script that executes a number of commands. How do I make the shell script exit if …

bash shell
How can I get the current user's username in Bash?

I am writing a program in Bash that needs to get the user's username. I have heard of a thing …

bash username
Find the files existing in one directory but not in the other

I'm trying to find the files existing in one directory but not in the other, I tried to use this …

linux bash diff
Get just the filename from a path in a Bash script

How would I get just the filename without the extension and no path? The following gives me no extension, but …

bash scripting shell
An "and" operator for an "if" statement in Bash

I'm trying to create a simple Bash script to check if the website is down and for some reason the "…

bash if-statement
Find the files that have been changed in last 24 hours

E.g., a MySQL server is running on my Ubuntu machine. Some data has been changed during the last 24 hours. …

linux bash find