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 302562985 by admin_xor on Sunday 9th of October 2011 12:25:29 PM
Old 10-09-2011
Here's what you want:
Code:
find ./ -type f -print0 | xargs -0 grep -n "mail"

This code shows the file name and the line number where "mail" is found.
Output:
Code:
/home/unixuser/.gnupg/gpg.conf:102:# Example email keyserver:
/home/unixuser/.gnupg/gpg.conf:103:#      mailto:pgp-public-keys@keys.pgp.net
/home/unixuser/.gnupg/gpg.conf:129:#keyserver mailto:pgp-public-keys@keys.nl.pgp.net
/home/unixuser/.gnupg/gpg.conf:201:# photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"

and if you want to match with just the word "mail", use this:
Code:
find ./ -type f -print0 | xargs -0 grep -n " mail "

Note the spaces before and after mail within quotes. For case-insensitive search, add -i with grep:
Code:
find ./ -type f -print0 | xargs -0 grep -in " mail "


Last edited by admin_xor; 10-09-2011 at 01:31 PM..
 

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
GPGV2(1)							 GNU Privacy Guard							  GPGV2(1)

NAME
gpgv2 - Verify OpenPGP signatures SYNOPSIS
gpgv2 [options] signed_files DESCRIPTION
gpgv2 is an OpenPGP signature verification tool. This program is actually a stripped-down version of gpg which is only able to check signatures. It is somewhat smaller than the fully-blown gpg and uses a different (and simpler) way to check that the public keys used to make the signature are valid. There are no configuration files and only a few options are implemented. gpgv2 assumes that all keys in the keyring are trustworthy. By default it uses a keyring named 'trustedkeys.gpg' which is assumed to be in the home directory as defined by GnuPG or set by an option or an environment variable. An option may be used to specify another keyring or even multiple keyrings. RETURN VALUE
The program returns 0 if everything is fine, 1 if at least one signature was bad, and other error codes for fatal errors. OPTIONS
gpgv2 recognizes these options: --verbose -v Gives more information during processing. If used twice, the input data is listed in detail. --quiet -q Try to be as quiet as possible. --keyring file Add file to the list of keyrings. If file begins with a tilde and a slash, these are replaced by the HOME directory. If the file- name does not contain a slash, it is assumed to be in the home-directory ("~/.gnupg" if --homedir is not used). --status-fd n Write special status strings to the file descriptor n. See the file DETAILS in the documentation for a listing of them. --logger-fd n Write log output to file descriptor n and not to stderr. --ignore-time-conflict GnuPG normally checks that the timestamps associated with keys and signatures have plausible values. However, sometimes a signature seems to be older than the key due to clock problems. This option turns these checks into warnings. --homedir dir Set the name of the home directory to dir. If this option is not used, the home directory defaults to '~/.gnupg'. It is only recog- nized when given on the command line. It also overrides any home directory stated through the environment variable 'GNUPGHOME' or (on W32 systems) by means of the Registry entry HKCUSoftwareGNUGnuPG:HomeDir. EXAMPLES
gpgv2 pgpfile gpgv2 sigfile [datafile] Verify the signature of the file. The second form is used for detached signatures, where sigfile is the detached signature (either ASCII-armored or binary) and datafile contains the signed data; if datafile is "-" the signed data is expected on stdin; if datafile is not given the name of the file holding the signed data is constructed by cutting off the extension (".asc", ".sig" or ".sign") from sigfile. FILES
~/.gnupg/trustedkeys.gpg The default keyring with the allowed keys. ENVIRONMENT
HOME Used to locate the default home directory. GNUPGHOME If set directory used instead of "~/.gnupg". SEE ALSO
gpg2(1) The full documentation for this tool is maintained as a Texinfo manual. If GnuPG and the info program are properly installed at your site, the command info gnupg should give you access to the complete manual including a menu structure and an index. GnuPG 2.0.22 2014-06-10 GPGV2(1)
All times are GMT -4. The time now is 08:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy