# Powershell 定义文本
# 使用引号可以定义字符串,如果想让自己定义的字符串原样输出,可以使用单引号。
# $text='$fei $(tai) $env:windir 飞苔博客 (20+2012)'
# $text
# 定义的字符中的变量被内容替换,表达式被执行可以使用双引号
# $site="飞苔博客 Powershell博客"
# $text="$site $(get-date) $env:windir"
# $text
# 文本中的特殊字符
# 将变量放在字符串中,输出时变量会被替换成变量本身的值或者内容。如果将表达式放置在字符串中,并且使用的格式如“$(expression)”,表达式也会被执行,并被替换成表达式执行的输出。
# "系统目录位于:$env:windir"
# "默认安装程序目录位于:$env:ProgramFiles"
# "机器名为:$env:computername"
#
# "当前日期:$(get-date)"
# "1GB=$(1gb/1kb)KB"
#
# 系统目录位于:C:\Windows
# 默认安装程序目录位于:C:\Program Files
# 机器名为:G08XMAXY
# 当前日期:11/11/2019 11:47:57
# 1GB=1048576KB
# Powershell转义字符
# Powershell中扮演转义字符角色是反引号“`”字符串中的反引号
#使用单引号闭合字符串输出双引号
# 'The site of my blog is"www.mossfly.com"'
#使用转义字符输出双引号
# "My blog site is`"www.mossfly.com`""
#在字符串中输出换行符
# "The site of my blog is `"www.mossfly.com`",`n飞苔博客"
#
# The site of my blog is"www.mossfly.com"
# My blog site is"www.mossfly.com"
# The site of my blog is "www.mossfly.com",
# 飞苔博客
# Powershell转义字符表
# 转义字符 描述
# `n 换行符
# `r 回车符
# `t 制表符
# `a 响铃符
# `b 退格符
# `’ 单引号
# `” 双引号
# `0 Null
# “ 反引号本身
# Here strings 定义多行文本
# @“字符串”@格式定义多行文本
# @"
# 这首诗用来评价陶渊明的诗歌再好不过了
#
# 一语天然万古新,豪华落尽见真淳。
# 南窗白日羲皇上,未害渊明是晋人。
# "@
# 用户交互
# $name = Read-Ho
Powershell使用特殊文本命令
最新推荐文章于 2024-11-13 23:07:05 发布