Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Linux – Is there a difference between a grep command with '[.]' or [.]?

sysadmin@localhost:~/Documents$ grep ‘[.]’ profile.txt                          
Hello my name is Joe**.**                                                           
I am 37 years old**.**                                                              
My favorite food is avocados**.**                                                   
I have 2 dogs**.** 

sysadmin@localhost:~/Documents$ grep [.] profile.txt                          
Hello my name is Joe**.**                                                           
I am 37 years old**.**                                                              
My favorite food is avocados**.**                                                   
I have 2 dogs**.** 

They both outputed the same answer but there’s something hidden that i’m missing?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

No, there is no difference. In this StackOverflow post with a similar question, the accepted answer shows how you can use echo to test out in what way your command is being processed before being executed.

Try out the following:

someone@somewhere:~$ echo grep [.] profile.txt
grep [.] test.txt
someone@somewhere:~$ echo grep '[.]' profile.txt
grep [.] test.txt

You see, the commands that are executed are the same exact commands 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading