Display Array of Strings with White Spaces
Hello, this is a C shell question.
I generated an array of strings, but each string has white spaces between tokens. My script is set cmd1 = 'apple orange' set cmd2 = 'tea coffee' set cmd_list = ($cmd1 $cmd2) The problem is when I tried to display each element from that array foreach cmd ($cmd_list) echo "cmd_list is $cmd" end What I want to see is cmd_list is apple orange cmd_list is tea coffee but instead I saw cmd_list is apple cmd_list is orange cmd_list is tea cmd_list is coffee How should I write the foreach command to fix the problem? Thanks |
You can try the :q modifier to prevent word splitting. For example:
Code:
#!/bin/tcsh Ah... and welcome to LinuxQuestions! :) |
Thanks!
It works!
|
Please mark as SOLVED if you have your solution.
|
All times are GMT -5. The time now is 03:05 AM. |