![unix find word in file with line number unix find word in file with line number](https://oss-emcsprod-public.modb.pro/wechatSpider/modb_20220704_4adc2a66-fb8b-11ec-a026-fa163eb4f6be.png)
Use -exclude-dir option to exclude directory from search. Same as with files grep can also exclude specific directories from the search. Similarly, using -exclude option we can exclude any specific filenames:
![unix find word in file with line number unix find word in file with line number](https://oldjhos.files.wordpress.com/2019/04/54065-holy-2598222_960_720.800w.tn_.jpg)
conf within /etc directory containing string bash: The next example will find all files with extension. For example we only would like to search for a specific text/string within configuration files with extension. Using grep command it is also possible to include only specific files as part of the search. Include or Exclude specific files names from search By using grep’s -i option the command will also list any lines containing Stretch, STRETCH, StReTcH etc., hence, to perform case-insensitive search. The next example will only show all file names containing string stretch within /etc/ directory recursively:Īll searches are by default case sensitive which means that any search for a string stretch will only show files containing the exact uppercase and lowercase match. The above commands may produce an unnecessary output. List only files names containing a specific text Use grep’s -w option to show only a specific word: Meaning the lines with stretches, stretched etc. The above grep command example lists all files containing string stretch. Search for all files containing a specific word etc/os-release:PRETTY_NAME="Debian GNU/Linux 9 (stretch)" etc/grub.d/00_header:background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"` etc/dictionaries-common/words:stretching etc/dictionaries-common/words:stretchiest etc/dictionaries-common/words:stretchier etc/dictionaries-common/words:stretchers etc/dictionaries-common/words:stretcher's etc/dictionaries-common/words:outstretching etc/dictionaries-common/words:outstretches etc/dictionaries-common/words:outstretched etc/dictionaries-common/words:outstretch etc/dictionaries-common/words:homestretches etc/dictionaries-common/words:homestretch's etc/dictionaries-common/words:homestretch etc/dictionaries-common/words:backstretches etc/dictionaries-common/words:backstretch's etc/dictionaries-common/words:backstretch etc/apt/sources.list:deb-src stretch/updates main etc/apt/sources.list:deb stretch/updates main
![unix find word in file with line number unix find word in file with line number](https://keyworx.com/media/django-summernote/2020-08-13/be515a38-f907-4b91-bc94-b7f011d7d431.jpg)
etc/apt/sources.list:deb-src stretch main etc/apt/sources.list:#deb cdrom:/ stretch main etc/apt/sources.list:# deb cdrom:/ stretch main The following linux command will search for a string stretch in all files within /etc/ directory including all sub-directories: To search recursively means to also traverse all sub-directories. The above command omitted all sub-directories. Find all files with a specific string recursively