当前位置:网站首页>A simple bash to powershell case
A simple bash to powershell case
2022-07-31 05:58:00 【tcliuwenwen】
博文背景
群友的bash脚本需要移植到Windows平台下,我帮群友写了一下
具体操作
脚本未经过充分测试,很可能有BUG存在
#!/bin/bash
FILE_NAME=$1
NEW_ORG_NAME=$2
STR=`sed -n '1p' ./${
FILE_NAME}`
TEMP_STR=($STR)
BLOCKCHAIN_NAME=${TEMP_STR[1]}
STR=`sed -n '3p' ./${
FILE_NAME}`
TEMP_STR=($STR)
CRYTPO_PATH=${TEMP_STR[1]}
ADDORG_PEER=`expr $# - 2`
#ADDORG_PEER=`expr ${ADDORG_PEER} / 2`
STR=[email protected]
ARG_ARR=($STR)
function addOrg(){
line=`sed -n '/organizations:/=' ${
FILE_NAME} | tail -n1`
echo " ${NEW_ORG_NAME}: #TAGORGS:_${NEW_ORG_NAME} mspid: ${NEW_ORG_NAME} #TAGORGS:_${NEW_ORG_NAME} cryptoPath: ${CRYTPO_PATH}/peerOrganizations/${NEW_ORG_NAME}/users/[email protected]${NEW_ORG_NAME}/msp #TAGORGS:_${NEW_ORG_NAME} peers: #${NEW_ORG_NAME} #TAGORGS:_${NEW_ORG_NAME}" > temp.txt
# for ((i=2;i<`expr ${ADDORG_PEER} + 2`;i++));do
# echo " - ${ARG_ARR[i]}" >> temp.txt
# done
sed -i "${line} r temp.txt" ${FILE_NAME}
}
addOrg
$FILE_NAME=$args[0]
$NEW_ORG_NAME=$args[1]
$STR=$(Get-Content $FILE_NAME | Select -Index 0)
$TEMP_STR=$STR.Split(" ")
$BLOCKCHAIN_NAME=$TEMP_STR[1]
$STR=$(Get-Content $FILE_NAME | Select -Index 2)
$TEMP_STR=$STR.Split(" ")
$CRYTPO_PATH=$TEMP_STR[1]
$ADDORG_PEER=$args.Count - 2
$STR=$args
$ARG_ARR=$STR
Function addOrg() {
$linenumber=$(Get-Content ${
FILE_NAME} | Select-String -Pattern "organizations:" | Select-Object LineNumber)
$line=$linenumber.Get($linenumber.Length-1).LineNumber
echo @" ${NEW_ORG_NAME}: #TAGORGS:_${NEW_ORG_NAME} mspid: ${NEW_ORG_NAME} #TAGORGS:_${NEW_ORG_NAME} cryptoPath: ${CRYTPO_PATH}/peerOrganizations/${NEW_ORG_NAME}/users/[email protected]${NEW_ORG_NAME}/msp #TAGORGS:_${NEW_ORG_NAME} peers: #${NEW_ORG_NAME} #TAGORGS:_${NEW_ORG_NAME} "@ | Set-Content temp.txt
# 此处缺一个sed命令暂时没有实现
}
addOrg
边栏推荐
猜你喜欢

feign调用不通问题,JSON parse error Illegal character ((CTRL-CHAR, code 31)) only regular white space (r

Powershell中UTF-8环境中文乱码解决办法
![[uiautomation] Get WeChat friend list (stored in txt)](/img/26/1f3424c5998c52c6e10ced8529012a.png)
[uiautomation] Get WeChat friend list (stored in txt)

flutter arr 依赖

(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
![[Cloud native] Simple introduction and use of microservice Nacos](/img/06/b0594208d5b0cbf3ae8edd80ec12c4.png)
[Cloud native] Simple introduction and use of microservice Nacos

对js的数组的理解

带你搞懂MySQL隔离级别,两个事务同时操作同一行数据会怎样?

NFTs: The Heart of Digital Ownership
![[swagger close] The production environment closes the swagger method](/img/43/17be22626ba152b33beaf03f92fbec.png)
[swagger close] The production environment closes the swagger method
随机推荐
为什么bash中的read要配合while才能读取/dev/stdin的内容
Attribute Changer的几种形态
SSH自动重连脚本
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
"limit" query in Oracle database
mysql常用命令
C language tutorial (3) - if and loop
quick-3.5 无法使用模拟器修改
Understanding SSRF, this article is enough
flutter arr 依赖
C语言 | 获取字符串里逗号间隔的内容
Android软件安全与逆向分析阅读笔记
Artifact SSMwar exploded Error deploying artifact.See server log for details
MySQL错误-this is incompatible with sql_mode=only_full_group_by完美解决方案
DeFi Token in the project management
计网 Packet Tracer仿真 | 简单易懂集线器和交换机对比(理论+仿真)
sqlmap injection tutorial common commands
【Elastic-Job】分布式调度任务概览篇
podspec自动化升级脚本
安装Multisim出现 No software will be installed or removed解决方法