Sunday 12 April 2020

Basic Commands for Shell

Map Book for Experienced Bash users

The table below lists the usage of some basic commands to help you get started on PowerShell faster. Note that all bash commands should continue working on PowerShell session.
BashPowerShellDescription
lsdir, Get-ChildItemList files and folders
treedir -Recurse, Get-ChildItem -RecurseList all files and folders
cdcd, Set-LocationChange directory
pwdpwd, $pwd, Get-LocationShow working directory
clear, Ctrl+L, resetcls, clearClear screen
mkdirNew-Item -ItemType DirectoryCreate a new folder
touch test.txtNew-Item -Path test.txtCreate a new empty file
cat test1.txt test2.txtGet-Content test1.txt, test2.txtDisplay files contents
cp ./source.txt ./dest/dest.txtCopy-Item source.txt dest/dest.txtCopy a file
cp -r ./source ./destCopy-Item ./source ./dest -RecurseRecursively copy from one folder to another
mv ./source.txt ./dest/dest.txtMove-Item ./source.txt ./dest/dest.txtMove a file to other folder
rm test.txtRemove-Item test.txtDelete a file
rm -r <folderName>Remove-Item <folderName> -RecurseDelete a folder
find -name build*Get-ChildItem build* -RecurseFind a file or folder starting with 'build'
grep -Rin "sometext" --include="*.cs"Get-ChildItem -Recurse -Filter *.cs
| Select-String -Pattern "sometext"
Recursively case-insensitive search for text in files
curl https://github.comInvoke-RestMethod https://github.comTransfer data to or from the web

No comments:

Post a Comment