// archives

Scripting

This category contains 12 posts

PowerShell: Deleting entire lines in a text file based on a partial string match

PS C:\workspace> (gc “fileToParse.txt”) -notmatch "<criteria>" | out-file "resultFile.txt" Note: <Criteria>, for example, “not".

PowerShell: Rename file to lowercase

1. Open PowerShell 2. CD into directory to work on 3. Execute the following command: get-childitem * -recurse | rename-item -newname { $_.name.ToLower() }

PowerShell: Rename file’s file extension

1. Open PowerShell 2. CD into directory to work on 3. Execute the following command: get-childitem * -recurse | rename-item -newname { $_.name -replace ".txt",".bcp" }

Read a file with bash

I had to test our download servers at work right away, i.e., HTTP vs HTTPS, which required downloading a large number of files.  A file list was given to me to work with, like so: /download/integrations/file1.exe/download/us/update/patch/file1.exe/download/us/cab/file1.exe So I decided to use the bash shell to read each line and run wget quick and dirty.  Here’s the [...]

VI global search and replace

In case you need to search and replace text globally within vi, here’s the command to do so: :1,$s/old/new vi is a free software screen-oriented text editor computer program written by Bill Joy in 1976 for an early BSD release. Peace!  \m/