Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi Linux Guru's
can you guide me on which command to use? I'm trying to check on the files that are dated 2015-07-16 to latest but I'm having a different results
I've tried these but gives me a wrong echo
Code:
[pog@gwapo file]$ ls grep file.log.2015-07-{16..21}
ls: grep: No such file or directory
ls: file.log.2015-07-16: No such file or directory
ls: file.log.2015-07-17: No such file or directory
ls: file.log.2015-07-18: No such file or directory
ls: file.log.2015-07-19: No such file or directory
ls: file.log.2015-07-20: No such file or directory
ls: file.log.2015-07-21: No such file or directory
[pogi@gwapo file]$ ls -ltrh file.log.2015-07-{16..21}*
ls: file.log.2015-07-17*: No such file or directory
You're using brace expansion in your command. Brace expansion is performed before pathname expansion, and doesn't require the filename to exist, so the first thing that happens is that your command gets expanded to
Code:
ls -ltrh file.log.2015-07-16* file.log.2015-07-17* file.log.2015-07-18* file.log.2015-07-19* file.log.2015-07-20* file.log.2015-07-21*
Then, the pathname expansion occurs and each of the expressions will be replaced by lists of matching filenames. Because there is no file matching the glob
Code:
file.log.2015-07-17*
this one will remain unchanged. And because the file with such a name does not exist, ls will of course complain about that.
Apart from giving you an ugly error message, it is harmless and you can just send the message to /dev/null.
Also, you can change the default shell behaviour regarding unmatched globs with
I've tried removing the grep but I throws me a "ls: grep: No such file or directory" may I know what parameter does eliminate that?
You remove grep from your command by not typing it.
Or more precisely: When you type "ls grep", the "ls" command will look up a file named grep. Since it doesn't find this file, it complains. So, leave the "grep" out of your command and you are half-way there.
In addition, your original command looked for files that end in 16, 17, ..., 21. However the filenames in your directory don't end with this number. So, add an asterisk, which stands for "any string".
Last edited by berndbausch; 07-21-2015 at 05:28 AM.
You remove grep from your command by not typing it.
Or more precisely: When you type "ls grep", the "ls" command will look up a file named grep. Since it doesn't find this file, it complains. So, leave the "grep" out of your command and you are half-way there.
In addition, your original command looked for files that end in 16, 17, ..., 21. However the filenames in your directory don't end with this number. So, add an asterisk, which stands for "any string".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.