Giter Club home page Giter Club logo

quick-bash's Introduction

Quick Guide on Bash

Bash is not a general-purpose programming language. It is a language for programming the shell, which provides an interface to access the services of a Linux operating system. Despite its ancient syntax and crippling limitations, Bash remains relevant today for managing system programs and automating small tasks in a Linux environment. Bash is certainly worth learning.

To illustrate the utility of Bash, imagine that you are asked to write

A program that reads a text file and prints a table of unique words and corresponding frequencies, sorted from most to least frequent.

In 1986, Donald Knuth, the Father of the analysis of computer algorithms, was asked to write such a program. He produced a solution in Pascal that was 10 pages in length. This code was well-designed, thoroughly commented, and introduced a novel data structure. The same task can be achieved by the following 5-line Bash script:

tr -cs A-Za-z '\n' |    # put each word on its own line
tr A-Z a-z |            # convert all uppercase letters to lower case
sort |                  # sort the words alphabetically
uniq -c |               # create a frequency table for unique words
sort -k 1rn -k 2        # sort by descending frequency, then lexicographically

The reason why this Bash script is so terse is because it does not start from scratch; rather, it feeds the input through a series of existing programs to produce the desired output. Bash breaks down a complex task into smaller jobs that it delegates to specialized Linux programs.

Indeed, Bash excels in work flow management. While Bash is a poor choice for writing fault-tolerant, memory-intensive, performance-critical applications, it is a widely used language for managing programs in the Linux environment. With this guide, you will learn to write simple and comprehensible Bash scripts, allowing you to achieve the full potential of Linux.

quick-bash's People

Contributors

djhshih avatar jonathan-tse avatar

Stargazers

allisonvmitch avatar Xiaotian Ma avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.