Giter VIP home page Giter VIP logo

simple-bash-scripts's Introduction

Simple Bash Script


Collection of simple bash script that will written for new Learners

Installation

$ git clone https://github.com/hosam1696/simple-bash-scripts

To Open the repo on Your Browser

$ npm repo

To list the available shells on your machine

> cat /etc/shells
# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash
/bin/csh
/bin/dash
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh

String Comparisons:

= compare if two strings are equal

!= compare if two strings are not equal

-n evaluate if string length is greater than zero

-z evaluate if string length is equal to zero

Examples:

[ s1 = s2 ] (true if s1 same as s2, else false)

[ s1 != s2 ] (true if s1 not same as s2, else false)

[ s1 ] (true if s1 is not empty, else false)

[ -n s1 ] (true if s1 has a length greater then 0, else false)

[ -z s2 ] (true if s2 has a length of 0, otherwise false)

Number Comparisons:

-eq compare if two numbers are equal

-ge compare if one number is greater than or equal to a number

-le compare if one number is less than or equal to a number

-ne compare if two numbers are not equal

-gt compare if one number is greater than another number

-lt compare if one number is less than another number

Examples:

[ n1 -eq n2 ] (true if n1 same as n2, else false)

[ n1 -ge n2 ] (true if n1greater then or equal to n2, else false)

[ n1 -le n2 ] (true if n1 less then or equal to n2, else false)

[ n1 -ne n2 ] (true if n1 is not same as n2, else false)

[ n1 -gt n2 ] (true if n1 greater then n2, else false)

[ n1 -lt n2 ] (true if n1 less then n2, else false)

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.