Amit's Blog
  • Home
  • Videos
  • All Posts
  • Tags
  • About Me
Subscribe
Tagged

shell script

A collection of 2 posts

Linux

Getting exit status of the command when using pipes

I came across a situation where i needed the exit code of last command but before passing it through the pipe. For example, running the following command would give the exit code 0, even if the first command failed : root@NTRTR:/tmp# wl -i eth0 assoclist | wc -l wl: wl

  • Amit Nepal
Amit Nepal Apr 24, 2020 • 1 min read
mysql

Shell Script to Create and Grant Privilege to a new user

!/bin/bash #Script to Create a user and assign privilege to a MySQL Database read  -p  "Please Enter Database Name:" dbname mysql -Bse "USE $dbname" 2> /dev/null if [ $? -eq 0 ]; then         read -p "Please enter the  username you wish to create : " username

  • amit
amit Mar 10, 2012 • 1 min read
Amit's Blog © 2025
Powered by Ghost