How to find the word contained in a file with linux, look for the word contained in a file that we don't know which file contains the word. Maybe this can be a solution to solve the problem.Here I will exemplify searching for the word 'cinta' which does not know where the word is contained.

Above there are two files in the z folder which one file `dia.txt` and` love.txt` in the file contain sentences as shown in the pict.1. This time it will look for which file contains the word 'cinta' in the file in the z folder.

With the command on pict.2 it can be seen in searching for the word `cinta`, the word` love` is in the file love.txt

command description `grep -iRl "love" z`

`Grep` is a command used to search strings / words in a file. By using grep, it is easier for us to search for certain text in a file that contains a lot of text. This time I tried this grep command on the android emulator terminal. In this tutorial I look for a text "ram" on the file with the extension. Java without case sensitive / does not distinguish upper and lower case letters `i` is an argument to describe that the text is not case sensitive.
`R`, --dereference-recursive  likewise, but follow all symlinks
       --include=FILE_PATTERN  search only files that match FILE_PATTERN
       --exclude=FILE_PATTERN  skip files and directories matching FILE_PATTERN
       --exclude-from=FILE   skip files matching any file pattern from FILE
       --exclude-dir=PATTERN  directories that match PATTERN will be skipped.
`l`, --files-with-matches  print only names of FILEs containing matches.

Know the `grep` command and its arguments, you can do the `grep --help` command to find out what arguments are in the grep command and their functions.
    Blogger Comment
    Facebook Comment

1 komentar:

Thanks For Your Feedback.