Results 1 to 2 of 2
Hi, I am doing a script in tcsh (yes I know, I know..) and I have suddenly bumped into a problem I'm pretty sure I hadn't experienced up to now.. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 05-13-2011 #1
- Join Date
- May 2011
extra characters when using `ls *.*` in loops
Hi, I am doing a script in tcsh (yes I know, I know..) and I have suddenly bumped into a problem I'm pretty sure I hadn't experienced up to now..
For various reasons I find the following type of loop very useful for my purposes:
foreach m (`ls folder/*.*`) echo $m something based on $m something else based on $m end
To give you an example, I have a folder (ROIs) with the following files in it
ROIs/csf_segm2func.nii.gz ROIs/csf_segm.nii.gz ROIs/gm_segm2func.nii.gz ROIs/gm_segm.nii.gz ROIs/wm_segm2func.nii.gz ROIs/wm_segm.nii.gz
ESC[0mESC[01;31mROIs/csf_segm2func.nii.gzESC[0m ESC[01;31mROIs/csf_segm.nii.gzESC[0m ESC[01;31mROIs/gm_segm2func.nii.gzESC[0m ESC[01;31mROIs/gm_segm.nii.gzESC[0m ESC[01;31mROIs/wm_segm2func.nii.gzESC[0m ESC[01;31mROIs/wm_segm.nii.gzESC[0m ESC[m test.txt (END)
- 05-13-2011 #2
- Join Date
- Apr 2011
I suspect you have an alias for ls to turn on color display. You may want to unalias it before using.
Also, why not just do
foreach m (folder/*) ...
not sure why your using ls.