Matches all lines starting with lowercase a-s Matches the preceding item 0 or more times Matches all the line starting and ending with t and 2 char between them Using regular expression Metacharacters with grep command: To count the number of lines containing the pattern root in the /etc/group file: To search for the names of the files that contains the keyword root in /etc directory : To search for all the lines that does not contain the keyword root: Suppose we want to search for all lines that contain the keyword root in /etc/group file and view their line numbers, we use following option : Searches for the expression as acomplete word, ignoring those matches that are sub strings of larger words Inverts the search to display lines that do not match pattern Precedes each line with the relative line number in the file Lists the name of files with matching lines Searches both uppercase and lowercase characters Following command is used :ĭaemon 2557 1 0 Jul 07 ? 0:00 /usr/lib/nfs/statd Lets take an example where we want to see if the process statd is running of not. Using the grep command : The grep is very useful and widely used command. Searching Files, Directories & its contents : and /.Įxample: If you want to move two levels up the current working directory, we will use the command : We can also navigate multiple levels up in directory using cd. So if we want to go to the parent directory of the current working directory following command is used: → Parent directory or directory above the current working directory. There are few other path name abbreviations which we can use as well. However this functionality is not available in all shells. In the above examples, the '~' character is the abbreviation that represents the absolute path of the user's home directory. There is also a different way to navigate to the user's home directory : If cd command is used without any option it changes the directory from current working directory to user's home directory.Įxample: Let the user be 'ravi' and current working directory is /var/adm/messages Changing Directories : 'cd' commad is used to change directories.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |