piatok 6. mája 2022

what is ^ in bash?

Regular expressions are not very friendly for many linux administrators. I will try explain this regular expression ^. 


In English keyboard ^ you find with SHIFT+6! 





How it works? 


We have some file and we need find dhcp servers. 


Is it easy? Let me try! 


cat file | grep -i dhcp 


output


dhcp=18.21.51.98

#If you want DHCP servers please burn......


while dhcp ....


starting dhcp....


ok.... everything is fine but dhcp is not on the begining of line. 


Please try with ^!



cat file | "^dhcp*"


output: 


dhcp=18.21.51.98



that's all!


remember: 


1) regular expressions need ""

2) ^ is begining of line




Žiadne komentáre:

Zverejnenie komentára