Thread Subject: To create a text file

Subject: To create a text file

From: juckou

Date: 16 Oct, 2008 20:08:02

Message: 1 of 7

Hello,

I need to create a file with a list of all the names of the files I'm using (satellite maps in this case). I've been told to write (my maps are in png format):

ls *.png > whateverlist.txt

in the "shell, not in matlab". I don't really understand what means in the "shell, not in matlab". I've been trying to run it in the command window but, of course, it isn't working. The names of my files appear as in a list but this is never written in any .txt file.

Any idea of what I should do? Where should I write "ls *.png > whateverlist.txt"?

Thank you very much for any help

Regards
juckou

Subject: To create a text file

From: Ashish Uthama

Date: 16 Oct, 2008 20:16:14

Message: 2 of 7

shell is the *NIX equivalent of the windows command prompt (to put it
across in simple terms)

  ls *.png > whateverlist.txt

ls is a *NIX (UNIX/LINUX) command to LiSt files in a directory
ls *.png lists all files in the current directory ending in .png

This command might work on a windows machine if you have some relevent
pacakges installed which mimic *NIX commands. (I forget the names).

> whateverlist.txt redirects the output of the ls command to a file.

You can run shell commands from within MATLAB using either UNIX/SYSTEM or
a '!' (look up the doc for details)



On Thu, 16 Oct 2008 16:08:02 -0400, juckou <ja79@hw.ac.uk> wrote:

> Hello,
>
> I need to create a file with a list of all the names of the files I'm
> using (satellite maps in this case). I've been told to write (my maps
> are in png format):
>
> ls *.png > whateverlist.txt
>
> in the "shell, not in matlab". I don't really understand what means in
> the "shell, not in matlab". I've been trying to run it in the command
> window but, of course, it isn't working. The names of my files appear as
> in a list but this is never written in any .txt file.
>
> Any idea of what I should do? Where should I write "ls *.png >
> whateverlist.txt"?
>
> Thank you very much for any help
>
> Regards
> juckou

Subject: To create a text file

From: Guoliang Zhang

Date: 16 Oct, 2008 20:30:05

Message: 3 of 7

If your MatLab is running on a Linux like OS

>> system('ls *.png > whateverlist.txt')

invokes the "shell command" from within the MatLab.

if you are running windows, use dir instead of ls

>> system('dir *.png > whateverlist.txt')

.

if you don't want to use the shell, check out the MatLab functions

>> help fopen
>> help fclose

hth

GZ


"juckou" <ja79@hw.ac.uk> wrote in message
news:198261.1224187713473.JavaMail.jakarta@nitrogen.mathforum.org...
> Hello,
>
> I need to create a file with a list of all the names of the files I'm
> using (satellite maps in this case). I've been told to write (my maps are
> in png format):
>
> ls *.png > whateverlist.txt
>
> in the "shell, not in matlab". I don't really understand what means in the
> "shell, not in matlab". I've been trying to run it in the command window
> but, of course, it isn't working. The names of my files appear as in a
> list but this is never written in any .txt file.
>
> Any idea of what I should do? Where should I write "ls *.png >
> whateverlist.txt"?
>
> Thank you very much for any help
>
> Regards
> juckou

Subject: To create a text file

From: juckou

Date: 16 Oct, 2008 20:42:58

Message: 4 of 7

Thank you Ashish

So you mean that in order to use the command in windows I need new packages or matlab already have them? And what about using '!', how? Which doc have I to look up? Sorry for my ignorance.

Cheers
juckou

Subject: To create a text file

From: Ashish Uthama

Date: 16 Oct, 2008 21:00:31

Message: 5 of 7


Please find more details online at:
     http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_env/f0-12994.html#f0-38522
Or please paste this in the MATLAB command window:
     web([docroot,'/techdoc/matlab_env/f0-12994.html#f0-38522'])

"Guoliang Zhang" <zhangl@mathworks.com> 's post would answer your first
question.

On Thu, 16 Oct 2008 16:42:58 -0400, juckou <ja79@hw.ac.uk> wrote:

> Thank you Ashish
>
> So you mean that in order to use the command in windows I need new
> packages or matlab already have them? And what about using '!', how?
> Which doc have I to look up? Sorry for my ignorance.
>
> Cheers
> juckou

Subject: To create a text file

From: Walter Roberson

Date: 16 Oct, 2008 21:07:45

Message: 6 of 7

juckou wrote:

> So you mean that in order to use the command in windows I need new packages or matlab
> already have them?

If your original posting on this topic was accurate, you are not -permitted- to
invoke the commands from within Matlab nor to use any Matlab function
that would give you the same information. Your original posting also hints
strongly that you are -expected- to do the work on a Unix or Linux or Mac OS X machine,
not under MS Windows.

Subject: To create a text file

From: juckou

Date: 16 Oct, 2008 22:02:45

Message: 7 of 7

Now I'm using it correctly.

Thank you very much to all of you (Ashish, Leong, Walter and Wessel).

juckou

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com