bash 字串擷取 - Linux

By Joe
at 2009-06-18T12:46
at 2009-06-18T12:46
Table of Contents
請問各位大大,假如我有一個變數:
str='aaa bbb'
echo ${str:0:3}
echo ${str:4}
這樣可以分別把 aaa 和 bbb 抽取出來,
但是我現在要抽取的字串我無法事先知道他的長度,
有可能另一個字串是 'cccccccc ddddddd',
請問在 bash 裡面有什麼好方法嗎? 先感謝了! :>
--
str='aaa bbb'
echo ${str:0:3}
echo ${str:4}
這樣可以分別把 aaa 和 bbb 抽取出來,
但是我現在要抽取的字串我無法事先知道他的長度,
有可能另一個字串是 'cccccccc ddddddd',
請問在 bash 裡面有什麼好方法嗎? 先感謝了! :>
--
Tags:
Linux
All Comments

By Emily
at 2009-06-20T14:44
at 2009-06-20T14:44

By Ivy
at 2009-06-24T15:37
at 2009-06-24T15:37

By Leila
at 2009-06-29T08:44
at 2009-06-29T08:44

By Jacob
at 2009-06-30T04:47
at 2009-06-30T04:47
Related Posts
firefox會有殘影@@~

By Thomas
at 2009-06-18T10:27
at 2009-06-18T10:27
Compile C++ in UNIX

By Rebecca
at 2009-06-18T09:28
at 2009-06-18T09:28
Linux上有動態歌詞的MP3播放器

By James
at 2009-06-18T09:26
at 2009-06-18T09:26
如何monitor kernel drivers' memory u …

By Doris
at 2009-06-18T00:43
at 2009-06-18T00:43
有人用過wubi嗎?

By David
at 2009-06-18T00:22
at 2009-06-18T00:22