How to write basic bash scripts


Portions of the Gramm-Leach-Bliley Act require organizations to maintain a regular backup regimen for the safe and secure storage of financial data.

You’ll first need to set up multiple backup directories. Each directory will be dedicated to housing text files that you will create with different kinds of system information.

Don't use plagiarized sources. Get Your Custom Essay on
How to write basic bash scripts
Just from $10/Page
Order Essay

For example, the directory freemem will be used to store free memory system information files.

  1. Using brace expansion, create the following four directories:
    • ~/backups/freemem
    • ~/backups/diskuse
    • ~/backups/openlist
    • ~/backups/freedisk

    Note: Remember that brace expansion uses the following format: ~/exampledirectory/{subdirectory1,subdirectory2,etc}

Now you will create a script that will execute various Linux tools to parse information about the system. Each of these tools should output results to a text file inside its respective system information directory.

  • For example: cpu_usage_tool > ~/backups/cpuuse/cpu_usage.txt

In the above example, the cpu_usage_tool command will output CPU usage information into a cpu_usage.txt file.

To get started with setting up your script up in your home directory, do the following:

  • Navigate to your home directory by running: cd ~/
  • Run the command nano to open a new Nano window.

Note: If you’re unsure how to get started, we included a starter file. Use that as a guide.

  1. Edit the script file so that it that does the following:
    • Prints the amount of free memory on the system and saves it to ~/backups/freemem/free_mem.txt.
    • Prints disk usage and saves it to ~/backups/diskuse/disk_usage.txt.
    • Lists all open files and saves it to ~/backups/openlist/open_list.txt.
    • Prints file system disk space statistics and saves it to ~/backups/freedisk/free_disk.txt.

    Note: For the free memory, disk usage, and free disk commands, make sure you use the -h option to make the output human-readable.

  2. Save this file and make sure to change or modify the file permissions so that it is executable.

You should now have an executable file within your home ~/ directory.

  • Test the script with sudo ./
  • Note: If it appears, ignore the warning: lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs Output information may be incomplete.


  • Confirm the script ran properly by navigating to any of subdirectories in the ~/backup/ directory and using cat <filename> to view the contents of the backup files.


  • Automate your script by adding it to the weekly system-wide cron directory.

    Get professional assignment help cheaply

    Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?

    Whichever your reason may is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.

    Our essay writers are graduates with diplomas, bachelor, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college diploma. When assigning your order, we match the paper subject with the area of specialization of the writer.

    Why choose our academic writing service?

    • Plagiarism free papers
    • Timely delivery
    • Any deadline
    • Skilled, Experienced Native English Writers
    • Subject-relevant academic writer
    • Adherence to paper instructions
    • Ability to tackle bulk assignments
    • Reasonable prices
    • 24/7 Customer Support
    • Get superb grades consistently


Order a unique copy of this paper
(550 words)

Approximate price: $22

Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

We value our customers and so we ensure that what we do is 100% original..
With us you are guaranteed of quality work done by our qualified experts.Your information and everything that you do with us is kept completely confidential.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

The Product ordered is guaranteed to be original. Orders are checked by the most advanced anti-plagiarism software in the market to assure that the Product is 100% original. The Company has a zero tolerance policy for plagiarism.

Read more

Free-revision policy

The Free Revision policy is a courtesy service that the Company provides to help ensure Customer’s total satisfaction with the completed Order. To receive free revision the Company requires that the Customer provide the request within fourteen (14) days from the first completion date and within a period of thirty (30) days for dissertations.

Read more

Privacy policy

The Company is committed to protect the privacy of the Customer and it will never resell or share any of Customer’s personal information, including credit card data, with any third party. All the online transactions are processed through the secure and reliable online payment systems.

Read more

Fair-cooperation guarantee

By placing an order with us, you agree to the service we provide. We will endear to do all that it takes to deliver a comprehensive paper as per your requirements. We also count on your cooperation to ensure that we deliver on this mandate.

Read more

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Open chat
You can contact our live agent via WhatsApp! Via +1 817 953 0426

Feel free to ask questions, clarifications, or discounts available when placing an order.

Order your essay today and save 20% with the discount code VICTORY