Sponsored Content
Top Forums Shell Programming and Scripting Search for a particular file in the server Post 302266068 by zaxxon on Tuesday 9th of December 2008 10:22:26 AM
Old 12-09-2008
find was a good idea. You could just test it by searching a file you know it exist.
Code:
find / -type f -name "yourfilename" -print

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

use ind command to search files on differnet server

Hi, I am writing script to search the directories on different server. I have 3 servers. eg. ser1, ser2, ser2 find <absolute_path>-type d -user <user_name> -ctime +5 -exec ls -ltd {} \; can someone please suggest me some way how can i use find command for this. i have ssh connectivity... (1 Reply)
Discussion started by: vikash_k
1 Replies

2. Shell Programming and Scripting

sed help - search/copy from one file and search/paste to another

I am a newbie and would like some help with the following - Trying to search fileA for a string similar to - AS11000022010 30.4 31.7 43.7 53.8 60.5 71.1 75.2 74.7 66.9 56.6 42.7 32.5 53.3 I then want to replace that string with a string from fileB - ... (5 Replies)
Discussion started by: ncwxpanther
5 Replies

3. Shell Programming and Scripting

Perl - use search keywords from array and search a file and print 3rd field when matched

Hi , I have been trying to write a perl script to do this job. But i am not able to achieve the desired result. Below is my code. my $current_value=12345; my @users=("bob","ben","tom","harry"); open DBLIST,"<","/var/tmp/DBinfo"; my @input = <DBLIST>; foreach (@users) { my... (11 Replies)
Discussion started by: chidori
11 Replies

4. 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

5. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

6. Shell Programming and Scripting

Nested search in a file and replace the inner search

Hi Team, I am new to unix, please help me in this. I have a file named properties. The content of the file is : ##Mobile props east.url=https://qa.east.corp.com/prop/end west.url=https://qa.west.corp.com/prop/end south.url=https://qa.south.corp.com/prop/end... (2 Replies)
Discussion started by: tolearn
2 Replies

7. Shell Programming and Scripting

Retrieving the relevant search from search file in the main file

I have two files: file 1: hello.com neo.com,japan.com,example.com news.net xyz.com, telecom.net, highlands.net, software.com example2.com earth.net, abc.gov.uk file 2: neo.com example.com abc.gov.uk file 2 are the search keys to search in file 1 if any of the search... (7 Replies)
Discussion started by: csim_mohan
7 Replies

8. UNIX for Dummies Questions & Answers

Search file and print everything except multiple search terms

I'm trying to find a way to search a range of similar words in a file. I tried using sed but can't get it right:sed 's/\(ca01\)*//'It only removes "ca01" but leaves the rest of the word. I still want the rest of the information on the lines just not these specific words listed below. Any... (3 Replies)
Discussion started by: seekryts15
3 Replies

9. Shell Programming and Scripting

Read in search strings from text file, search for string in second text file and output to CSV

Hi guys, I have a text file named file1.txt that is formatted like this: 001 , ID , 20000 002 , Name , Brandon 003 , Phone_Number , 616-234-1999 004 , SSNumber , 234-23-234 005 , Model , Toyota 007 , Engine ,V8 008 , GPS , OFF and I have file2.txt formatted like this: ... (2 Replies)
Discussion started by: An0mander
2 Replies

10. Shell Programming and Scripting

How to search the multiple strings in app server.log?

Hi Team, Could you please suggest the below requirement. using the below server log, i just want only the order_id with combination of customer name , error code value as 5000111 & amount value using the shell script i tired using the command grep "error_code>50001111"... (6 Replies)
Discussion started by: venkat918
6 Replies
PREG_MATCH(3)								 1							     PREG_MATCH(3)

preg_match - Perform a regular expression match

SYNOPSIS
int preg_match (string $pattern, string $subject, [array &$matches], [int $flags], [int $offset]) DESCRIPTION
Searches $subject for a match to the regular expression given in $pattern. PARAMETERS
o $pattern - The pattern to search for, as a string. o $subject - The input string. o $matches - If $matches is provided, then it is filled with the results of search. $matches[0] will contain the text that matched the full pattern, $matches[1] will have the text that matched the first captured parenthesized subpattern, and so on. o $flags -$flags can be the following flag: o PREG_OFFSET_CAPTURE - If this flag is passed, for every occurring match the appendant string offset will also be returned. Note that this changes the value of $matches into an array where every element is an array consisting of the matched string at offset 0 and its string offset into $subject at offset 1. o $offset - Normally, the search starts from the beginning of the subject string. The optional parameter $offset can be used to specify the alternate place from which to start the search (in bytes). Note Using $offset is not equivalent to passing substr($subject, $offset) to preg_match(3) in place of the subject string, because $pattern can contain assertions such as ^, $ or (?<=x). Compare: <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3); print_r($matches); ?> The above example will output: Array ( ) while this example <?php $subject = "abcdef"; $pattern = '/^def/'; preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> will produce Array ( [0] => Array ( [0] => def [1] => 0 ) ) RETURN VALUES
preg_match(3) returns 1 if the $pattern matches given $subject, 0 if it does not, or FALSE if an error occurred. Warning This function may return Boolean FALSE, but may also return a non-Boolean value which evaluates to FALSE. Please read the section on Booleans for more information. Use the === operator for testing the return value of this function. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.6 | | | | | | | Returns FALSE if $offset is higher than $subject | | | length. | | | | | 5.2.2 | | | | | | | Named subpatterns now accept the syntax | | | (?<name>) and (?'name') as well as (?P<name>). | | | Previous versions accepted only (?P<name>). | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Find the string of text "php" <?php // The "i" after the pattern delimiter indicates a case-insensitive search if (preg_match("/php/i", "PHP is the web scripting language of choice.")) { echo "A match was found."; } else { echo "A match was not found."; } ?> Example #2 Find the word "web" <?php /* The  in the pattern indicates a word boundary, so only the distinct * word "web" is matched, and not a word partial like "webbing" or "cobweb" */ if (preg_match("/web/i", "PHP is the web scripting language of choice.")) { echo "A match was found."; } else { echo "A match was not found."; } if (preg_match("/web/i", "PHP is the website scripting language of choice.")) { echo "A match was found."; } else { echo "A match was not found."; } ?> Example #3 Getting the domain name out of a URL <?php // get host name from URL preg_match('@^(?:http://)?([^/]+)@i', "http://www.php.net/index.html", $matches); $host = $matches[1]; // get last two segments of host name preg_match('/[^.]+.[^.]+$/', $host, $matches); echo "domain name is: {$matches[0]} "; ?> The above example will output: domain name is: php.net Example #4 Using named subpattern <?php $str = 'foobar: 2008'; preg_match('/(?P<name>w+): (?P<digit>d+)/', $str, $matches); /* This also works in PHP 5.2.2 (PCRE 7.0) and later, however * the above form is recommended for backwards compatibility */ // preg_match('/(?<name>w+): (?<digit>d+)/', $str, $matches); print_r($matches); ?> The above example will output: Array ( [0] => foobar: 2008 [name] => foobar [1] => foobar [digit] => 2008 [2] => 2008 ) NOTES
Tip Do not use preg_match(3) if you only want to check if one string is contained in another string. Use strpos(3) or strstr(3) instead as they will be faster. SEE ALSO
PCRE Patterns, preg_quote(3), preg_match_all(3), preg_replace(3), preg_split(3), preg_last_error(3). PHP Documentation Group PREG_MATCH(3)
All times are GMT -4. The time now is 10:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy