Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
I am getting a error , while i run the command inside a directory.
ls -lt /A/B/C/D/filetolist*
-bash: /bin/ls: Argument list too long...
I want to know the reason for this and an alternate solution to it. Since this output, will be used for a script, I want the desired output of "ls -lt"
It means that when the shell expands the wildcard '*' you end up with too many files that match ie too many args for ls to handle.
What you can do is just a straight ls of the dir (which will just read the info from the dir file) and grep out the ones you want
Code:
for file in `ls A/B/C/D |grep ^filetolist`
do
ls -lt $file
done
Do you really need the info from the -lt switches?
Do you really need the info from the -lt switches?
Really needed. The script am using is listing the latest files from a number of directories. I failed to got the output(mailed to me, by the sctipt) for 2 directories , for the past couple of days .Then i found, the standard error in the mail from cron.
line 27: /bin/ls: Argument list too long (for the 2lines , denoting the 2 failed directories.)
I need to change the entire script , if i go on the way you shown....
The script am using is listing the latest files from a number of directories.
You can try to use find. For example if you want to find the files whose modification time is less than 5 days, you can do
Code:
find /A/B/C/D/ -mtime -5 -exec ls -l {} \;
using -exec you can execute the command ls -l over each of the files found. Or you can try the stat command to extract some more specific information (see man stat for details).
I can go with the "find " . The command you gave
find /A/B/C/D/ -mtime -5 -exec ls -l {} \;
is listing all files in that directory. But all the details I needed are there. Can you give me a "find" option to list the files created , within the last 5 days(along with ls -l , as above).
ZAMO, just a little advice: use the code tags for posting command lines: they are more readable and preserve multiple spaces, tabs and indentation. To embed a text inside code tags, go in advanced mode, select the text you want to embed and press the "#" button. Or put the code tags by typing them directly. Like this
[CO DE]do i = 1,n
write(*,*) array(n)
done[/CO DE]
strip out the blank space between O and D (I put it to show you what code tags are) and the trick is done
To embed a text inside code tags, go in advanced mode, select the text you want to embed and press the "#" button. Or put the code tags by typing them directly. Like this
[CO DE]do i = 1,n
write(*,*) array(n)
done[/CO DE]
strip out the blank space between O and D (I put it to show you what code tags are) and the trick is done
Code:
do i = 1,n
write(*,*) array(n)
done
@colucix: A slightly off-topic remark, but to illustrate how to format stuff in the forum, you can use [noparse][/noparse] tags, which will not interpret the information between those tags. This allows you to write [code][/code] and it will not insert a code block.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.