Difference between Unix and PowerShell Commands

In this Blog, I will demonstrate the difference between Unix and PowerShell Commands. It will help all coders who works on Scripting Languages.
Consider the one file in windows and one file in Linux with same data.
See the below Image for the same.

Find the Total Number of Records in a file .

Linux uses “cat” and “wc -l” command
cat LinuxScripting.txt | wc -l


Windows “Get-Content” and “Measure-Object” command.
$File_count=Get-Content PowerShell_Scripting.txt |Measure-Object

Read first n lines of a file

Linux uses “cat” and “head” command.
cat LinuxScripting.txt | head -3


Windows uses “Get-Content” and “Head” command.
`$File_subset=Get-Content PowerShell_Scripting.txt -Head 3

Read last n lines of a file

Linux uses “cat” and “tail” commands.
cat LinuxScripting.txt | tail -3

Windows uses “Get-Content” and “Tail”
$File_subset=Get-Content PowerShell_Scripting.txt -Tail 3

Read full file

Linux uses “cat” command.
cat LinuxScripting.txt

Windows use “Get-Content”.
$file_data=Get-Content PowerShell_Scripting.txt

Search a word in a file

Linux uses “cat” and “grep” commands.
cat LinuxScripting.txt | grep COL1

Windows uses “Get-Content” and “Where-Object {$_ -like ‘COL1‘}”
$file_search=Get-Content PowerShell_Scripting.txt | Where-Object {$_ -like 'COL1'}

Related posts