Redirection using Unix 'ls' list command
Show older comments
Hi,
I quite often use the following command in PC Matlab (as opposed to running Matlab in Unix environment):
!ls *mat > temp.txt;
or
system('ls *mat > temp.txt');
which lists all .mat files, creates a text file, and saves the data file names, one on each line, into the text file. This is very nice.
The thing is that the above command only works on my machine for some reason. I recently found out that none of my coworkers can execute the command although they have exact OS, Matlab version, etc.
I had to modify my scripts using 'dir' or 'diary' instead of 'ls >' for them.
Does anybody have any idea?
Thanks in advance,
Eric
1 Comment
Andrew Newell
on 8 Feb 2011
It works for me on a Mac with OS 10.6 (Snow Leopard). What goes wrong when you do it?
Accepted Answer
More Answers (1)
Kaustubha Govind
on 8 Feb 2011
0 votes
The bang(!) operator and system command essentially redirect the command to the system shell - is it likely that you have a Windows utility installed that defines 'ls'? You can test this by typing 'ls' at your Windows command prompt.
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!