Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12652 ディスカッション

Too many filename matches

Altera_Forum
名誉コントリビューター II
1,955件の閲覧回数

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 件の賞賛
8 返答(返信)
Altera_Forum
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

you could try a bash script: 

 

#!/bin/bash for file in $PWD/* do if ] then rm $file fi done
Altera_Forum
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

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
名誉コントリビューター II
676件の閲覧回数

Yes!! 

 

find . -name '*.dat' -delete 

 

Works just fine. 

 

Thanks for the help
返信