Familiarity (does it breed contempt)

Many years ago, a college professor told us a story related to Unix - when Dennis Ritchie was asked a question as to what he regrets in C, Dennis Ritchie replied that he would add an 'e' to the 'creat' function. I do not know the truth of this story though Google may provide an answer.

The reason I remembered this story is simple. I wanted to post an article. Though I have a few in my kitty, most of them are not fleshed out. I wanted something smallish. So I searched my scratch pad. There I found a few PowerShell commands.

Many of us who do not have an aversion to the command prompt, particularly on Unix/Linux systems, will remember a vital debugging aide. Not the 'print' statement, but 'tail'. When executing a large application with many print / log statements, using 'vi' or 'more' or 'less' is not helpful. This is because new data is being appended to the file and none of these tools keep refreshing the data. So the invaluable command was 'tail -f app.log'. This command keeps reading data from the file as it is updated and keeps adding that text to the console, causing the text to scroll, effectively allowing us to look at the log as it is generated and also scroll up to view previous messages.

For many years, this command has been sorely missing on Windows. Windows introduced PowerShell for a more rich command line scripting experience but uses a verbose syntax. Thus

tail -f [file-name]

becomes

Get-Content -Wait -Tail 30 [file-name]

Similarly,

wc -l

becomes

Get-Content [file-name] | Measure-Object -Character

Get-Content [file-name] | Measure-Object -Word

Get-Content [file-name] | Measure-Object -Line

Get-Content [file-name] | Measure-Object -Character -Line -Word

In summary, having become familiar - over the years to the Unix/Linux syntax - this syntax feels too verbose. Initially, such a verbose syntax can give you the creeps. But the syntax will grow on you with familiarity. The good thing is that we now have feature rich scripting support even on Windows.

#scripting #shellscripting #unix #linux #windows

要查看或添加评论,请登录

Bipin Patwardhan的更多文章

  • Parallel execution in Spark

    Parallel execution in Spark

    On reading the title, I am sure the first reaction will be 'What am I talking about'. As we all know, Spark is a…

    1 条评论
  • Writing code to generate code - Python + SQL version

    Writing code to generate code - Python + SQL version

    In my current project, we had to build multiple metric tables. The base table had 50 columns and we had to add around…

  • Change management is crucial (Databricks version)

    Change management is crucial (Databricks version)

    My last project was a data platform implemented using Databricks. As is standard in a data project, we were ingesting…

  • Friday fun - Impersonation (in a good way)

    Friday fun - Impersonation (in a good way)

    All of us know that impersonation - the assumption of another person's identity, be it for good or bad - is not a good…

  • Any design is a trade-off

    Any design is a trade-off

    Irrespective of any area in the world (software or otherwise), every design is a trade off. A design cannot be the 'one…

    1 条评论
  • Quick Tip: The headache caused by import statements in Python

    Quick Tip: The headache caused by import statements in Python

    When developing applications, there has to be a method to the madness. Just because a programming environment allows…

  • Databricks: Enabling safety in utility jobs

    Databricks: Enabling safety in utility jobs

    I am working on a project where we are using Databricks on the WAS platform. It is a standard data engineering project…

  • A Simple Code Generator Using a Cool Python Feature

    A Simple Code Generator Using a Cool Python Feature

    For a project that I executed about three years ago, I wrote a couple of code generators - three variants of a…

  • Recap of my articles from 2024

    Recap of my articles from 2024

    As we are nearing the end of 2024, I take this opportunity to post a recap of the year - in terms of the articles I…

  • Handling dates

    Handling dates

    Handling dates is tough in real life. Date handling is probably tougher in the data engineering world.

社区洞察