friends of mine I have the following problem:
in a direct I have a file list, for example:
-rw-rw-r-- 1 satvercl2 desa 6620 nov 26 15:35 prueba1.txt
-rw-rw-r-- 1 satvercl2 desa 6620 nov 26 15:35 prueba2.txt
-rw-rw-r-- 1 satvercl2 desa 6620 nov 26 15:35 prueba3.txt
-rw-rw-r-- 1 satvercl2 desa 6620 nov 26 15:35 prueba4.txt
I need to save to a file only the file name example:
prueba1.txt
prueba2.txt
prueba3.txt
prueba4.txt
I am using ls guadar -latr but I can not name only ejemplo :
ls -latr prueba*.txt > tmp.tmp
Please look at the ls
man page on your system (using man ls
) to determine if you need any of those options. You definitely do not want the l
option (which produces long format listings).
The simplest solution to what you said you are trying to do would just be:
ls prueba*.txt > tmp.txt
With most shells on most systems, the following would be faster since printf
is usually a shell built-in and ls
usually is not a shell built-in:
printf '%s\n' prueba*.txt > tmp.txt
Note that in both of these examples I changed the name of your output file from tmp.tmp
to tmp.txt
, but you can use whatever name you want.
2 Likes
Perfect, thank you very much .
This page is the bible !!!