[Solved] How to grep all the strings which end with ‘.txt’
How to grep all the strings which end with ‘.txt’ extension.
Some one ask this question on Ubuntu and I tried to figure it out the possibilities in which the outcome can be benefit to others.
May be the commands I used is not suitable for you as it is you can modified as by the need to you but it is most commonly used.
Previously he tried command to do the following is as under:
grep 'txt$' myFile
How to grep all the strings which end with ‘.txt’ Solution:
grep -o '\w*\.txt\b' myFile
grep -Eo '\w+\.txt\b' myFile
$ Grep -w
-w to get all words.
$ Grep -n
-n if you want results on their own line.
$ Grep -i
-i will do a case-insensitive search.
$ Grep -c
-c will return the number of times that word appeared in the file.
Above extensions are not specified to command you can use as it require. If you more commands regarding grep type:
$ grep –help
In this you can find all the commands regarding grep and its uses. This how can [Solved] How to grep all the strings which end with ‘.txt’.
If you have any suggestions please post free the comments section.