Showing posts with label scripting. Show all posts
Showing posts with label scripting. Show all posts

Tuesday, November 25, 2008

Bash debugger

This is for all of you hardcore bash scripters that sometimes want better debugging than placing "echo" statements in your scripts.

A co-worker sent this out to our internal sysadmin mail alias today.

http://www.linux.com/feature/153383

It references the bashdb project (bash debugger). I didn't know one existed.

Wednesday, July 11, 2007

Lame But Useful Bash Tricks (Part 1)

Incrementing Letters and Numbers for Variable Lists

[Note: Applicable for Bash version 3.00]

Using curly brackets "{" and "}", you can set a range with a variable list. Inside the curly brackets, the range just needs to be separated by two periods, "..".

Ex.
$ SERVERLIST="`echo server-{1..5}`"
$ echo $SERVERLIST
server-1 server-2 server-3 server-4 server-5

$ SERVERLIST="`echo server-{a..d}`"
$ echo $SERVERLIST
server-a server-b server-c server-d

This could also be useful for quick "for" loops with a list that has incremental numbers off the same root name.

Ex.
for i in server-{1..5}
do
echo $i
done

server-1
server-2
server-3
server-4
server-5