diff --git a/CMLeonOS.csproj b/CMLeonOS.csproj
index b99b15d..355fd4f 100644
--- a/CMLeonOS.csproj
+++ b/CMLeonOS.csproj
@@ -19,6 +19,11 @@
VMware
Use VMware Player or Workstation to deploy and debug.
192.168.0.8
+ Gzip
+ Elf
+ False
+ False
+ False
diff --git a/Kernel.cs b/Kernel.cs
index 71bbdd4..2b98d36 100644
--- a/Kernel.cs
+++ b/Kernel.cs
@@ -27,7 +27,7 @@ namespace CMLeonOS
Console.WriteLine(@" | |___| | | | |__| __/ (_) | | | | |_| |___) |");
Console.WriteLine(@" \____|_| |_|_____\___|\___/|_| |_|____/|____/ ");
Console.WriteLine();
- Console.WriteLine("CMLeonOS Test Project");
+ Console.WriteLine("CMLeonOS Project");
Console.WriteLine("By LeonOS 2 Developement Team");
// 注册VFS
diff --git a/Shell.cs b/Shell.cs
index 03a469b..bf62e4e 100644
--- a/Shell.cs
+++ b/Shell.cs
@@ -343,7 +343,7 @@ namespace CMLeonOS
Console.WriteLine("CMLeonOS v1.0");
break;
case "about":
- Console.WriteLine("CMLeonOS Test Project");
+ Console.WriteLine("CMLeonOS Project");
Console.WriteLine("By LeonOS 2 Developement Team");
break;
case "head":
@@ -385,6 +385,9 @@ namespace CMLeonOS
case "branswe":
ProcessBransweCommand(args);
break;
+ case "grep":
+ GrepFile(args);
+ break;
default:
Console.WriteLine($"Unknown command: {command}");
break;
@@ -1067,6 +1070,62 @@ namespace CMLeonOS
}
}
+ private void GrepFile(string args)
+ {
+ if (string.IsNullOrEmpty(args))
+ {
+ Console.WriteLine("Error: Please specify file name and search pattern");
+ Console.WriteLine("Usage: grep ");
+ return;
+ }
+
+ string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+ if (parts.Length < 2)
+ {
+ Console.WriteLine("Error: Please specify both pattern and filename");
+ Console.WriteLine("Usage: grep ");
+ return;
+ }
+
+ string pattern = parts[0];
+ string fileName = parts[1];
+
+ try
+ {
+ string filePath = fileSystem.GetFullPath(fileName);
+
+ if (!File.Exists(filePath))
+ {
+ Console.WriteLine($"Error: File not found: {fileName}");
+ return;
+ }
+
+ string content = File.ReadAllText(filePath);
+ string[] lines = content.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
+
+ int matchCount = 0;
+ Console.WriteLine($"Searching for '{pattern}' in {fileName}:");
+ Console.WriteLine("--------------------------------");
+
+ foreach (string line in lines)
+ {
+ if (line.Contains(pattern))
+ {
+ matchCount++;
+ int lineNumber = Array.IndexOf(lines, line) + 1;
+ Console.WriteLine($" Line {lineNumber}: {line}");
+ }
+ }
+
+ Console.WriteLine("--------------------------------");
+ Console.WriteLine($"Found {matchCount} matches");
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Error searching file: {ex.Message}");
+ }
+ }
+
private void ProcessEnvCommand(string args)
{
string[] parts = args.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);