extract any of the filename that ends in .IMA

September 28, 2010 at 06:14:00
Specs: Macintosh
I got some files in the same folder


and I would like to extract any one of the filename that ends in .IMA and do further processing
(ex. FERNANDEZ_0500.,
is it possible to use awk for this?

Thank you in advance

See More: extract any of the filename that ends in .IMA

Report •

September 28, 2010 at 07:26:57
I am not a MAC guy, but you should be able to use the unix wildcard character * to match all the files with an IMA extension:

# one way listing the filenames
ls -1 *.IMA

# another way processing each file
awk ' { print $0 } ' *.IMA

Report •

September 28, 2010 at 10:59:46
Thank you for the reply, but I just want one file name instead of all (ex. only the first one which ends in .IMA),is it possible to extract it?
the awk ' { print $0 } ' *.IMA doesnt seem to work in MAC :(

Report •

September 28, 2010 at 12:04:10
Sorry, I missed that. How about:

ls -1 *.IMA|tail -1

or maybe:

ls -1r *.IMA|tail -1

Report •

Related Solutions

September 29, 2010 at 10:27:42
thanks a lot , it works,
but somehow when i save it as a variable and used it in the further commend, it doesnt work (mri_convert is a command line program for image processing), is there a way to solve this? thanks a tons

#/bin/csh -f

temp=$(ls -1 *.IMA | tail -1)
mri_convert -it siemens $temp -ot nii test.nii

echo "done"

Report •

September 29, 2010 at 10:39:45

sorry for the posting, i got it work now, simply this line will do the trick

mri_convert -it siemens {`ls -tr *.IMA | tail -1`} -ot nii test.nii

Report •

Ask Question