Creating a HEAD utility for Windows 10

One of the things I did often in my first career job was create utilities that we could use as a network support team. I was an intern coming from university, where I used SunOS and Solaris all the time. I was used to a command line for a lot of work. While DOS worked well, there were things I missed, like whoami, head, tail, etc.

I rebuilt a bunch of those as DOS batch files for myself, but I expanded this to more useful things. We supported over 1000 people, and finding their phone extensions was a pain, especially in the early 1990s with phones that had cords and pagers. We had a common file share that contained a text phone directory, so I built 411.bat, which took a parameter and searched that file for a matching name. Then returned the line of data. It was immensely helpful to us.

The other day I had a large file that I wanted a glimpse of. I opened it in Notepad++ (this was GBs of data), but it took time. That made me think I’d really like HEAD on Windows. I tried it, but it’s not there.

So I built it. This is my command file:

powershell “get-content %1 | select-object -first 10”

I save this in a utilities folder in my path. Then in other folders, I can run it and get a glimpse of text files I’m importing or working with. Way, way faster than Excel or trying to open this in another program. I often have a cmd open, so this is useful to me. You can see it working below.

2022-08-04 08_55_24-C__utilities

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , . Bookmark the permalink.

1 Response to Creating a HEAD utility for Windows 10

  1. Jeff Moden says:

    There’s a lot to be learned by looking back. I think it’s called “experience”. Nicely done, Steve.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.