// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; public class MainClass { public static string Eater(string line, int ix, int n) { string res = ""; int ws = 0; for (int i = 1; i < line.Length; i++) { if ((line[i] == ' ') && (line[i - 1] != ' ')) { ws = ws + 1; } if ((ws >= ix) && (ws < (ix + n))) { res = res + line[i]; } } return res.Trim(); } public static void Parse(string line) { string protection = Eater(line, 0, 1); string owner = Eater(line, 1, 3); int size = int.Parse(Eater(line, 4, 1)); string tim = Eater(line, 5, 3); string filename = Eater(line, 8, 100); Console.WriteLine(filename + " " + size + " " + tim); } public static void Main(string[] args) { Parse("drwxr-xr-x 1 ftp ftp 0 Sep 01 19:38 Adobe Illustrator 10"); Parse("drwxr-xr-x 1 ftp ftp 0 Sep 07 09:36 subdir"); Parse("-rw-r--r-- 1 ftp ftp 1871872 Sep 07 11:52 a.zip"); Parse("-rw-r--r-- 1 ftp ftp 21814474 Sep 07 09:53 z.zip"); } }