1.

Write difference between grep and find command.

Answer»
  • Grep command: This command facilitates searching and displaying content based on regular expressions specified by the user. Using the Grep command, one can search in a file for PATTERNS. Grep command have the following syntax:
    grep “literal string” <filename>

Example: 

grep “apple” file1.txt //Displays all the lines with the word “apple” in the file1grep “apple” file1.txt  file2.txt //Scan MULTIPLE documents and search the word “apple” in both files.
  • Find command: The FIND command searches for files and folders based on their size, modification time, and access time. You can use this command to search files and directories. Find command have the following syntax:
    find <path> <search criteria> <action>

Example:

find –type  f  // Command will find all the filesfind  –type  d  //Command will find all the directoriesfind .  –name file1.txt //Command will find file1.txt in the CURRENT directory.


Discussion

No Comment Found