Sponsored Content
Top Forums UNIX for Dummies Questions & Answers What is the Best way to search files for a string?? Post 302178069 by 35Soinc on Monday 24th of March 2008 02:06:34 PM
Old 03-24-2008
What is the Best way to search files for a string??

I'm looking to seach all the files in a directory and sub-directories looking for a string. When the string is found, I want to display the filename and the entire line of that file that the string was found on.

what is the best way to do this ?? I've been playing around with awk, find, and grep with no luck. I am on HPUX 11.11

thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Search all files for specific string

Hi Friends, How can I search all files in all slices on a unix system for a particular string within the file. e.g search string 'oracle' Thanks (4 Replies)
Discussion started by: sureshy
4 Replies

2. UNIX for Dummies Questions & Answers

Search files for a string in the remote machine

Hi all, I want to search the files in a remote machine for a particular string. The SSH command I wrote is giving an error even when the syntax is correct. ssh user@hostmachine find . -name "*.txt" -exec grep "ARIVU" '{}' \; The error it gives is find: missing argument to `-exec' When the... (2 Replies)
Discussion started by: a_rivu
2 Replies

3. UNIX for Dummies Questions & Answers

String Search within Text Files

I have many scripts in directories and sub-directories that I would like to search for a specific string. How would I do that? (1 Reply)
Discussion started by: bggibson
1 Replies

4. UNIX for Dummies Questions & Answers

Search for Files that DONT contain a string

How do I search for files that dont contain a certain string? I am currently trying find ./logs -size +1c -exec grep -l 'Process Complete' {} \; -exec ls -l {} \; > $TOD Which gives me files that are reater han 0 file size and contain the string 'Process complete' but I want files that DONT... (13 Replies)
Discussion started by: tonydsam
13 Replies

5. Shell Programming and Scripting

Search and replace string in files

I'm trying to remove the following string from several files. <img heigth="1" width="1" border="0" src="http://myteenmovies.net/t.php?id=5540372">I'm using the following script #!/bin/bash # This script will search and replace all regular files for a string # supplied by the user and... (1 Reply)
Discussion started by: d13g0sv
1 Replies

6. Shell Programming and Scripting

Help with search string between two files

Hi, Basically i want to search for a string in file two based on the input file one and if it matches get the nextline and print the value of the field name. cat one abc xyz defcat two <src> <name="path/to/abc" test="value_version"> <new name="Y2" > </src> <src> <name="path/to/xyz"... (5 Replies)
Discussion started by: greet_sed
5 Replies

7. Shell Programming and Scripting

Search several string and convert into a single line for each search string using awk command AIX?.

I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios. Cat test Nov 10, 2012 5:17:53 AM INFO: Request Type Line 1.... (5 Replies)
Discussion started by: laknar
5 Replies

8. Shell Programming and Scripting

Search string within a file and list common words from the line having the search string

Hi, Need your help for this scripting issue I have. I am not really good at this, so seeking your help. I have a file looking similar to this: Hello, i am human and name=ABCD. How are you? Hello, i am human and name=PQRS. I am good. Hello, i am human and name=ABCD. Good bye. Hello, i... (12 Replies)
Discussion started by: royzlife
12 Replies

9. Shell Programming and Scripting

Read files incrementally and search for particular string.

Example I have following requirements where i need to search for particular string from the log files.Files will be archived with number attached end to it and creates a new log file. First Day i will ran at 8:00 AM Filename:a.log1 Wed Aug 24 04:46:34... (1 Reply)
Discussion started by: nareshnani211
1 Replies

10. UNIX for Beginners Questions & Answers

Loop through the folders and search for particular string in files

Hello, Opearting System Environment : HP Unix B.11.31 U I look for script to On specific folders list On specific filelist Search for given string For Example : r48_buildlib.txt contains wpr480.0_20161027 wpr480.0_20161114 wpr481.0_20161208 wpr482.0_20161222... (4 Replies)
Discussion started by: Siva SQL
4 Replies
MrmOpenHierarchy(library call)											    MrmOpenHierarchy(library call)

NAME
MrmOpenHierarchy -- Allocates a hierarchy ID and opens all the UID files in the hierarchy SYNOPSIS
#include <Mrm/MrmPublic.h> Cardinal MrmOpenHierarchy( MrmCount num_files, String file_names_list[], MrmOsOpenParamPtr *ancillary_structures_list, MrmHierarchy *hierarchy_id); DESCRIPTION
This routine is obsolete and exists for compatibility with previous releases. It is replaced by MrmOpenHierarchyPerDisplay. MrmOpenHierar- chy is identical to MrmOpenHierarchyPerDisplay except that MrmOpenHierarchy does not take a display argument. num_files Specifies the number of files in the name list. file_names_list Specifies an array of character strings that identify the UID files. ancillary_structures_list A list of operating-system-dependent ancillary structures corresponding to items such as filenames, clobber flags, and so forth. This argument should be NULL for most operations. If you need to reference this structure, see the definition of MrmOsOpen- ParamPtr in the MrmPublic.h header file for more information. hierarchy_id Returns the search hierarchy ID. The search hierarchy ID identifies the list of UID files that MRM searches (in order) when per- forming subsequent fetch calls. Each UID file string in file_names_list can specify either a full pathname or a filename. If a UID file string has a leading slash (/), it specifies a full pathname, and MRM opens the file as specified. Otherwise, the UID file string specifies a filename. In this case, MRM looks for the file along a search path specified by the UIDPATH environment variable or by a default search path, which varies depending on whether or not the XAPPLRESDIR environment variable is set. The UIDPATH environment variable specifies a search path and naming conventions associated with UID files. It can contain the substitution field %U, where the UID file string from the file_names_list argument to MrmOpenHierarchyPerDisplay is substituted for %U. It can also contain the substitution fields accepted by XtResolvePathname. The substitution field %T is always mapped to uid. The entire path is first searched with %S mapped to .uid. If no file is found, it is searched again with %S mapped to NULL. If no display is set prior to calling this function, the result of this function's call to XtResolvePathname is undefined. For example, the following UIDPATH value and MrmOpenHierarchy call cause MRM to open two separate UID files: UIDPATH=/uidlib/%L/%U.uid:/uidlib/%U/%L static char *uid_files[] = {"/usr/users/me/test.uid", "test2"}; MrmHierarchy *Hierarchy_id; MrmOpenHierarchy((MrmCount)2,uid_files, NULL, Hierarchy_id) MRM opens the first file, /usr/users/me/test.uid, as specified in the file_names_list argument to MrmOpenHierarchy, because the UID file string in the file_names_list argument specifies a full pathname. MRM looks for the second file, test2, first as /uidlib/%L/test2.uid and second as /uidlib/test2/%L, where the display's language string is substituted for %L. After MrmOpenHierarchy opens the UID hierarchy, you should not delete or modify the UID files until you close the UID hierarchy by calling MrmCloseHierarchy. If UIDPATH is not set but the environment variable XAPPLRESDIR is set, MRM searches the following pathnames: o %U%S o $XAPPLRESDIR/%L/uid/%N/%U%S o $XAPPLRESDIR/%l/uid/%N/%U%S o $XAPPLRESDIR/uid/%N/%U%S o $XAPPLRESDIR/%L/uid/%U%S o $XAPPLRESDIR/%l/uid/%U%S o $XAPPLRESDIR/uid/%U%S o $HOME/uid/%U%S o $HOME/%U%S o /usr/lib/X11/%L/uid/%N/%U%S o /usr/lib/X11/%l/uid/%N/%U%S o /usr/lib/X11/uid/%N/%U%S o /usr/lib/X11/%L/uid/%U%S o /usr/lib/X11/%l/uid/%U%S o /usr/lib/X11/uid/%U%S o /usr/include/X11/uid/%U%S If neither UIDPATH nor XAPPLRESDIR is set, MRM searches the following pathnames: o %U%S o HOME/%L/uid/%N/%U%S o HOME/%l/uid/%N/%U%S o $HOME/uid/%N/%U%S o $HOME/%L/uid/%U%S o $HOME/%l/uid/%U%S o $HOME/uid/%U%S o $HOME/%U%S o /usr/lib/X11/%L/uid/%N/%U%S o /usr/lib/X11/%l/uid/%N/%U%S o /usr/lib/X11/uid/%N/%U%S o /usr/lib/X11/%L/uid/%U%S o /usr/lib/X11/%l/uid/%U%S o /usr/lib/X11/uid/%U%S o /usr/include/X11/uid/%U%S These paths are defaults that vendors may change. For example, a vendor may use different directories for /usr/lib/X11 and /usr/include/X11. The following substitutions are used in these paths: %U The UID file string, from the file_names_list argument. %N The class name of the application. %L The display's language string. This string is influenced by XtSetLanguageProc. The default string is determined by calling set- locale(LC_ALL, NULL). %l The language component of the display's language string. %S The suffix to the filename. The entire path is first searched with a suffix of .uid. If no file is found, it is searched again with a NULL suffix. RETURN
This function returns one of the following status return constants: MrmSUCCESS The function executed successfully. MrmNOT_FOUND File not found. MrmFAILURE The function failed. RELATED
MrmOpenHierarchyPerDisplay(3) and MrmCloseHierarchy(3). MrmOpenHierarchy(library call)
All times are GMT -4. The time now is 06:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy