Command Window

1/1/1970

Command Window

Command Prompt

what is sh, the most time command-line??

Command Prompt vs Powershell

What is Unix- like shell? common Unix-like shells that are available on Windows 1. Bash (Bourne Again Shell) such as Git Bash:**

Directory Separator


Commands

touch (Unix-like Shells) : It update the access and modification timestamps of a file. (Creates if doesn't exist)

nul (Window Cmd) : It is a special device in Windows, essentially a "black hole" for output. Anything redirected to nul is discarded.

type (Windows Cmd) : It is used to display the contents of a file.

echo (Unix-like Shells and Windows Cmd) : It is used to display provided arguments (text or variables).

> (Redirection Operator)


Clean Terminal

clear

Remove a file (In Window)

# Remove a file
del path\to\your\file
 
# Remove a Folder
rmdir /s /q path\to\your\folder

/s: option removes the folder and its contents /q: suppresses confirmation prompts

Understand type & nul

# Output nothing into a file (Used to Create a empty file or overwrite if exist)
nul > app.js
#or
> app.js
 
# display content from a file
type app.js
 
# display and store nothing into a file
type nul > app.js
 
# display and output content into a file 
type Hello world > app.js # Not Valid ❌

Display an output type/echo

type app.js
 
echo app.js # output string i.e. app.js

Create a empty file or clear a file. >

# Creates a empty file or overwrites
nul > index.html
# or shorthand
> index.html
 
# unix-based system.
touch index.html

Create or overwrite empty file and display file > & type/echo

type nul > app.js
# or
echo > app.js

Create or overwrite text in a file

# create or clear a file
echo > app.js
 
# create or overwrite a file with a 'single blank line'
echo. > app.js
 
# create or overwrite a file with 'Hello World' text
echo Hello world > html.txt

Cntrl+ C

is used to terminate a running Process in Unix-like Operating System + cmd & shell

Comment

REM

REM This is a comment

::

:: This is a comment

echo ?

The echo command in Unix-like operating systems, including Linux and macOS, as well as in the Windows Command Prompt and PowerShell, is used to display a line of text or a string.

Syntax

echo [option(s)] [string(s)]

Display a simple message

echo "Hello, World!"

note:- like powershell "" is not used in cmd

Write output to a file (create file if not exist)

echo Hello, world! > myfile.txt

Display the value of a variable

name="Gaurav"
echo "Hello, $name!"
echo -e "Line 1\nLine 2\nLine 3"

Common Options

Using incorrect directory separators

(e.g. require('.\myFile.js'), when it should be .//myFile.js. Remember,