bash foo

Instead of writing tons and tons of small scripts < 10 lines that all depend on each other I have the habbit of writing them as functions and throwing them into one file (easier to edit, less worries about them depending on each other). To be able to use the functions from the bash shell, just add $(basename $0) “$@” to the END of the file, and add symlinks function_name -> file.

Example:
$ ln -s foo.sh foobar

$ cat foo.sh

 Bash |  copy code |? 
1
#!/bin/bash
2
foobar() {
3
echo "world domination"
4
return
5
}
6
 
7
$(basename $0) "$@"


Related posts:

  1. bash scripting … switching into directory of the script
  2. Bash Scripting
  3. bash: using the content of a variable as variable name
  4. self0wned
  5. Script of the day – clean up stale .ssh/known_hosts

Trackback URL

,

No Comments on "bash foo"

Hi, leave a comment:


Connect with Facebook

ALLOWED XHTML TAGS:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to Comments
Performance Optimization WordPress Plugins by W3 EDGE