Difference Between PowerShell and Shell Scripting – PART2

This blog is the continuation of my previous Blog, where I have explained the difference between PowerShell and Shell Scripting through 5 different scenarios. Here , in this Blog , I will take 5 more different commands and will show the difference between them.Consider one file in windows and one file in Linux with same Data.

Clear the content of a file
Windows use “Clear-Content”
Clear-Content .\PowerShell_Scripting.txt


Linux uses “>” symbol to truncate or removing content of a file.
>Linuxfile.txt

Copy a file from one Location to another
Windows uses “Copy-Item” command to remove a file.
Copy-Item .\PowerShell_Scripting.txt .\files\PowerShell_Scripting.txt
It will copy files from current location to files folder.

Linux uses “cp” command
cp linuxfile.txt copyfiles/linuxfile.txt

Remove a file
Windows use “Remove-Item” command to remove a file.
Remove-Item .\PowerShell_Scripting.txt

Linux uses “rm -f” command to remove a file.
rm -f linuxfile.txt

Move a file from one Location to Another
Windows uses “Move-Item” command to move a file.
Move-Item .\PowerShell_Scripting.txt .\files\PowerShell_Scripting.txt

Linux uses “mv” command to move a file.
mv linuxfile.txt copyfiles/

Kill a Process
Windows uses “Stop-Process” command to kill a process.
Stop-Process -processname note*
The Above command kill all processes running starting with word “note” like Notepad and Notepad++

Linux uses “Kill” command to kill a process running in Linux Machine
kill processid
Processid is fetched using below command.
ps -eaf | grep "<processname>"

Related posts