Finding files in a specific date and then search for a phone number

jaredwins

I'm about half-way through this command. I'm eventually going to implement it in a PHP site so if I could keep it down to one line, that would rock!

Here's what I'm trying to do: find compressed files in a specific date, and then grep for the phone number 1234567890. The command I have so far is:

find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00'

The results are

 ./1006AC1.ACT.gz
 ./1006AC3.ACT.gz
 ./1006AC4.ACT.gz
 ./1006AC0.ACT.gz
 ./1006ABF.ACT.gz
 ./1006AC5.ACT.gz
 ./1006AC2.ACT.gz

This is good! But, this is also where I'm stuck. Each one of these files contains tons of records and to search the 7 compressed files I usually just:

gunzip -c 1006A* |grep 1234567890

But I'm trying to roll those two commands into one. Here's the direction I've been heading:

 find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' |xargs gunzip -c * | grep 1234567890

Unfortunately, this and the other variants I've tried either such nothing, or everything. I cannot get it to search only in the 7 files that were output.
Optionally, my other thought (because the goal is to implement it to a PHP site) would be to run my first command, and then try to find the files that match using a regex. In this case: 1006A
Then, I'd encapsulate that in a variable and send the second command similar to:

 gunzip -c $compressed |grep 1234567890


My difficulty here is taking all 7 files, and outputing only the letters/numbers that are similar in all 7.

Thanks for any help! Jared

John1024

Use zgrep:

find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' | xargs zgrep 1234567890

zgrep is like grep but understands compressed files.

Additional notes

In your trial command, note the star after xargs gunzip -c:

find . -newermt '2014-04-30 08:00:00' -not -newermt '2014-04-30 09:00:00' |xargs gunzip -c * | grep 1234567890

The shell will expand that star, *, to be all the filenames in the current directory. That is not what you want and is likely why you got unexpected results from the command.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Finding files in a specific date and then search for a phone number

From Dev

Finding and deleting files with a specific date

From Dev

Finding number of days and months in between specific date

From Dev

finding a specific date in MySql

From Dev

Linux search a specific text in specific log files based on date

From Dev

Specific phone number regex

From Dev

Dash search not finding some files

From Dev

Finding index of specific date in dateTimeArray

From Java

Finding specific range of number in java

From Dev

Finding number of occurrences for specific value

From Dev

Finding Page Number of specific record

From Dev

Finding specific number inside a string?

From Dev

Finding files not ending with specific extensions

From Dev

Finding files not ending with specific extensions

From Dev

Using LS To Show The Date Modified And A Specific Number Of Files

From Dev

Copy large number of files of specific date to another directory?

From Dev

Finding number of files in each folder

From Dev

NSDataDetector not finding phone number result type

From Dev

Search for Phone Number Pattern in a file

From Dev

Finding sum of number nearest to specific number

From Dev

finding specific files and data inside files

From Dev

Finding the square root of a number by using binary search

From Dev

Windows 7 search finding vdmk files with *.* but not *.vdmk

From Dev

Windows 10 not finding exe files in search

From Dev

Finding a specific number within a comma separated list

From Dev

Finding indexes of a specific repeated number in array

From Dev

Finding all combinations of numbers that equal a specific number

From Dev

Finding files within date range suffix

From Dev

Finding files based on the date contained in their filenames

Related Related

  1. 1

    Finding files in a specific date and then search for a phone number

  2. 2

    Finding and deleting files with a specific date

  3. 3

    Finding number of days and months in between specific date

  4. 4

    finding a specific date in MySql

  5. 5

    Linux search a specific text in specific log files based on date

  6. 6

    Specific phone number regex

  7. 7

    Dash search not finding some files

  8. 8

    Finding index of specific date in dateTimeArray

  9. 9

    Finding specific range of number in java

  10. 10

    Finding number of occurrences for specific value

  11. 11

    Finding Page Number of specific record

  12. 12

    Finding specific number inside a string?

  13. 13

    Finding files not ending with specific extensions

  14. 14

    Finding files not ending with specific extensions

  15. 15

    Using LS To Show The Date Modified And A Specific Number Of Files

  16. 16

    Copy large number of files of specific date to another directory?

  17. 17

    Finding number of files in each folder

  18. 18

    NSDataDetector not finding phone number result type

  19. 19

    Search for Phone Number Pattern in a file

  20. 20

    Finding sum of number nearest to specific number

  21. 21

    finding specific files and data inside files

  22. 22

    Finding the square root of a number by using binary search

  23. 23

    Windows 7 search finding vdmk files with *.* but not *.vdmk

  24. 24

    Windows 10 not finding exe files in search

  25. 25

    Finding a specific number within a comma separated list

  26. 26

    Finding indexes of a specific repeated number in array

  27. 27

    Finding all combinations of numbers that equal a specific number

  28. 28

    Finding files within date range suffix

  29. 29

    Finding files based on the date contained in their filenames

HotTag

Archive