-1

How to solve issue Argument list too long in grep command?

I need to execute grep command

grep '^ORA'  '/log/bssuser/CDR/Postpaid_CDR_Log/'*.log > output.txt

I have error : -bash: /usr/bin/xargs: Argument list too long

Grobu
  • 599
  • 1
  • 11
  • 3
    The command-line you provided in your post only mentions `grep`, not `xargs`. – Grobu Aug 25 '23 at 05:31
  • 2
    As you can see from the text of the error message (.... **xargs**: ...), it does not come from the command you have posted. Please post the command which causes the trouble. – user1934428 Aug 25 '23 at 09:13
  • Does this answer your question? [Argument list too long error for rm, cp, mv commands](https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands) – pjh Aug 25 '23 at 21:58

1 Answers1

1

For handling a wild number of files you need to use find:

find /log/bssuser/CDR/Postpaid_CDR_Log/ -type f -name '*.log' \
     -exec grep '^ORA' {} + >  output.txt
Fravadona
  • 13,917
  • 1
  • 23
  • 35