InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

Menu
  • Home
  • Sitemap

Python Programming Language Best Tutorials and Code Examples

Learn Python Right Now!
Home
Bash
Documenting Your Script in bash
Bash

Documenting Your Script in bash

InfinityCoder February 9, 2017

Before we say one more word about shell scripts or variables, we have to say something about documenting your scripts.

After all, you need to be able to understand your script even when several months have passed since you wrote it.

Document your script with comments. The # character denotes the beginning of a comment. All the characters after it on that line are ignored by the shell.

1
2
3
4
5
#
# This is a comment.
#
# Use comments frequently.
# Comments are your friends.

Some people have described shell syntax, regular expressions, and other parts of shell scripting as write only syntax, implying that it is nearly impossible to understand the intricacies of many shell scripts.
One of your best defenses against letting your shell scripts fall into this trap is the liberal use of comments (another is the use of meaningful variable names).

It helps to put a comment before strange syntax or terse expressions.

1
2
3
4
5
# replace the semi with a blank
NEWPATH=${PATH/;/ }
#
# switch the text on either side of a semi
sed -e 's/^\(.*\);\(.*\)$/\2;\1/' < $FILE

Comments can even be typed in at the command prompt with an interactive shell.
This can be turned off, but it is on by default. There may be a few occasions when it is useful to make interactive comments.

Share
Tweet
Email
Prev Article
Next Article

Related Articles

Sifting Through Files for a String in bash
You need to find all occurrences of a string in …

Sifting Through Files for a String in bash

Appending Rather Than Clobbering Output in bash
Each time you redirect your output, it creates that output …

Appending Rather Than Clobbering Output in bash

About The Author

InfinityCoder
InfinityCoder

Leave a Reply

Cancel reply

Recent Tutorials InfinityQuest

  • Adding New Features to bash Using Loadable Built-ins in bash
    Adding New Features to bash Using Loadable …
    June 27, 2017 0
  • Getting to the Bottom of Things in bash
    Getting to the Bottom of Things in …
    June 27, 2017 0

Recent Comments

    Categories

    • Bash
    • PHP
    • Python
    • Uncategorized

    InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more

    About Us

    Start learning your desired programming language with InfinityQuest.com.

    On our website you can access any tutorial that you want with video and code examples.

    We are very happy and honored that InfinityQuest.com has been listed as a recommended learning website for students.

    Popular Tags

    binary data python CIDR convert string into datetime python create xml from dict python dictionary into xml python how to create xml with dict in Python how to write binary data in Python IP Address read binary data python tutorial string as date object python string to datetime python

    Archives

    • June 2017
    • April 2017
    • February 2017
    • January 2017
    • December 2016
    • November 2016
    Copyright © 2019 InfinityQuest - Programming Code Tutorials and Examples with Python, C++, Java, PHP, C#, JavaScript, Swift and more
    Programming Tutorials | Sitemap