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
内容概要:本文介绍了一个基于Matlab的综合能源系统优化调度仿真资源,重点实现了含光热电站、有机朗肯循环(ORC)和电含光热电站、有机有机朗肯循环、P2G的综合能源优化调度(Matlab代码实现)转气(P2G)技术的冷、热、电多能互补系统的优化调度模型。该模型充分考虑多种能源形式的协同转换与利用,通过Matlab代码构建系统架构、设定约束条件并求解优化目标,旨在提升综合能源系统的运行效率与经济性,同时兼顾灵活性供需不确定性下的储能优化配置问题。文中还提到了相关仿真技术支持,如YALMIP工具包的应用,适用于复杂能源系统的建模与求解。; 适合人群:具备一定Matlab编程基础和能源系统背景知识的科研人员、研究生及工程技术人员,尤其适合从事综合能源系统、可再生能源利用、电力系统优化等方向的研究者。; 使用场景及目标:①研究含光热、ORC和P2G的多能系统协调调度机制;②开展考虑不确定性的储能优化配置与经济调度仿真;③学习Matlab在能源系统优化中的建模与求解方法,复现高水平论文(如EI期刊)中的算法案例。; 阅读建议:建议读者结合文档提供的网盘资源,下载完整代码和案例文件,按照目录顺序逐步学习,重点关注模型构建逻辑、约束设置与求解器调用方式,并通过修改参数进行仿真实验,加深对综合能源系统优化调度的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值