hello, i'm new to linux shell, i would like to split a string like this one: TEST="apath/ anotherpath/*.txt" for d in $TEST do echo "$d" done here i wanted to output: >apath >anotherpath/*.txt btw i just can not avoid shell to expand '*.txt' to 'file1.txt', 'file2.txt'; etc. i think i am missing something around 'TEST' in 'for d in $TEST' but i have no clues... best,
![]() |
0 |
![]() |
On Sat, 08 May 2004 09:39:49 -0700, Valia wrote: > hello, > > i'm new to linux shell, i would like to split a string like this one: > > TEST="apath/ anotherpath/*.txt" > for d in $TEST > do > echo "$d" > done > > here i wanted to output: > >>apath >>anotherpath/*.txt > > btw i just can not avoid shell to expand '*.txt' to 'file1.txt', > 'file2.txt'; etc. > > i think i am missing something around 'TEST' in 'for d in $TEST' but i > have no clues... > Put double quotes around it.
![]() |
0 |
![]() |
On 2004-05-08, Valia wrote: > hello, > > i'm new to linux shell, i would like to split a string like this one: > > TEST="apath/ anotherpath/*.txt" > for d in $TEST > do > echo "$d" > done > > here i wanted to output: > >>apath >>anotherpath/*.txt > > btw i just can not avoid shell to expand '*.txt' to 'file1.txt', > 'file2.txt'; etc. > > i think i am missing something around 'TEST' in 'for d in $TEST' but i > have no clues... Use "set -f" to disable filename expansion, then turn it back on afterwards with "set +f": set -f TEST="apath/ anotherpath/*.txt" for d in $TEST do echo "$d" done set +f -- Chris F.A. Johnson http://cfaj.freeshell.org/shell =================================================================== My code (if any) in this post is copyright 2004, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License
![]() |
0 |
![]() |