|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
split in bash
2008-07-02, 12:04(-04), Wayne:
[] >Then, what is the best way to split a string in bash? > echo ${s%%,*} # everything up to the last comma in s No, that's everything up to the *first* comma in s if s contains a comma or s in full if not (and subject to word splitting, globbing and echo transformations as you forgot to quote it and used echo). ${s%,*} for everything up to the last comma (or s in full if s doesn't contain a comma). echo ${s,} # everything after the last comma in s [] or s in full if s doesn't contain a comma. -- S |
![]() |
| Viewing: Web Development Archives > FAQs > Unix/Linux > split in bash |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|