This is an unofficial emergency mirror of the great BashFAQ at Greg's wiki. In case Greg's wiki is down, these pages will keep up the information for you ;)
Also it might be useful for regular searches, since Greg's private internet connection is usually under high load and sometimes slow.
This is an automatic mirror and conversion script, there are bugs in the syntax conversion between Greg's MoinMoin Wiki and this DokuWiki.
The complate namespace is readonly, since the master copy at Greg's wiki is what should be edited, not this one!
FAQ001 How can I read a file (data stream, variable) line-by-line?
FAQ002 How can I store the return value/output of a command in a variable?
FAQ003 How can I insert a blank character after each character?
FAQ004 How can I check whether a directory is empty or not? How do I check for any *.mpg files?
FAQ005 How can I use array variables?
FAQ006 How can I use variable variables (indirect variables, pointers, references) or associative arrays?
FAQ007 Is there a function to return the length of a string?
FAQ008 How can I recursively search all files for a string?
FAQ009 My command line produces no output: tail -f logfile | grep 'foo bar'
FAQ010 How can I recreate a directory hierarchy structure, without the files?
FAQ011 How can I print the n'th line of a file?
FAQ012 How do I invoke a shell command from a non-shell application?
FAQ013 How can I concatenate two variables? How do I append a string to a variable?
FAQ014 How can I redirect the output of multiple commands at once?
FAQ015 How can I run a command on all files with the extension .gz?
FAQ016 How can I use a logical AND/OR/NOT in a shell pattern (glob)?
FAQ017 How can I group expressions, e.g. (A AND B) OR C?
FAQ018 How can I use numbers with leading zeros in a loop, e.g. 01, 02?
FAQ019 How can I split a file into line ranges, e.g. lines 1-10, 11-20, 21-30?
FAQ020 How can I find and deal with file names containing newlines, spaces or both?
FAQ021 How can I replace a string with another string in all files?
FAQ022 How can I calculate with floating point numbers instead of just integers?
FAQ023 I want to launch an interactive shell that has a special set of aliases and functions, not the ones in the user's ~/.bashrc.
FAQ024 I set variables in a loop. Why do they suddenly disappear after the loop terminates? Or, why can't I pipe data to read?
FAQ025 How can I access positional parameters after $9?
FAQ026 How can I randomize (shuffle) the order of lines in a file? (Or select a random line from a file, or select a random file from a directory.)
FAQ027 How can two unrelated processes communicate?
FAQ028 How do I determine the location of my script? I want to read some config files from the same place.
FAQ029 How can I display the target of a symbolic link?
FAQ030 How can I rename all my *.foo files to *.bar, or convert spaces to underscores, or convert upper-case file names to lower case?
FAQ031 What is the difference between test, [ and [[ ?
FAQ032 How can I redirect the output of 'time' to a variable or file?
FAQ033 How can I find a process ID for a process given its name?
FAQ034 Can I do a spinner in Bash?
FAQ035 How can I handle command-line arguments to my script easily?
FAQ036 How can I get all lines that are: in both of two files (set intersection) or in only one of two files (set subtraction).
FAQ037 How can I print text in various colors?
FAQ038 How do Unix file permissions work?
FAQ039 What are all the dot-files that bash reads?
FAQ040 How do I use dialog to get input from the user?
FAQ041 How do I determine whether a variable contains a substring?
FAQ042 How can I find out if a process is still running?
FAQ043 Why does my crontab job fail? 0 0 * * * some command > /var/log/mylog.`date +%Y%m%d`
FAQ044 How do I create a progress bar?
FAQ045 How can I ensure that only one instance of a script is running at a time (mutual exclusion)?
FAQ046 I want to check to see whether a word is in a list (or an element is a member of a set).
FAQ047 How can I redirect stderr to a pipe?
FAQ048 Eval command and security issues
FAQ049 How can I view periodic updates/appends to a file? (ex: growing log file)
FAQ050 I'm trying to put a command in a variable, but the complex cases always fail!
FAQ051 I want history-search just like in tcsh. How can I bind it to the up and down keys?
FAQ052 How do I convert a file from DOS format to UNIX format (remove CRs from CR-LF line terminators)?
FAQ053 I have a fancy prompt with colors, and now bash doesn't seem to know how wide my terminal is. Lines wrap around incorrectly.
FAQ054 How can I tell whether a variable contains a valid number?
FAQ055 Tell me all about 2>&1 -- what's the difference between 2>&1 >foo and >foo 2>&1, and when do I use which?
FAQ056 How can I untar or unzip multiple tarballs at once?
FAQ057 How can group entries (in a file by common prefixes)?
FAQ058 Can bash handle binary data?
FAQ059 I saw this command somewhere: :(){ :|:& } (fork bomb). How does it work?
FAQ060 I'm trying to write a script that will change directory (or set a variable), but after the script finishes, I'm back where I started (or my variable isn't set)!
FAQ061 Is there a list of which features were added to specific releases (versions) of Bash?
FAQ062 How do I create a temporary file in a secure manner?
FAQ063 My ssh client hangs when I try to run a remote background job!
FAQ064 Why is it so hard to get an answer to the question that I asked in #bash?
FAQ065 Is there a "PAUSE" command in bash like there is in MSDOS batch scripts? To prompt the user to press any key to continue?
FAQ066 I want to check if [[ $var == foo | $var == bar | $var == more ]] without repeating $var n times.
FAQ067 How can I trim leading/trailing white space from one of my variables?
FAQ068 How do I run a command, and have it abort (timeout) after N seconds?
FAQ069 I want to automate an ssh (or scp, or sftp) connection, but I don't know how to send the password....
FAQ070 How do I convert Unix (epoch) timestamps to human-readable values?
FAQ071 How do I convert an ASCII character to its decimal (or hexadecimal) value and back?
FAQ072 How can I ensure my environment is configured for cron, batch, and at jobs?
FAQ073 How can I use parameter expansion? How can I get substrings? How can I get a file without its extension, or get just a file's extension?
FAQ074 How do I get the effects of those nifty Bash Parameter Expansions in older shells?
FAQ075 How do I use 'find'? I can't understand the man page at all!
FAQ076 How do I get the sum of all the numbers in a column?
FAQ077 How do I log history or "secure" bash against history removal?
FAQ078 I want to set a user's password using the Unix passwd command, but how do I script that? It doesn't read standard input!
FAQ079 How can I grep for lines containing foo AND bar, foo OR bar? Or for files containing foo AND bar, possibly on separate lines?
FAQ080 How can I make an alias that takes an argument?
FAQ081 How can I determine whether a command exists anywhere in my PATH?
FAQ082 Why is $(...) preferred over `...` (backticks)?
FAQ083 How do I determine whether a variable is already defined? Or a function?
FAQ084 How do I return a string (or large number, or negative number) from a function? "return" only lets me give a number from 0 to 255.
FAQ085 How to write several times to a fifo without having to reopen it?
FAQ086 How to ignore aliases or functions when running a command?
FAQ087 How can I get the permissions of a file without parsing ls -l output?
FAQ088 How can I avoid losing any history lines?
FAQ089 I'm using a loop which runs once per line of input but it only seems to run once; everything after the first line is ignored?
FAQ090 How do I prepend a text to a file (the opposite of >>)?
FAQ091 I'm trying to get the number of columns or lines of my terminal but the variables COLUMNS / LINES are always empty
FAQ092 How do I write a CGI script that accepts parameters?
FAQ093 How can I see a progress bar when copying/moving files?
FAQ094 I want to get an alert when my disk is full (parsing df output).
FAQ095 I'm getting "Argument list too long". How can I process a large list in chunks?
FAQ096 ssh eats my word boundaries! I can't do ssh remotehost make CFLAGS="-g -O"!
FAQ097 How do I determine whether a symlink is dangling (broken)?
FAQ098 How to add localization support to your bash scripts
FAQ099 How can I get the newest (or oldest) file from a directory?
FAQ100 How do I do string manipulations in bash?