Tagged: bash

0

$? variable in linux

$? Status of the previous process / command which ran on the shell $ pwd $ echo $? // returns 0 which means the previous command ran sucessfully $ blahCommand $echo $? // returns...

0

How to create scripts in terminal

Follow three simple steps to automate your terminal. Create a script Set the permissions Execute the script Create a script test.sh $vi test.sh ls -la echo ‘Hello Bash!’ Set the permissions $sudo chmod 777...

0

[: !=: unary operator expected

In bash, always use the double bracket conditional command [[ … ]] For example, #!/bin/bash sex=male if [[ $sex == ‘male’ ]];then echo “sex is male.” elif [[ $sex == ‘female’ ]];then echo “sex...

0

Print a line of a local file in using command line

Print 15th line using sed sed -n “15p” hello-world.js Print 15-25 line using sed sed -n “15,25p” hello-world.js Print 15-25 line with line numbers using sed sed -n “10,20p” hello-world.js | less -N