|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Arg list too long
Hello All,
I am trying to find a file name with .sh exention from a list of .dat files inside a directory. find /app/folder1/* -name '*.dat'| xargs grep '.sh' ksh: /usr/local/bin/find: arg list too long Please help me finding the command. Thanks |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Try running: Code:
find /app/folder1/* -name '*.dat' -type f -exec grep '.sh' {} \; |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thanks - but that does not work either.
Maybe the ncargs value is too low on my system. ncargs 6 ARG/ENV list size in 4K byte blocks True |
|
#4
|
|||
|
|||
|
I assume that bipinajith's proposed solution will still fail because /app/folder1/* is expanding to a list of arguments too long to process. The following should avoid that problem and be MUCH more efficient: Code:
find /app/folder1 -name '*.dat' -type f -exec grep '.sh' {} +Note, however, that if your .dat files are binary files (rather than text files) grep might not work. (The standards only specify the behavior of grep when its input files are text files.) Also note that if grep is called with only one file operand, the name of the file in which the line is found will not be printed; just the contents of the matching line. If your .dat files are text files and you want the name of the file to be printed as well as the matched lines even if there is only one file operand, add /dev/null as another file operand. If you only want the names of matching files, but don't need to see the matched lines use the -l (letter ell; not digit 1) option. And note that the pattern specified by '.sh' is a basic regular expression will match the two characters sh as long as they are not the 1st two characters on a line. If you want to match the three characters .sh , you need to add the -F option, use the obsolescent fgrep utility instead of grep, or escape the period in the BRE. |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| arg list too long | Zenwork | Shell Programming and Scripting | 2 | 10-08-2008 03:06 PM |
| ls -t arg list too long | CSU_Ram | UNIX for Dummies Questions & Answers | 4 | 05-05-2005 10:19 AM |
| arg list too long | encrypted | UNIX for Advanced & Expert Users | 8 | 11-12-2004 05:38 AM |
| egrep and Arg list too long | kingo | UNIX for Dummies Questions & Answers | 6 | 05-22-2002 11:52 AM |
| arg list too long | vingupta | UNIX for Dummies Questions & Answers | 5 | 08-02-2001 11:43 PM |
|
|