Sponsored Content
Top Forums Shell Programming and Scripting Find files and seach limit with grep Post 302657367 by nfn on Sunday 17th of June 2012 10:01:29 AM
Old 06-17-2012
Hi,

Thanks for you help, but I have errors when I execute the command:

Code:
root@local:~# find /var/cache/nginx/portal -maxdepth 1 -type d | xargs -P 16 -n 1 head -2 | grep -Rl "topic" | sort -u
head: error reading `/var/cache/nginx/portal': Is a directory
head: error reading `/var/cache/nginx/portal/1': Is a directory
head: error reading `/var/cache/nginx/portal/a': Is a directory
head: error reading `/var/cache/nginx/portal/4': Is a directory
head: head: error reading `/var/cache/nginx/portal/c': Is a directory

Without head I get:

Code:
root@local:~# find /var/cache/nginx/portal -maxdepth 1 -type d | xargs -P 16 -n 1 grep -Rl "topic" | sort -u
/var/cache/nginx/portal/8/d2/c7271e2a8985029a4194f1a43c256d28
/var/cache/nginx/portal/8/d6/76ecc4bbe957b6b3cdf4cacc4ffc1d68
/var/cache/nginx/portal/8/dc/fc67dd7e7a375d72f9fa41cfa4967dc8
/var/cache/nginx/portal/8/e7/ba67ada1fa86c5636f55303f5d5e6e78
/var/cache/nginx/portal/8/e7/e716048797249a17af20db3d320b9e78
/var/cache/nginx/portal/8/ea/0deae0c338ae8eb56f4e61877c7dfea8
/var/cache/nginx/portal/9/0b/de72ff84eac8eafe1d867ad6057d30b9
/var/cache/nginx/portal/9/11/6501b6f1dd8a62319d4edb86ebe02119
/var/cache/nginx/portal/9/12/fc1b1c0d72d1880e65de4f31a6f72129
/var/cache/nginx/portal/9/1d/74e03f08932a8643952a55843dc781d9
...... etc

The full command can be changed if it's easy to archive the same results.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

grep something to find which files, lines contain something

in aix, i use grep something * to get the files, lines that contain something. but i couldnt get the same result from a sun box. what is the equivalent? thanks (4 Replies)
Discussion started by: yls177
4 Replies

2. Shell Programming and Scripting

grep line length limit

Hi Friends, I am having a funny problem with grep. When I run grep 'expr' file.txt things work fine. But when try to get the line number using the -n option, i.e, grep -n 'expr' file.txt I get a message, "grep: 0652-226 Maximum line length of 2048 exceeded." If the line has more than... (3 Replies)
Discussion started by: hnhegde
3 Replies

3. AIX

Help Using Grep command to Find the string in the files in the root directory

I want to serch for a string in all the files in the root directory. i want the search to be limited to only the files in the directory i.e the search to be done only in the files not in the sub directory. the approaches tried are 1)grep "pattern string" this command was serching the... (3 Replies)
Discussion started by: Subbu_Angeline
3 Replies

4. Shell Programming and Scripting

Is it better to grep and pipe to awk, or to seach with awk itself

This may just be a lack of experience talking, but I always assumed that when possible it was better to use a commands built in abilities rather than to pipe to a bunch of commands. I wrote a (very simple) script a while back that was meant to pull out a certain error code, and report back what... (4 Replies)
Discussion started by: DeCoTwc
4 Replies

5. UNIX for Dummies Questions & Answers

Shell to seach all .mov files in a drive

I want a shell script which does: -> search all .mov files in a drive (say e: drive) which are above 800 mb of size -> Delete the searched .mov files which are above 800mb Thanks, Manoj (4 Replies)
Discussion started by: manoj.b
4 Replies

6. Shell Programming and Scripting

Any limit on files

I am doing an ftp of around 1010 files and I am using mput for this. For some reason its only transferring 10 or 20 files and the rest are not getting transferred. There is some socket error in the log. is there an issue if we have more than 50 or so files for mput. here is the o/p in the log... (2 Replies)
Discussion started by: dsravan
2 Replies

7. UNIX for Dummies Questions & Answers

Using grep to find files that don't contain a string

Hi all, I am still learning my way around unix commands and I have the following question. I have a website and I want to search for all the html pages that don't contain a certain js file. The file I am searching for is located under /topfolder/js/rules.js . So I assume in my grep search I... (5 Replies)
Discussion started by: SyphaX
5 Replies

8. Shell Programming and Scripting

grep by limit search

Hi I am in new in unix,can any one tell how to grep the data by limit. suppose I have below data:- is :mSecs is :mSecs is :mSecs is :mSecs requirement is how to grep the data which is having count greater than 1000 msecs only. thanks in adnavce. (2 Replies)
Discussion started by: abhigrkist
2 Replies

9. UNIX for Dummies Questions & Answers

Limit Number of files

hi guys how can i limit number of files in a disk or partition ? or how can i make a limit to inode number for a disk or partition ? ext3 or ext4 file system (1 Reply)
Discussion started by: mhs
1 Replies

10. UNIX for Dummies Questions & Answers

General find /grep question: files with lines ending in r

I am trying to find files that have lines in them that end in an r. I have been able to locate files by using the following command: find . -type f -name "*RECORDS"| xargs grep -l r$ However, I now want to find files that don't end in r anywhere. That means that no sentences or lines in... (9 Replies)
Discussion started by: newbie2010
9 Replies
ZGREP(1)						      General Commands Manual							  ZGREP(1)

NAME
zgrep - search possibly compressed files for a regular expression SYNOPSIS
zgrep [ grep_options ] [ -e ] pattern filename... DESCRIPTION
Zgrep is used to invoke the grep on compress'ed or gzip'ed files. All options specified are passed directly to grep. If no file is speci- fied, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to grep. If zgrep is invoked as zegrep or zfgrep then egrep or fgrep is used instead of grep. If the GREP environment variable is set, zgrep uses it as the grep program to be invoked. For example: for sh: GREP=fgrep zgrep string files for csh: (setenv GREP fgrep; zgrep string files) AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), egrep(1), fgrep(1), zdiff(1), zmore(1), znew(1), zforce(1), gzip(1), gzexe(1) ZGREP(1)
All times are GMT -4. The time now is 12:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy