Sponsored Content
Full Discussion: Search for a File Python
Top Forums Programming Search for a File Python Post 302867619 by in2nix4life on Thursday 24th of October 2013 02:20:30 PM
Old 10-24-2013
Why go outside of Python to perform the file search?

Code:
import os
import re

srchFile = 'GeoIP.dat'
srchDir  = '/usr/share'

for root, dirs, files in os.walk(srchDir):
    for file in files:
        if re.match(srchFile, file, re.IGNORECASE):
            geopath = os.path.join(root, file)

5c25eb06d19ae3c2f5f820d0c42bc8db

Last edited by in2nix4life; 11-12-2013 at 02:39 PM..
This User Gave Thanks to in2nix4life For This Post:
 

9 More Discussions You Might Find Interesting

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

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

3. Shell Programming and Scripting

[Python] Search a file with paramiko

I need to compare the output files in a directory for sftp, looking through a mask. Return the full file name. Eg. I have a file named locally: test.txt I must check through sftp, if a file with the following name: test_F060514_H173148.TXT My idea is for the filename to a... (0 Replies)
Discussion started by: Jomeaide
0 Replies

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

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

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

7. Shell Programming and Scripting

Search and Replace+append a text in python

Hello all, I have a verilog file as following (part of it): old.v: bw_r_rf16x32 AUTO_TEMPLATE ( 1957 // .rst_tri_en (mem_write_disable), 1958 .rclk (clk), 1959 .bit_wen (dva_bit_wr_en_e), 1960 .din ... (5 Replies)
Discussion started by: Zam_1234
5 Replies

8. Programming

Python re.search vs re.sub

I am having trouble understanding why these two commands differ with one producing the desire results and the other not. An example: capture_str = 'xserver-xorg-video-qxl-dbg (0.1.1-2+b2 , 0.1.1-2+b1 , 0.1.1-2 ) X.Org X server -- QXL display driver (debugging symbols)' re.search(r'(?<=\\, ).*',... (2 Replies)
Discussion started by: metallica1973
2 Replies

9. Programming

Search or find a element inside list python

I have a list as follows: From this i need to grep the element using keyword as "primary" and return output as 12:13-internet-wifi-primary i used as follows if (i <= (len(system_info))): ss = system_info print... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies
GEOIP_DB_GET_ALL_INFO(3)						 1						  GEOIP_DB_GET_ALL_INFO(3)

geoip_db_get_all_info - Returns detailed information about all GeoIP database types

SYNOPSIS
array geoip_db_get_all_info (void ) DESCRIPTION
The geoip_db_get_all_info(3) function will return detailed information as a multi-dimensional array about all the GeoIP database types. This function is available even if no databases are installed. It will simply list them as non-available. The names of the different keys of the returning associative array are as follows: o "available" -- Boolean, indicate if DB is available (see geoip_db_avail(3)) o "description" -- The database description o "filename" -- The database filename on disk (see geoip_db_filename(3)) RETURN VALUES
Returns the associative array. EXAMPLES
Example #1 A geoip_db_get_all_info(3) example This will print the array containing all the information. <?php $infos = geoip_db_get_all_info(); if (is_array($infos)) { var_dump($infos); } ?> The above example will output: array(11) { [1]=> array(3) { ["available"]=> bool(true) ["description"]=> string(21) "GeoIP Country Edition" ["filename"]=> string(32) "/usr/share/GeoIP/GeoIP.dat" } [ ... ] [11]=> array(3) { ["available"]=> bool(false) ["description"]=> string(25) "GeoIP Domain Name Edition" ["filename"]=> string(38) "/usr/share/GeoIP/GeoIPDomain.dat" } } Example #2 A geoip_db_get_all_info(3) example You can use the various constants as keys to get only parts of the information. <?php $infos = geoip_db_get_all_info(); if ($infos[GEOIP_COUNTRY_EDITION]['available']) { echo $infos[GEOIP_COUNTRY_EDITION]['description']; } ?> The above example will output: GeoIP Country Edition PHP Documentation Group GEOIP_DB_GET_ALL_INFO(3)
All times are GMT -4. The time now is 12:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy