Search for 2 ** in a file in unix


Recommended Posts

hey guys im pretty new to unix and still learning. im playing around with metacharacters. Im trying to remove special meaning of * which i thought would b \* . Im wanting to search a files contents for one or more occurences of an asterix ( * )

Any advice would help

Link to comment
Share on other sites

You are right.

The backslash escape character for the asterisk is correct. For example:

mark@mark-core2:~$ touch crazy_file
mark@mark-core2:~$ mv crazy_file crazy\*file
mark@mark-core2:~$ ls cra*
crazy*file
mark@mark-core2:~$ ls | grep \*   
crazy*file
mark@mark-core2:~$

You can see that I can rename a file to include an asterisk. I can ls and see it. Then I can even pass an ls through a grep that pattern matches to find the asterisk.

Link to comment
Share on other sites

excellent so if i wanted to put this into a case statement that would search for a number of options, continuing with files

\*) echo asterix found

etc would work

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.