Find command usage in Linux with excellent examples--reference

本文详细介绍了Linux find命令的使用方法,包括基于文件类型、权限、日期、大小及所有权的查找,以及如何搜索特定文件和目录。通过提供丰富的示例,帮助用户掌握find命令的高级应用。
find searches  the directory tree rooted at each given file name by evaluating  the  given expression from left to right, according to the rules of prece dence, until the outcome is known (the left  hand side is false for and operations, true for or), at which point  find moves on to the next file name.
The syntax of find command is:
 
find where-to-look criteria what-to-do
 
I have tried to explain the find command usage with all possible examples:
 
 
 
 
Part I – Find Files Based on their types
 
1. Find Files Using Name in Current Directory

Find all the files whose name is codeon.txt in a current working directory.

 # find . -name codeon.txt

2. Find Files Under Home Directory
  
Find all the files under /home directory with name codeon .txt.

 # find /home -name codeon.txt 
 
3. Find Files Using Name and Ignoring Case

Find all the files whose name is codeon .txt and contains both capital and small letters in /home directory.

   # find /home -iname codeon.txt

4. Find Directories Using Name

Find all directories whose name is Codeon in /directory.

   # find / -type d -name Codeon

5. Find PHP Files Using Name

Find all php files whose name is codeon .php in a current working directory.

   # find . -type f -name codeon.php

6. Find all PHP Files in Directory
 
# find . -type f -name "*.php"

 
Part II – Find Files Based on their Permissions

7.  Find all the files whose permissions are 777
 
# find . -type f -perm -0777
 
8. Find all the files without permission 777
 
# find / -type f   !  -perm -777
  
9. Find all the SGID bit set files whose permissions set to 644
 
 # find / -perm -2644
  
10. Find all the Sticky Bit set files whose permission are 551
 
# find / -perm -1551
  
11. Find all SUID set Files

   # find / -perm -4000
  
12. Find all SGID set files
 
  # find / -perm -2000
  
13. Find all Sticky bit set files
  
  # find / -perm -1000

  14. Find all Read Only files

   # find / -perm /u=r
  
15. Find all Executable Files
 
   # find / -perm /a=x
  
16. Find all 777 permission files and use chmod command to set permissions to 644

   # find / -type f -perm 0777 -print -exec chmod 644 {} \;
  
17. Find all 777 permission directories and use chmod command to set permissions to 755

 # find / -type d -perm 777 -print -exec chmod 755 {}  \;
  
18. Find and remove single File

To find a single file called codeon .txt and remove it.

   # find . -type f -name "codeon.txt" -exec rm -f {} \;
  
19. Find and remove Multiple File

To find and remove multiple files such as .mp3 or .txt, then use.

# find . -type f -name "*.txt" -exec rm -f {}  \;

OR

# find . -type f -name "*.mp3" -exec rm -f {}  \;
  
20. Find all Empty Files

To find all empty files under certain path.

   # find /tmp -type f -empty
  
21. Find all Empty Directories

To find all empty directories under certain path.

   # find /tmp -type d -empty
  
22. File all Hidden Files

To find all hidden files, use below command

   # find /tmp -type f -name ".*"
  
Note: always put -name before ".*"
  
Part III - Search files based on owners and groups

 

23. Find Single File Based on User

To find all or single file called codeon .txt under /root directory of owner root.

   # find / -user root -name codeon.txt
  
24. Find all Files Based on User

To find all files that belongs to user Codeon under /home directory.

   # find /home -user codeon
  
25. Find all Files Based on Group

To find all files that belongs to group Developer under /home directory.

   # find /home -group Developer
  
26. Find Particular Files of User

To find all .txt files of user codeon under /home directory.

   # find /home -user codeon -iname "*.txt"
 
Part IV – Find Files and Directories Based on Date and Time

 


27. Find Last 50 Days Modified Files

To find all the files which are modified 50 days back.

   # find / -mtime 50
  
28. Find Last 50 Days Accessed Files

To find all the files which are accessed 50 days back.

   # find / -atime 50
  
29. Find Last 50-100 Days Modified Files

To find all the files which are modified more than 50 days back and less than 100 days.

   # find / -mtime +50 –mtime -100
  
30. Find Changed Files in Last 1 Hour

To find all the files which are changed in last 1 hour.

   # find / -cmin -60
  
31. Find Modified Files in Last 1 Hour

To find all the files which are modified in last 1 hour.

   # find / -mmin -60
  
32. Find Accessed Files in Last 1 Hour

To find all the files which are accessed in last 1 hour.

   # find / -amin -60
 

Part V - Find files and directories based on size

33. Find 50MB Files

To find all 50MB files, use

   # find / -size 50M
  
34. Find Size between 50MB – 100MB

To find all the files which are greater than 50MB and less than 100MB.

   # find / -size +50M -size -100M
  
35. Find and Delete 100MB Files

To find all 100MB files and delete them using one single command.

   # find / -size +100M -exec rm -rf {}  \;
  
36. Find Specific Files and Delete

Find all .mp3 files with more than 10MB and delete them using one single command.

   # find / -type f -name *.mp3 -size +10M -exec ls -l {}  \;

- See more at: http://www.coolcoder.in/2014/02/find-command-usage-in-linux-with.html#sthash.vnYfMYA6.dpuf

.net 8.0 <PackageReference Include="indice.Edi" Version="1.12.0" /> 将X12文档反序列化为.NET对象,解析處理EDI850文件 完整代碼 EDI Serializer/Deserializer. Used to read & write EDI streams. This is a ground up implementation and does not make use of XML Serialization in any step of the process. This reduces the overhead of converting into multiple formats allong the way of getting the desired Clr object. This makes the process quite fast. Tested with Tradacoms, EDIFact and ANSI ASC X12 (X12) formats. Using attributes you can express all EDI rules like Mandatory/Conditional Segments, Elements & Components as well as describe component values size length and precision with the picture syntax (e.g 9(3), 9(10)V9(2) and X(3)). Quick links Installation Attributes Example usage Deserialization (EDI to POCOs) Serialization (POCOs to EDI) Contributions The Picture clause Roadmap Installation To install Edi.Net, run the following command in the Package Manager Console. Or download it here PM> Install-Package "indice.Edi" Attributes. The general rules of thumb are : Attribute Description EdiValue Any value inside a segment. (ie the component value 500 in bold) UCI+001342651817+9907137000005:500+9912022000002:500+7 EdiElement Elements are considered to be groups of values otherwise known as groups of components. One can use this attribute to deserialize into a complex class that resides inside a segment. For example this can usually be used to deserialize more than one value between + into a ComplexType (ie the whole element into a new class 9912022000002:500 in bold) UCI+001342651817+9907137000005:500+9912022000002:500+7 EdiPath To specify the path EdiSegment Marks a propery/class to be deserialized for a given segment. Used in conjunction with EdiPath EdiSegmentGroup Marks a propery/class as a logical container of segments. This allows a user to decorate a class whith information regarding the starting and ending segments that define a virtual group other than the standard ones (Functional Group etc). Can be applied on Lists the same way that [Message] or [Segment] attributes work EdiMessage Marks a propery/class to be deserialized for any message found. EdiGroup Marks a propery/class to be deserialized for any group found. EdiCondition In case multiple MessageTypes or Segment types with the same name. Used to discriminate the classes based on a component value Example usage: There are available configurations (EdiGrammar) for EDIFact, Tradacoms and X12. Working examples for all supported EDI formats can be found in the source code under tests. EdiFact sample POCO classes TRADACOMS sample classes (UtilityBill) X12 sample classes (850 Purchase Order) Note that all examples may be partialy implemented transmissions for demonstration purposes although they are a good starting point. If someone has complete poco classes for any transmition please feel free to contribute a complete test. Deserialization (EDI to POCOs) The following example makes use of the Tradacoms grammar and deserializes the sample.edi file to the Interchange class. var grammar = EdiGrammar.NewTradacoms(); var interchange = default(Interchange); using (var stream = new StreamReader(@"c:\temp\sample.edi")) { interchange = new EdiSerializer().Deserialize<Interchange>(stream, grammar); } Serialization (POCOs to EDI) In this case we are instantiating our POCO class Interchange and then fill-it up with values before finally serializing to out.edi. var grammar = EdiGrammar.NewTradacoms(); var interchange = new Interchange(); // fill properies interchange.TransmissionDate = DateTime.Now; ... // serialize to file. using (var textWriter = new StreamWriter(File.Open(@"c:\temp\out.edi", FileMode.Create))) { using (var ediWriter = new EdiTextWriter(textWriter, grammar)) { new EdiSerializer().Serialize(ediWriter, interchange); } } Model Annotated POCOS example using part of Tradacoms UtilityBill format: public class Interchange { [EdiValue("X(14)", Path = "STX/1/0")] public string SenderCode { get; set; } [EdiValue("X(35)", Path = "STX/1/1")] public string SenderName { get; set; } [EdiValue("9(6)", Path = "STX/3/0", Format = "yyMMdd", Description = "TRDT - Date")] [EdiValue("9(6)", Path = "STX/3/1", Format = "HHmmss", Description = "TRDT - Time")] public DateTime TransmissionStamp { get; set; } public InterchangeHeader Header { get; set; } public InterchangeTrailer Trailer { get; set; } public List<UtilityBill> Invoices { get; set; } } [EdiMessage, EdiCondition("UTLHDR", Path = "MHD/1")] public class InterchangeHeader { [EdiValue("9(4)"), EdiPath("TYP")] public string TransactionCode { get; set; } [EdiValue("9(1)", Path = "MHD/1/1")] public int Version { get; set; } } [EdiMessage, EdiCondition("UTLTLR", Path = "MHD/1")] public class InterchangeTrailer { [EdiValue("9(1)", Path = "MHD/1/1")] public int Version { get; set; } } [EdiMessage, EdiCondition("UTLBIL", Path = "MHD/1")] public class UtilityBill { [EdiValue("9(1)", Path = "MHD/1/1")] public int Version { get; set; } [EdiValue("X(17)", Path = "BCD/2/0", Description = "INVN - Date")] public string InvoiceNumber { get; set; } public MetetAdminNumber Meter { get; set; } public ContractData SupplyContract { get; set; } [EdiValue("X(3)", Path = "BCD/5/0", Description = "BTCD - Date")] public BillTypeCode BillTypeCode { get; set; } [EdiValue("9(6)", Path = "BCD/1/0", Format = "yyMMdd", Description = "TXDT - Date")] public DateTime IssueDate { get; set; } [EdiValue("9(6)", Path = "BCD/7/0", Format = "yyMMdd", Description = "SUMO - Date")] public DateTime StartDate { get; set; } [EdiValue("9(6)", Path = "BCD/7/1", Format = "yyMMdd", Description = "SUMO - Date")] public DateTime EndDate { get; set; } public UtilityBillTrailer Totals { get; set; } public UtilityBillValueAddedTax Vat { get; set; } public List<UtilityBillCharge> Charges { get; set; } public override string ToString() { return string.Format("{0} TD:{1:d} F:{2:d} T:{3:d} Type:{4}", InvoiceNumber, IssueDate, StartDate, EndDate, BillTypeCode); } } [EdiSegment, EdiPath("CCD")] public class UtilityBillCharge { [EdiValue("9(10)", Path = "CCD/0")] public int SequenceNumber { get; set; } [EdiValue("X(3)", Path = "CCD/1")] public ChargeIndicator? ChargeIndicator { get; set; } [EdiValue("9(13)", Path = "CCD/1/1")] public int? ArticleNumber { get; set; } [EdiValue("X(3)", Path = "CCD/1/2")] public string SupplierCode { get; set; } [EdiValue("9(10)V9(3)", Path = "CCD/10/0", Description = "CONS")] public decimal? UnitsConsumedBilling { get; set; } } Contributions The following is a set of guidelines for contributing to EDI.Net. Did you find a bug? Ensure the bug was not already reported by searching on GitHub under Issues. If you're unable to find an open issue addressing the problem, open a new one. Be sure to include a title and clear description, as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring. Did you write a patch that fixes a bug? Open a new GitHub pull request with the patch. Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. Build the sourcecode As of v1.0.7 the solution was adapted to support the dotnet core project system. Then it was adapted again since the dotnet core tooling was officialy relased (March 7th 2017 at the launch of Visual studio 2017). In order to build and test the source code you will need either one of the following. Visual studio 2019 + the dotnet sdk 8.0 (for v2.0.0 onwards) Visual studio 2017 + the dotnet core workload (for versions v1.1.3 - v1.x.x) Visual studio 2015 Update 3 & .NET Core 1.0.0 - VS 2015 Tooling (for versions v1.0.7 - v1.1.2) VS Code + .NET Core SDK for more information check .Net Core official page. The Picture clause The Picture Clause is taken from COBOL laguage and the way it handles expressing numeric and alphanumric data types. It is used throughout tradacoms. Symbol Description Example Picture Component c# result 9 Numeric 9(3) 013 int v = 13; A Alphabetic not used - - X Alphanumeric X(20) This is alphanumeric string v = "This is alphanumeric"; V Implicit Decimal 9(3)V9(2) 01342 decimal v = 13.42M; S Sign not used - - P Assumed Decimal not used - - Roadmap (TODO) Implement serializer Serialize to write Clr classes to edi format (Using attributes). (planned for v1.1) Start github wiki page and begin documentation. Create a seperate package (or packages per EDI Format) to host well known interchange transmitions (ie Tradacoms Utitlity Bill). Then anyone can fork and contribute his own set of POCO classes. Disclaimer. The project was inspired and influenced by the work done in the excellent library JSON.Net by James Newton King. Some utility parts for reflection string parsing etc. are used as is
11-28
AI 代码审查Review工具 是一个旨在自动化代码审查流程的工具。它通过集成版本控制系统(如 GitHub 和 GitLab)的 Webhook,利用大型语言模型(LLM)对代码变更进行分析,并将审查意见反馈到相应的 Pull Request 或 Merge Request 中。此外,它还支持将审查结果通知到企业微信等通讯工具。 一个基于 LLM 的自动化代码审查助手。通过 GitHub/GitLab Webhook 监听 PR/MR 变更,调用 AI 分析代码,并将审查意见自动评论到 PR/MR,同时支持多种通知渠道。 主要功能 多平台支持: 集成 GitHub 和 GitLab Webhook,监听 Pull Request / Merge Request 事件。 智能审查模式: 详细审查 (/github_webhook, /gitlab_webhook): AI 对每个变更文件进行分析,旨在找出具体问题。审查意见会以结构化的形式(例如,定位到特定代码行、问题分类、严重程度、分析和建议)逐条评论到 PR/MR。AI 模型会输出 JSON 格式的分析结果,系统再将其转换为多条独立的评论。 通用审查 (/github_webhook_general, /gitlab_webhook_general): AI 对每个变更文件进行整体性分析,并为每个文件生成一个 Markdown 格式的总结性评论。 自动化流程: 自动将 AI 审查意见(详细模式下为多条,通用模式下为每个文件一条)发布到 PR/MR。 在所有文件审查完毕后,自动在 PR/MR 中发布一条总结性评论。 即便 AI 未发现任何值得报告的问题,也会发布相应的友好提示和总结评论。 异步处理审查任务,快速响应 Webhook。 通过 Redis 防止对同一 Commit 的重复审查。 灵活配置: 通过环境变量设置基
【直流微电网】径向直流微电网的状态空间建模与线性化:一种耦合DC-DC变换器状态空间平均模型的方法 (Matlab代码实现)内容概要:本文介绍了径向直流微电网的状态空间建模与线性化方法,重点提出了一种基于耦合DC-DC变换器的状态空间平均模型的建模策略。该方法通过数学建模手段对直流微电网系统进行精确的状态空间描述,并对其进行线性化处理,以便于系统稳定性分析与控制器设计。文中结合Matlab代码实现,展示了建模与仿真过程,有助于研究人员理解和复现相关技术,推动直流微电网系统的动态性能研究与工程应用。; 适合人群:具备电力电子、电力系统或自动化等相关背景,熟悉Matlab/Simulink仿真工具,从事新能源、微电网或智能电网研究的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握直流微电网的动态建模方法;②学习DC-DC变换器在耦合条件下的状态空间平均建模技巧;③实现系统的线性化分析并支持后续控制器设计(如电压稳定控制、功率分配等);④为科研论文撰写、项目仿真验证提供技术支持与代码参考。; 阅读建议:建议读者结合Matlab代码逐步实践建模流程,重点关注状态变量选取、平均化处理和线性化推导过程,同时可扩展应用于更复杂的直流微电网拓扑结构中,提升系统分析与设计能力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值