Minggu, 03 Maret 2024

Comment In Batch, Registry, PowerShell, Bash File

Comment In Microsoft Windows Command Prompt and Batch File

  • To create a single line comment in batch file start with the REM

    REM This is a comment
  • Other way to create a single line comment in batch file start with double colon ::

    :: This is a comment
  • To create an inline comments in batch file start with the percentage and equal sign %= then end the comment with equal and percentage sign =%

    echo "Hello world!" %= This is an inline comment. =%
  • To create multiline batch comments, start each line with the double colon ::

    :: This is the first line
    :: This is the second line

NOTES:

  • Batch script file extension is .bat
  • Inside nested parts (IF/ELSE, FOR loops, etc...) :: should be followed with normal line, otherwise it gives error (use REM there).
  • if they are not in the beginning of line, then add ampersand & sign character, for example
    echo "Hello world!" & :: This is an inline comment.
  • To avoid printing a REM command to screen, start with @, for example @ REM This is a comment

Comment In Registry File

  • To create a single line comment in registry file start with the semicolon ;

    ; This is a comment

NOTES:

  • Registry file extension is .reg

Comment In PowerShell File

  • To create a single line comment in registry file start with the start with the hash sign (#):

    # This is a comment
  • To create multiline powershell comments, start each line with the hash sign (#):

    # This is the first line
    # This is the second line
  • Another way to create multiline block comments is valid in the modern PowerShell version, start with less than and hash mark <# together then end with hash mark and greater than #>

    <# 'COMMENT'
    This is the first line
    This is the second line #>

NOTES:

  • PowerShell script file extension ( .ps1 )
  • PowerShell script data files ( .psd1 ), 
  • PowerShell script module files ( .psm1 ).
  • and Script Pane are configuration files (.ps1xml), XML based files.

Comment In Linux/Unix Terminal and Bash File

  • To create a single line comments in bash scripts start with the hash sign (#):

    # This is a comment
  • To create an inline comments in bash scripts start with the hash/number sign (#):

    echo "Hello world!" # This is an inline comment.
  • To create multiline bash comments, start each line with the hash sign (#):

    # This is the first line
    # This is the second line
  • Another unconventional way to create multiline block comments is to use the bash null command (:) together with the heredoc notation:

    : << 'COMMENT'
    This is the first line
    This is the second line
    COMMENT

NOTES:

  • Linux / Unix command is case sensitive
  • Bash script file extension is .sh

Bibliography:

https://learn.microsoft.com/ https://phoenixnap.com/ https://ss64.com/ https://stackoverflow.com/ https://www.computerhope.com/, https://www.commandlinefu.com/

Tidak ada komentar:

Posting Komentar

Various Other Posts