Posts

Showing posts from May, 2022

All about SED

 Best videos of sed on youtube: playlist here Pattern space and Hold space:  Pattern space and hold space, first read throery  here ,(don't doe exercises there, they are confusing) what does H,h,G,g and x mean and recall above 4 terms 10 times and read the below explanation: When sed reads a file line by line, the line that has been currently read is inserted into the   pattern   buffer (pattern space). Pattern buffer is like the temporary buffer, the scratchpad where the current information is stored. When you tell sed to print, it prints the pattern buffer. Hold buffer / hold space is like a long-term storage, such that you can catch something, store it and reuse it later when sed is processing another line. You do not directly process the hold space, instead, you need to copy it or append to the pattern space if you want to do something with it. For example, the print command  p  prints the pattern space only. Likewise,  s  operates on the...

Scripting Imp rules

Image
1. Command Substitution: old style: `command` new style: $(command) -> Recommanded Eg: echo "Todays date is: `date +%D`"        echo "Todays date is:$(date +%D)" 2. variable substitution $variable name ${variablename} -> Recommanded Never use single quoates for variable substitution Eg: echo '$NAME' ouput: $NAME 3.Arihmetic operations: We can perform arthemetic operations using 4 ways: 2 nd method is not used mostly Example: Note(VVIMP) : Except assignment operator, for all operators we should provide space before and after operator Eg: If we provide space after assignment operator, it would result in error add_result = `expr $a + $b` (Invalid) add_result=`expr $a + $b` (valid, Since no spave before and after = operator) 4.Assignment and comparison: x=10 -> Assignment(No space) x = 10 -> comparison(space) Eg: There is space before and after =, so it is comparison #!/bin/bash read -p "Enter you name:" name if [ $name = "bhuvan"...