Search code examples
grepls

List filename not contain some keywords in the dictory file


In a folder, there are lots of files, which contain timestamp information in the filename, for example,

callMic-13501358220-414404433.caf   (414404433 is the timestamp)
callMic-18901111584-414235643.caf
....

I also have a text file (timestamp.txt) which woule be used as a dictory. The text file contain lots of timestamp per line, as shown below.

414247851
414235643
414226229
....
..

i want to list all filenames which not contain the timestamp listed in timestamp.txt.


Solution

  • grep -vFwf timstamp.txt filename.txt
    

    if your filenames are not in file, you could

    ls -1 or find magic..|grep -vFwf timestamp.txt