DEV Community

Thanabodee Charoenpiriyakij
Thanabodee Charoenpiriyakij

Posted on

3 1

From UNIX command to PowerShell command

ลอง map command จาก os ตระกูล UNIX ที่ใช้ในชีวิตประจำวันมาเป็น PowerShell ของ Windows

mkdir

สร้างโฟลเดอร์

UNIX:

$ mkdir powershell_tut
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> New-Item -ItemType "directory" powershell_tut
Enter fullscreen mode Exit fullscreen mode

cd

เปลี่ยนโฟลเดอร์

UNIX:

$ cd powershell_tut
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Set-Location powershell_tut
Enter fullscreen mode Exit fullscreen mode

touch

สร้างไฟล์

UNIX:

$ touch a.txt
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> New-Item a.txt
Enter fullscreen mode Exit fullscreen mode

cp

Copy ไฟล์จากต้นทางไปปลายทาง

UNIX:

$ cp a.txt b.txt
$ cp -r dir_a dir_b
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Copy-Item a.txt b.txt
PS> Copy-Item -Recurse dir_a dir_b
Enter fullscreen mode Exit fullscreen mode

rm

ลบไฟล์หรือโฟลเดอร์

UNIX:

$ rm a.txt
$ rm -r dir_a
$ rm -rf dir_b
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Remove-Item a.txt
PS> Remove-Item -Recurse dir_a
PS> Remove-Item -Recurse -Force dir_b
Enter fullscreen mode Exit fullscreen mode

mv

ย้ายไฟล์หรือโฟลเดอร์

UNIX:

$ mv dir_b dir_c
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Move-Item dir_b dir_c
Enter fullscreen mode Exit fullscreen mode

ls

List ไฟล์หรือโฟลเดอร์นั้น ๆ

UNIX:

$ ls
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Get-ChildItem
Enter fullscreen mode Exit fullscreen mode

man

ดู manual ของโปรแกรมนั่น ๆ

UNIX:

$ man cp
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Get-Help Copy-Item
Enter fullscreen mode Exit fullscreen mode

curl

Request data จาก url ที่ระบุ

UNIX:

$ curl http://example.com
Enter fullscreen mode Exit fullscreen mode

PowerShell:

PS> Invoke-RestMethod -Uri http://example.com
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more