2>/dev/null

Friends have the following problem

a search may not find anything which would correct example:

ls -ltr *prueba.txt | nawk '{ print $9 }' > Procesar.dat 2>/dev/null

When he finds nothing gives me the following error

ls: prueba.txt: No such file or directory

because 2> / dev / null does not work I missing something?

ls needs its stderr redirected as well.

1 Like

I do not understand ,

To fix this code you could use:

ls -ltr *prueba.txt 2>/dev/null | awk '{ print $9 }' > Procesar.dat

But this is highly inefficient and will not give you complete filenames if any of your filenames contain whitespace characters. The suggestions in your other thread today: Browse directory would be much better ways to do this.

Also, note that *prueba.txt will not match any of the files listed in the other thread. (There is a HUGE difference between *prueba.txt and prueba*.txt !)

1 Like

So it is thanks Use the solution of another thread I stay perfect thank you very much once again