Sponsored Content
Top Forums Shell Programming and Scripting How can i find a word inside a file from a directory and it's subdirectory ? Post 302562987 by ahamed101 on Sunday 9th of October 2011 12:54:34 PM
Old 10-09-2011
Check if your grep supports -r option, if so you can do it this way
Code:
grep -rli mail *

--ahamed
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate file's size in directory and subdirectory

Hi, I have written one script to calculate total space of all file in one directory, ignoring subdirectory, it works fine. Now, I've been trying to calculate all files which includes files in any subdirectories. I use recursive function to do this, but it can work only if there is only one... (4 Replies)
Discussion started by: KLL
4 Replies

2. UNIX for Dummies Questions & Answers

Create Year directory, date subdirectory and archive the file

Hi, After checking all the UNIX threads, I am able to come up with a solution so far. I am working on a shell script where it moves the files to a certain directory. The conditions to check are 1) Check if the file exists in the current directory. 2) Check if the destination directory... (2 Replies)
Discussion started by: madhunk
2 Replies

3. Shell Programming and Scripting

Find files in directory and its subdirectory

I am writing a script which reads a file line by line and then assigns it to a variable like this 1090373422_4028715212.jpg. I have images with file name of this format in some other directory. In my script I want to assign variable with this file name and then find this filename in some other... (11 Replies)
Discussion started by: jyotib
11 Replies

4. Shell Programming and Scripting

Find command, -name by directory and subdirectory?

Hi All, I'm trying to use the find command to return matches for a directory and file. For example, given the following directories: /one/two/three/file1.txt /one/three/two/file1.txt /one/four/two/three/file1.txt I'm expecting the following to be returned: ... (16 Replies)
Discussion started by: makodarear
16 Replies

5. Shell Programming and Scripting

Find files inside the parent directory only

Hi All, The following find command lists the files which are 45 minutes older. But it searches for the sub directories also. $ find . -type f -mmin +45 -print ./hello.txt ./test/hi.txt ./temp/now.txt ls hello.txt test temp How can i modify the find command in such way that it finds... (4 Replies)
Discussion started by: Tuxidow
4 Replies

6. Shell Programming and Scripting

Sum of file size in directory / subdirectory

Hi , I am trying to write something to find the size of particular type of files in a directory & it's subdirectory and sum the size .. These types of file are found at directory level or its subdirectories level .. #!/bin/ksh FNAME='.pdf' S_PATH=/abc/def/xyz find $S_PATH -exec ls -lad... (4 Replies)
Discussion started by: Vaddadi
4 Replies

7. Shell Programming and Scripting

Find and replace a word in all the files (that contain the word) under a directory

Hi Everyone, I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap". For Example: In the Directory, $pwd /home/nick $ grep -l "xsgd1234dap" *.sh | wc -l 119 I have "119" files that are still using... (5 Replies)
Discussion started by: filter
5 Replies

8. UNIX for Dummies Questions & Answers

command to find cksum of all files inside a directory?

I did this: ls -lrRt | grep ^* | cksum * but it is showing cksum of sub-directories. Thanks You Please use code tags when posting data and code samples, thank you. (3 Replies)
Discussion started by: ezee
3 Replies

9. Shell Programming and Scripting

Move all files not in a directory into a subdirectory named for each given file

Hi Everyone! Looking for some help with a script that will take all files in any given root folder (which are not already in a folder) and put them into separate folders with the name of each given file. Any ideas? Thank you! (1 Reply)
Discussion started by: DanTheMan
1 Replies

10. Shell Programming and Scripting

Searching File in Directory and all Subdirectory and Delete

Hi All, My directory structure is like Directory1 SubDirectory1 SubDirectory2 SubDirectory3 I have main directories and subdirectories underneath. I want to write a shell script where I will be passing file name as a parameter, Now I want to find all the files in Directory1... (19 Replies)
Discussion started by: John William
19 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 invokes grep on compressed or gzipped files. These grep options will cause zgrep to terminate with an error code: (-[drRzZ]|--di*|--exc*|--inc*|--rec*|--nu*). All other options specified are passed directly to grep. If no file is specified, 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 the GREP environment variable is set, zgrep uses it as the grep program to be invoked. EXIT CODE
2 - An option that is not supported was specified. AUTHOR
Charles Levert (charles@comm.polymtl.ca) SEE ALSO
grep(1), gzexe(1), gzip(1), zdiff(1), zforce(1), zmore(1), znew(1) ZGREP(1)
All times are GMT -4. The time now is 01:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy