Black Bytes » expansion http://www.blackbytes.info Sat, 30 Nov 2013 17:18:48 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.2 Bash expansionshttp://www.blackbytes.info/2013/11/bash-expansions/ http://www.blackbytes.info/2013/11/bash-expansions/#comments Sat, 30 Nov 2013 17:18:35 +0000 admin http://www.blackbytes.info/?p=1080 In this post you will learn about bash expansions, you probably already used them if you have done something like “ls *.txt”, basically the shell does some processing on the command line before actually executing it, which enables us to do a numbers of things, like using variables.

Here is a small cheatsheet of the most useful expansions:

Brace expansion
List: {1,2,3}
brace-expansion

Range: {20..30}
range

Filename expansion (also know as globbing)
*.sh -> expands to all file names that have an extension of .sh
[st]* -> expands to all file names that start with either an 's' or a 't'

filename-expansion

Tip: if you want to use a especial character without it being expanded you can enclose it in quotes, for example: echo “test*”

Variable expansion
$SHELL -> /usr/bin/zsh

You can learn more here: http://www.gnu.org/software/bash/manual/html_node/Shell-Expansions.html

]]>
http://www.blackbytes.info/2013/11/bash-expansions/feed/ 0