Skip to Content
Learn Linux Shell Scripting - Fundamentals of Bash 4.4
book

Learn Linux Shell Scripting - Fundamentals of Bash 4.4

by Sebastiaan Tammer
December 2018
Beginner
452 pages
12h 17m
English
Packt Publishing
Content preview from Learn Linux Shell Scripting - Fundamentals of Bash 4.4

Current working directory

The first candidate for inclusion in our own private function library is correctly setting the current working directory. This is a pretty simple function, so we'll add it without too much explanation:

reader@ubuntu:~/scripts/chapter_13$ vim ~/bash-function-library.sh reader@ubuntu:~/scripts/chapter_13$ cat ~/bash-function-library.sh #!/bin/bash###################################### Author: Sebastiaan Tammer# Version: v1.1.0# Date: 2018-11-17# Description: Bash function library.# Usage: source ~/bash-function-library.sh#####################################<SNIPPED># Set the current working directory to the script location.set_cwd() {  cd $(dirname $0)}

Because a function library is something that is potentially updated ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bash Scripting Fundamentals

Bash Scripting Fundamentals

Sander van Vugt

Publisher Resources

ISBN: 9781788995597Supplemental Content