Riaan Lehmkuhl's Blog

Subversion, Progamming, Tips & Tricks and whatever else springs to mind.
16Dec

cat Command for windows

16 December 2009 10:24 by Riaan Lehmkuhl

The cat command is one of the most frequently used commands on Linux/Unix like operating systems. Needless to say it could also be very useful on your Windows system.

Here is the C# code to create your own cat command...

Program.cs:

using System;

namespace cat {
    class Program {
        static void Main(string[] args) {
            if (null != args && args.Length > 0) {
                foreach (string arg in args) {
                    if (System.IO.File.Exists(arg)) {
                        Console.Write(System.IO.File.ReadAllText(arg));
                        Console.Write(Environment.NewLine);
                    }
                }
            }
        }
    }
}

The usage should be mostly the same as with it’s Unix counterpart.

To learn more see The cat Command.

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

1/26/2010 2:40:02 AM #

Indonesia Java International Destination

nice trick for windows, thanks for your imaginative idea

Indonesia Java International Destination United States

3/3/2010 3:30:20 PM #

cheap prada

in most cases it can be replaced by the operator '<' or transfer of the file name as an argument

cheap prada United States

3/4/2010 3:32:37 PM #

Kevin

For us non-programmers - Powershell does the trick too! Something like:

cat c:\sample.txt | findstr hellWorld

Kevin United Kingdom

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading


Riaan Lehmkuhl


Me, a disorder of the brain that results in a disruption in a person's thinking, mood, and ability to relate to others.

Recent comments

Comment RSS

Thingies

Calendar And Month List

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Disclaimer & Privacy

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008

Privacy:
We use third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

Most comments

Kevin Kevin
1 comments
gb United Kingdom
Moneymaker Moneymaker
1 comments
Indonesia Java International Destination Indonesia Java International Destination
1 comments
us United States

Cool Quote

I know that you believe that you understood what you think I said, but I am not sure you realize that what you heard is not what I meant. - Robert McCloskey