Hi,
How will i grep for a string which has '/' in it.

I have so many script files some are having

#!/bin/bash

and some are having

#!/bin/sh

how can i find the scripts which are having #!/bin/sh.

Thanks

Just put single quotes around the searched-for string:

grep '#!/bin/bash' filename

or use back-slashes to escape all the special characters

grep \#\!\/bin\/bash filename

Hello,

The easiest method is to enclose what you are looking for in quotes and the only charactor you have to escape is the backslash (because of the history command). For example you could run the following which would find all of the files in the /bin directory that use #!/bin/bash:

[root@lptp2 ~]# grep "#\!/bin/bash" /bin/*
/bin/abrt-action-save-kernel-data:#!/bin/bash
/bin/alsa-info:#!/bin/bash
/bin/alsa-info.sh:#!/bin/bash
/bin/animal-sniffer:#!/bin/bash
/bin/auto-br:#!/bin/bash -
/bin/auto-br-rpmbuild:#!/bin/bash -
/bin/blueproximity:#!/bin/bash
.
.