- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I got a system that records to a Compact Flash disk. Everything works great except when I try to delete a bunch of files using rm *.dat. It gives me the message: "Too many filename matches". I also have the problem that when we have several files, "ls" hangs up. I tried to get the rm command off the Busybox, but I'm getting errors when I compile the OS. Please adviceLink Copied
8 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. I don't know busybox but I know linux.
The parse of "*.dat" seems to exceed the max number of arguments. "ls" hangs up but responds later (very later) I think. A begin of an idea (remove by groups): rm a*.datrm b*.dat
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mmTushi,
Thanks for the prompt response. We are removing the data files in smaller groups as you pointed out. But this is a royal pain, very slow tedious process. Is there any way one can change the max number of arguments? The default settings have rm in Busybox. I like to try rm outside of Busybox. What do I need to change in the uClinux settings to accomplish this? Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
you could try a bash script:
#!/bin/bash
for file in $PWD/*
do
if ]
then
rm $file
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The usual way to avoid the argument limit is using 'xargs', typically:
find . -name '*.dat' | xargs rm
although in your case: echo *.dat | xargs rm
may well work, but I'm not sure busybox has xargs. You could so something like (untested): rm_all()
{
while
do
rm "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
shift 9
done
rm "$@"
}
rm_all *.dat
Since it is likely that the shell function argument limit is larger than that for exec.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm trying to enable bash, but I get the following error:
In function 'make_child': /pathname/nios2-linux/uClinux-dist/user/bash/jobs.c:1147: undefined reference to 'fork' How do I fix this? Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added xargs to busybox, and I tried the command
echo *.dat | xargs rm same result: Too many filename matches Where in busybox is the maximum number of arguments defines, does anybody know? Thanks- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That constraint will be in the shell, it might be an argument count limit, or a byte length limit. Try searching the source tree for the error message!
The kernel will have its own limit - but that need not apply to shell builtins. The 'Too many filename matches' error might even be coming from the part of the shell that expands the wildcard - rather than part of the attempt to run a program. If the error is returned by "set -- *.dat" then you probably wont get the shell to expand the list anywhere. That means you'll need to use something else to generate the list of names, 'find' or 'ls .' will work - with the latter you'll need to filter the unwanted names yourself. You also won't want to run 'rm' for every file - unless you add it as a shell builtin - because of the fork+exec costs. You might actually be able to use: find . -name '*.dat' -delete- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes!!
find . -name '*.dat' -delete Works just fine. Thanks for the help
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page