Skip to content

Instantly share code, notes, and snippets.

@HallexCosta
Last active May 18, 2021 22:36
Show Gist options
  • Save HallexCosta/3f9f371f1db6c65aa2cbe9ef805a848d to your computer and use it in GitHub Desktop.
Save HallexCosta/3f9f371f1db6c65aa2cbe9ef805a848d to your computer and use it in GitHub Desktop.
Bash Advanced Commands

Bash Advanced Commands

Getting Started

  • I/O Redirection
    • >/dev/null

Usage

This is a example of use the function I/O Redirection in conditional structure

#!/bin/sh

# Verify if NPM was installed
if which npm >/dev/null; then
  echo "NPM installed"
  npm -v
else
  echo "NPM not Installed"
fi

# Verify if YARN was installed
if which yarn >/dev/null; then
  echo "YARN installed"
  yarn -v
else
  echo "YARN not Installed"
fi

# Verify if TMUX was installed
if which tmux >/dev/null; then
  echo "TMUX installed"
  tmux -V
else
  echo "TMUX not Installed"
fi

References: https://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment