Make list of files which contains IP
Hello,
I would like to make a list of files which is having IP address present. Example I can list the .php files by using the following, find /var/www/html/Macrotext/ -name *.php >> /tmp/phpfilelist.txt But how to list .php the files which is only having IP address in it. Kind regards, Jojan Paul |
You can use 'grep' to find the files, 'grep -l' will print only filenames.
Here's one good page for you: http://www.shellhacks.com/en/RegEx-F...ile-Using-Grep |
Am using the following to command but no luck
find /var/www/html/Macrotext/ -name '*.php' | grep 10.10.3.120 >> /tmp/phpfilelist120.txt |
because that grep will search in the filenames instead of contents. You need to check the -exec flag of find (see man page)
|
You need to understand what you are doing.
In your example, you list all filenames ending with '.php', then you look for an ip address in the filenames. You could do this two ways: 1. Find all files with ip addresses in them, then sort out the php-files or 2. Find all php-files, then search each file for ip addresses. Both ways work, without too much thinking I'd say the first method requires little less coding. But if you want to search places with large amount of files the second method is probably faster - it's quicker to search for filenames than to search for a string in files. |
All times are GMT -5. The time now is 08:20 PM. |