Search for file on unix system
Change Language. Related Articles. Table of Contents. Improve Article. Save Article. Like Article. Next The Linux Kernel. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Writing code in comment? Please use ide. Learn more. Search a file in unix system Ask Question. Asked 5 years, 7 months ago. Active 5 years, 7 months ago.
Viewed times. I am trying to find a file using find and locate commands. I am trying to use a kind of prd systems. Improve this question. Kevdog 3, 18 18 gold badges 39 39 silver badges 61 61 bronze badges. Rajagopalarao Rajagopalarao 45 1 1 silver badge 5 5 bronze badges.
What is prd? Can you give some info about the file you are looking for? To print only the filenames that match your search, use the -l operator:. The output shows the exact filenames that contain phoenix in the current directory but does not print the lines with the corresponding word:. As a reminder, use the recursive search operator -r to include all subdirectories in your search. When grep prints results with many matches, it comes handy to see the line numbers. Append the -n operator to any grep command to show the line numbers.
We will search for Phoenix in the current directory, show two lines before and after the matches along with their line numbers.
Individual files, such as log files, can contain many matches for grep search patterns. Limit the number of lines in the grep output by adding the -m option and a number to the command. In this case, the terminal prints the first two matches it finds in the sample file. If you do not specify a file and search all files in a directory, the output prints the first two results from every file along with the filename that contains the matches.
The grep command is highly flexible with many useful operators and options. By combining grep commands, you can get powerful results and find the text hiding in thousands of files. What is the grep Command? Was this article helpful? Goran Jevtic. Working with multiple departments and on various projects, he has developed an extraordinary understanding of cloud and virtualization technology trends and best practices.
Next you should read. SysAdmin Web Servers. Cron is used to schedule scripts and commands on Linux systems. When find examines or prints information about files, the information used shall be taken from the properties of the file to which the link points, not from the link itself unless it is a broken symbolic link or find is unable to examine the file to which the link points.
Use of this option implies -noleaf. If you later use the -P option, -noleaf will still be in effect. If -L is in effect and find discovers a symbolic link to a subdirectory during its search, the subdirectory pointed to by the symbolic link will be searched.
Do not follow symbolic links, except while processing the command line arguments. When find examines or prints information about files, the information used shall be taken from the properties of the symbolic link itself.
0コメント