Difference between revisions of "Търсене на файл и стринг"

From Ilianko
 
(6 intermediate revisions by 3 users not shown)
Line 11: Line 11:
  
  
== Търсене стринг във файловете от текуюата директория. ==
+
== Търсене стринг във файловете от текущата директория. ==
  
find . | xargs grep 'string' -sl  
+
find . | xargs grep 'string' -sl  
  
 
Търсенето се извършва от grep (-sl - опции за извеждане на резултатите)
 
Търсенето се извършва от grep (-sl - опции за извеждане на резултатите)
  
 +
== Търсене на стринг и файл ==
 +
find . -iname '*php' | xargs grep 'string' -sl
 +
 +
 +
== ==
 +
How to chmod 755 all directories but no file (recursively)?
 +
find /path/to/base/dir -type d -exec chmod 755 {} +
 +
 +
Inversely, how to chmod only files (recursively) but no directory ?
 +
find /path/to/base/dir -type f -exec chmod 644 {} +
 +
 +
Or, if there are many objects to process:
 +
chmod 755 $(find /path/to/base/dir -type d)
 +
chmod 644 $(find /path/to/base/dir -type f)
 +
 +
Or, to reduce chmod spawning:
 +
find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
 +
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644
  
== Търсене на стринг и файл ==
 
find . -iname '*php' | xargs grep 'string' -sl
 
  
 
[http://www.liamdelahunty.com/tips/linux_find_string_files.php търсене на файлове и съдържанието им]
 
[http://www.liamdelahunty.com/tips/linux_find_string_files.php търсене на файлове и съдържанието им]
 +
 +
[[Category:Linux Справочник| ]]

Latest revision as of 09:20, 23 November 2013

Търсене на файл

find . -iname '*php'

Търсене на файлове в текущата и подчинените директори на файлове завършващи с "php"

find . -iname '*php' -mtime -1

Извежда скоро редактирани файлове

find . -iname '*php' -mtime +1 

Извежда файлове редактиране същия ден.


Търсене стринг във файловете от текущата директория.

find . | xargs grep 'string' -sl 

Търсенето се извършва от grep (-sl - опции за извеждане на резултатите)

Търсене на стринг и файл

find . -iname '*php' | xargs grep 'string' -sl 


How to chmod 755 all directories but no file (recursively)?

find /path/to/base/dir -type d -exec chmod 755 {} +

Inversely, how to chmod only files (recursively) but no directory ?

find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Or, to reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644


търсене на файлове и съдържанието им