How To Find With PowerShell

Finding files, do I even need to describe how important this is?

Finding files, do I even need to describe how important this is? From finding README files in a project $ find . -name README* ./app/ ./ ./ to locating that one config file you never can remember the location of. $ find . -name dnsconf.yaml ./app/module1/dnsconf.yaml .notice{padding:18px;line-height:24px;margin-bottom:24px;border-radius:4px;color:#444;background:#e7f2fa}.notice p:last-child{margin-bottom:0}.notice-title{margin:-18px -18px 12px;padding:4px 18px;border-radius:4px 4px 0 0;font-weight:700;color:#fff;background:#6ab0de}.notice.warning .notice-title{background:rgba(217,83,79,.9)}.notice.warning{background:#fae2e2} .notice-title{background:#f0b37e}{background:#fff2db}.notice.note .notice-title{background:#6ab0de}.notice.note{background:#e7f2fA}.notice.tip .notice-title{background:rgba(92,184,92,.8)}.notice.tip{background:#e6f9e6}.icon-notice{display:inline-flex;align-self:center;margin-right:8px}.icon-notice img,.icon-notice svg{height:1em;width:1em;fill:currentColor}.icon-notice img,.icon-notice.baseline svg{top:0.125em;position:relative} Info All commands in this post are run against a open source repository to allow you to reproduce output & play with the commands. [Read More]

How To Grep With PowerShell

It's just like Bash, but more powerful!

Filtering data, from log or config files to data returned by an api, is an important operation to remove noise from it and make further analysis possible. In Bash most would gravitate towards grep, egrep or awk. Classic examples would be looking at your history $ history | grep ssh ssh marco@ ssh deploy@ ssh admin@ looking for errors in a log $ cat /var/log/app.log | grep error 2020-09-30 09:01:17 error: twitter api responded with 403 2020-09-30 09:16:05 error: secret plan to take over the world failed grep $ grep api app. [Read More]

How To Tail With PowerShell

How to replace tail in PowerShell

Printing the last or first, few lines of a file is a common operation in day to day operations. On Linux most people will, without thinking twice, use tail and it’s counterpart head to achieve this. It’s man page1 describes tail simply like this Print the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. [Read More]

Bash Utilities In Powershell

Replacing common bash utilities in PowerShell

Whats the first thing coming to mind when seeing a command line? For most people it is Linux, be it Ubuntu, Debian or RedHat. And it is completely understandable. A big part of our industry has a background in Linux and sees it as the superior system for quick scripts and the like. In this series I want to challenge this notion. PowerShell can compete with, an in some cases outperform, the quick scripts and common daily tasks done in Linux shells. [Read More]