Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Too many filename matches

Altera_Forum
Honored Contributor II
1,406 Views

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 advice
0 Kudos
8 Replies
Altera_Forum
Honored Contributor II
127 Views

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*.dat 

rm b*.dat 

...
Altera_Forum
Honored Contributor II
127 Views

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
Altera_Forum
Honored Contributor II
127 Views

you could try a bash script: 

 

#!/bin/bash for file in $PWD/* do if ] then rm $file fi done
Altera_Forum
Honored Contributor II
127 Views

The usual way to avoid the argument limit is using 'xargs', typically: 

find . -name '*.dat' | xargs rmalthough in your case: 

echo *.dat | xargs rmmay 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.
Altera_Forum
Honored Contributor II
127 Views

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
Altera_Forum
Honored Contributor II
127 Views

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
Altera_Forum
Honored Contributor II
127 Views

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
Altera_Forum
Honored Contributor II
127 Views

Yes!! 

 

find . -name '*.dat' -delete 

 

Works just fine. 

 

Thanks for the help
Reply