Download nhạc từ các trang nhạc lớn của Việt Nam

30 Tháng Mười 2006
@ 07:58
(Tác giả:Phạm Đức Hải)
Nguồn : Some examples of using UNIX find command.
Introduction

The find command allows the Unix user to process a set of files and/or directories in a file subtree.

You can specify the following:

  • where to search (pathname)
  • what type of file to search for (-type: directories, data files, links)
  • how to process the files (-exec: run a process against a selected file)
  • the name of the file(s) (-name)
  • perform logical operations on selections (-o and -a)
Search for file with a specific name in a set of files (-name)
find . -name "rc.conf" -print

This command will search in the current directory and all sub directories for a file named rc.conf.

Note: The -print option will print out the path of any file that is found with that name. In general -print wil print out the path of any file that meets the find criteria.

How to apply a unix command to a set of file (-exec).
find . -name "rc.conf" -exec chmod o+r '{}' \;

This command will search in the current directory and all sub directories. All files named rc.conf will be processed by the chmod -o+r command. The argument '{}' inserts each found file into the chmod command line. The \; argument indicates the exec command line has ended.

The end results of this command is all rc.conf files have the other permissions set to read access (if the operator is the owner of the file).

How to apply a complex selection of files (-o and -a).
find /usr/src -not \( -name "*,v" -o -name ".*,v" \) '{}' \; -print

This command will search in the /usr/src directory and all sub directories. All files that are of the form '*,v' and '.*,v' are excluded. Important arguments to note are:

  • -not means the negation of the expression that follows
  • \( means the start of a complex expression.
  • \) means the end of a complex expression.
  • -o means a logical or of a complex expression.
    In this case the complex expression is all files like '*,v' or '.*,v'

The above example is shows how to select all file that are not part of the RCS system. This is important when you want go through a source tree and modify all the source files... but ... you don't want to affect the RCS version control files.

How to search for a string in a selection of files (-exec grep ...).
find . -exec grep "www.ajaxviet.com" '{}' \; -print

This command will search in the current directory and all sub directories. All files that contain the string will have their path printed to standard output.

If you want to just find each file then pass it on for processing use the -q grep option. This finds the first occurrance of the search string. It then signals success to find and find continues searching for more files.

find . -exec grep -q "www.ajaxviet.com" '{}' \; -print

This command is very important for process a series of files that contain a specific string. You can then process each file appropriately. An example is find all html files with the string "www.athabascau.ca". You can then process the files with a sed script to change those occurrances of "www.athabascau.ca" with "intra.athabascau.ca".

Chuyên mục: Linux

Referred by:
search file script not using find (www.google.com.vn) [Referral]
find command + linux (www.google.com.vn) [Referral]
Linux find command find java or (www.google.com.vn) [Referral]
find exec (www.google.com.vn) [Referral]
ubuntu using find command (www.google.com.vn) [Referral]
find content in file unix command (www.google.com.vn) [Referral]
linux command+find+print out path (www.google.com.vn) [Referral]
linux command find sub (www.google.com.vn) [Referral]
find command content file php linux (www.google.com.vn) [Referral]
find man command (www.google.com.vn) [Referral]
finding some blog (www.google.com.vn) [Referral]
unix blog (www.google.com.vn) [Referral]
find command directory in Ubuntu (www.google.com.vn) [Referral]
command in unix (www.google.com.vn) [Referral]
find directory path unix (www.google.com.vn) [Referral]
command find (www.google.com.vn) [Referral]
search a string in all find by command on Linux (www.google.com.vn) [Referral]
find command ubuntu (www.google.com.vn) [Referral]
"{} \;" + "find command" (www.google.com.vn) [Referral]
Linux command + find + grep (www.google.com.vn) [Referral]
"\;" + "find command" + "indicates" (www.google.com.vn) [Referral]
"\;" + "indicates" + "exec" + "ended" (www.google.com.vn) [Referral]
linux find file in sub directory (www.google.com.vn) [Referral]
exsample command get path directory SQLserver 2000 (www.google.com.vn) [Referral]
command find (www.google.com.vn) [Referral]
use comments in unix (www.google.com.vn) [Referral]
comand grep linux (www.google.com.vn) [Referral]
unix how to search content in file (www.google.com.vn) [Referral]
linux command + search command (www.google.com.vn) [Referral]
tìm kiếm với find command (www.google.com.vn) [Referral]
sed (www.google.com.vn) [Referral]
search " in file + UNIX (www.google.co.in) [Referral]
find command (www.google.com.vn) [Referral]
how to use find command on ubuntu (www.google.com.vn) [Referral]
unix directory find search (www.google.com.vn) [Referral]
find command (www.google.com.vn) [Referral]
find command (www.google.com.vn) [Referral]
linux command (www.google.com.vn) [Referral]
search file content in linux grep find (www.google.com.vn) [Referral]
find command (www.google.com.vn) [Referral]
some blog (www.google.com.vn) [Referral]
linux find command logical or (www.google.com) [Referral]
command exec linux (www.google.com.vn) [Referral]
joomla unix path (www.google.com.vn) [Referral]