In: Computer Science
this is bash scripting.
a. Explain the difference between grep and egrep?
b. Write a command to list files where third letter is x or y?
c. Write command to remove array element with id 5
Answer a)
grep stands for Global Regular Expressions Print but egrep stands
for Extended Global Regular Expressions Print
When we use grep for pattern search for the symbols cannot be done directly we have to use the backslash but in egrep the symbols are the meta characters which we can use directly without backslash.
grep -E is same as egrep
screenshot
Answer b)
ls ??[xy]*
here ?? means any character for the first two characters and for the third letter [xy] means either x or y then * means any character after x or y.
Screenshot
Answer c)
unset arr1[5]
By the unset command we can remove the array element in a shell script.