如何在CSH中拆分字符串? [英] How do I split a String in CSH?

查看:754
本文介绍了如何在CSH中拆分字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我想用逗号作为分隔符分割 1、2、3,并使用循环分别处理结果的三个子字符串。

For example, I want to split "one,two,three" with comma as delimiter and use a loop to process the resulted three substring separately.

推荐答案

例如:

set s = "one,two,three"
set words = `echo $s:q | sed 's/,/ /g'`
foreach word ($words:q)
    echo $word:q
end

但是请考虑csh是否适合您从事的工作:

But consider whether csh is the right tool for whatever job you're doing:

http://www.bmsc.washington.edu/people/merritt/text/cshbad.txt

这篇关于如何在CSH中拆分字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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