OVOmkar Venkatrao Punjajiincosmicomkar.hashnode.dev·Apr 23, 2023 · 1 min readAppend output end of text file#! /bin/bash echo "-e Enter file name: \c" read file_name if [ -f $file_name ] then if [ -w $file_name ] then echo "type some data to append to the file. To quit press ctrl+d:" cat >> $file_nameelse echo "File don't have to write permission" fi else ...00
OVOmkar Venkatrao Punjajiincosmicomkar.hashnode.dev·Apr 23, 2023 · 1 min readfile test operator#! /bin/bash echo -e "Enter the name of the file: \c" # -e flag for /c so the cursor stays on the same line read file_name if [ -d $file_name ] # {-f... for regular file }, {-d ... for directory } # {-c ... for character special file } , { -b ... for...00
OVOmkar Venkatrao Punjajiincosmicomkar.hashnode.dev·Apr 23, 2023 · 1 min readif Statements#! /bin/bash #Integers comparison operators #String comparison #{ { = , == , != } ..... [ "$a" = "$b" ] #{ {< , > , -z {for null string , #zero-length string } ..... [[ "$a" < "$b" ]] count=10 if [ $count -eq 10 ] then echo "Number Equal to 10 " fi i...00
OVOmkar Venkatrao Punjajiincosmicomkar.hashnode.dev·Apr 23, 2023 · 1 min readpass Args to bash Script in terminal#! /bin/bash echo "Your Args Variables are: $0 $1 $2 $3" #Pass Args as Array elements: args=("$@") echo "Args Var...: ${args[0]} , ${args[1]} , ${args[2]}" #Prints all args Variables echo $@ #Prints number of args00
OVOmkar Venkatrao Punjajiincosmicomkar.hashnode.dev·Apr 23, 2023 · 1 min readread input from user#! /bin/bash echo "Enter your name: " read name echo "Entered name: $name" #multi variables input echo "Enter Names:" read name1 name2 name3 echo "Names are : $name1 , $name2 , $name3" #Take User input on the same line read -p "username:" user_var ec...00