从命令值保存到一个数组的bash [英] store the values from command into an array bash

查看:125
本文介绍了从命令值保存到一个数组的bash的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  SVN合并信息 - 显示,转速资格http://svn.test.com/INT_1.0.0/ http://svn.test.com/DEV/ |切-dR-f2 |切-d-f16097
6099

当我把这个剧本,我只得到最后的值,但还不是全部:

 #!的/ usr /斌/庆典 src_url =htt​​p://svn.test.com/INT_1.0.0/
 target_url =htt​​p://svn.test.com/DEV/ eligible_revs =(`svn的合并信息 - 显示,转速资格$ src_url $ target_url |切-dR-f2 |切-d,-f1`) 回声$ {eligible_revs [@]}输出:
6099


解决方案

如果您正在运行Cygwin的行尾可以搞砸了。

  $富=(`printf的'酒吧\\ r \\ nba​​z'`)$回声$ {foo的[*]}
 巴兹

svn mergeinfo --show-revs eligible http://svn.test.com/INT_1.0.0/ http://svn.test.com/DEV/  | cut -d"r" -f2 | cut -d" " -f1

6097
6099

when i put this in a script, i get only last value but not all:

#!/usr/bin/bash

 src_url="http://svn.test.com/INT_1.0.0/"
 target_url="http://svn.test.com/DEV/"

 eligible_revs=(`svn mergeinfo --show-revs eligible  $src_url $target_url | cut -d"r" -f2 | cut -d" " -f1`)

 echo ${eligible_revs[@]}

output:
6099

解决方案

If you are running Cygwin the line endings can mess it up

$ foo=(`printf 'bar\r\nbaz'`)

$ echo ${foo[*]}
 baz

这篇关于从命令值保存到一个数组的bash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆