I have a process creating the following files, which share a similar pattern.  file_1.txt file_2.txt . . . file_1000.txt . . . file_1901.txt file_1902.txt   But, there are only 1890 files in the folder. I would like to know if there is a way to identify the missing files from the list of files sharing a pattern.
21020
I have 2000+ files in a folder, but there are few files missing from the folder.  Name of the files are like     GLDAS_NOAH025SUBP_3H.A2003001.0000.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003001.0600.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003001.1200.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003001.1800.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003002.0000.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003002.0600.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003002.1200.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003002.1800.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003003.0000.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003003.0600.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003003.1200.001.2015210044609.pss.grb   GLDAS_NOAH025SUBP_3H.A2003003.1800.001.2015210044609.pss.grb   001 indicates day, while 0000 is the hour.  How to find out which file is missing in the folder? I got few answer in google but could not figure out how to implement those.
48423
I want to create multiple files at a time using names from a file list.txt, how can I do it?  Sample list.txt:  EOG090W002U EOG090W00C1 EOG090W00DC EOG090W00DE EOG090W00E5 EOG090W00HR EOG090W00MH EOG090W00MS EOG090W00PB EOG090W00U4 EOG090W00UK EOG090W00WM EOG090W00WR   Suppose I have this list.txt containing some id-numbers. Now I want to make separate files using these ids as the name (e.g. EOG090W002U_M0.ctl, EOG090W00C1_M0.ctl, EOG090W00DC_M0.ctl). Also, the contents of the files need to be change accordingly. For example the content of EOG090W002U_M0.ctl, EOG090W00C1_M0.ctl file will be   seqfile = EOG090W002U_p.phy treefile = Constant.txt outfile = EOG090W002U_M0_mlc   or  seqfile = EOG090W00C1_p.phy treefile = Constant.txt outfile = EOG090W00C1_M0_mlc   where *.phy and Constant.txt will be provided in the same folder.
55783
I am trying to run grep against a list of a few hundred files:  $ head -n 3 &lt;(cat files.txt) admin.php ajax/accept.php ajax/add_note.php   However, even though I am grepping for a string that I know is found in the files, the following does not search the files:  $ grep -i 'foo' &lt;(cat files.txt)  $ grep -i 'foo' admin.php The foo was found   I am familiar with the -f flag which will read the patterns from a file. But how to read the input files?  I had considered the horrible workaround of copying the files to a temporary directory as cp seems to support the &lt;(cat files.txt) format, and from there grepping the files. Shirley there is a better way.
42108
I have a directory (e.g., abc/def/efg) with many sub-directories (e.g.,: abc/def/efg/(1..300)). All of these sub-directories have a common file (e.g., file.txt). I want to search a string only in this file.txt excluding other files. How can I do this?  I used  grep -arin "pattern" *, but it is very slow if we have many sub-directories and files.
97364
I would like to know how file types are known if filenames don't have suffixes.  For example, a file named myfile could be binary or text to start with, how does the system know if the file is binary or text?
60833
I'm trying to accomplish a simple task using the excellent post : I would like to remove all files from a folder except those listed in a .txt file contained in the folder. The syntax works fine, but for some reason all files are removed - basically the script is saying that there are no correspondences between the filenames in the folder and those in the .txt file - but I can see that there are!   I thought maybe there might be some invisible white space after my file names that I cannot see (in the folder or the .txt file). But I don't think so...Is there another solution that I am not thinking of?
5122
How can I determine the list of files in a directory from inside my C or C++ code?  I'm not allowed to execute the ls command and parse the results from within my program.
19512
I have a largish music collection and there are some duplicates in there. Is there any way to find duplicate files. At a minimum by doing a hash and seeing if two files have the same hash.  Bonus points for also finding files with the same name apart from the extension - I think I have some songs with both mp3 and ogg format versions.  I'm happy using the command line if that is the easiest way.
22339
I'm looking for a way to list all files in a directory that contain the full set of keywords I'm seeking, anywhere in the file.  So, the keywords need not to appear on the same line.  One way to do this would be:  grep -l one $(grep -l two $(grep -l three *))   Three keywords is just an example, it could just as well be two, or four, and so on.  A second way I can think of is:  grep -l one * | xargs grep -l two | xargs grep -l three   A third method, that appeared in , would be:  find . -type f \   -exec grep -q one {} \; -a \   -exec grep -q two {} \; -a \   -exec grep -q three {} \; -a -print   But that's definitely not the direction I'm going here. I want something that requires less typing, and possibly just one call to grep, awk, perl or similar.  For example, I like how , like:  awk '/one/ &amp;&amp; /two/ &amp;&amp; /three/' *   Or, print just the file names:  awk '/one/ &amp;&amp; /two/ &amp;&amp; /three/ { print FILENAME ; nextfile }' *   But I want to find files where the keywords may be anywhere in the file, not necessarily on the same line.    Preferred solutions would be gzip friendly, for example grep has the zgrep variant that works on compressed files. Why I mention this, is that some solutions may not work well given this constraint. For example, in the awk example of printing matching files, you can't just do:  zcat * | awk '/pattern/ {print FILENAME; nextfile}'   You need to significantly change the command, to something like:  for f in *; do zcat $f | awk -v F=$f '/pattern/ { print F; nextfile }'; done   So, because of the constraint, you need to call awk many times, even though you could do it only once with uncompressed files. And certainly, it would be nicer to just do zawk '/pattern/ {print FILENAME; nextfile}' * and get the same effect, so I would prefer solutions that allow this.
61308
I've a simple bash script. PFB :  CWD=/cygdrive/c/Users/abhisek.samanta/Desktop/New_folder cd $CWD for i in `cat req_files.txt` do echo "file_found : $i"&gt;a.txt done   Note : req_files.txt is having a list of files which i need to find in this directory . If the files are found, it should list the name of the file which was found &amp; print it in "a.txt".   The req_files.txt is having multiple files,but only the first filename is getting printed &amp; not the rest of the files. Pl help.
55217
I have a file that has a list of paths like so:  "1"       "/user/bin/share" "2"       "/home/user/.local" "3"       "/root/"   Is there a way to extract just the paths? I dont want the numbers or quotation marks. How can I sed or grep the paths out of the file? What regex would be required for such a task?
13500
Input file1 is:  dog 123 4335 cat 13123 23424  deer 2131 213132 bear 2313 21313   I give the match the  pattern from in other file ( like dog 123 4335 from   file2).  I match the pattern of the line is dog 123 4335 and after printing all lines without match line my output is:   cat 13123 23424 deer 2131 213132 bear 2313 21313   If only use without address of line only use the pattern, for example 1s how to  match and  print the lines?
32629
Using find with grep, one can locate files that match a pattern:  # find | grep error ./solr-modifiedSolr4/SolrPhpClient/phpdocs/errors.html ./error_log ./includes/classes/error_log   However, using find alone the first file is not found:  # find . -name error* ./error_log ./includes/classes/error_log   Why doesn't find locate the errors.html file when not used with grep? How is find used to show this file as well?
104094
I need an algorithm that can compare two text files and highlight their difference and  ( even better!) can compute their difference in a meaningful way (like two similar files should have a similarity score higher than two dissimilar files, with the word "similar" defined in the normal terms). It sounds easy to implement, but it's not.  The implementation can be in c# or python.  Thanks.
32302
dir(re.compile(pattern))    does not return pattern as one of the lists's elements. Namely it returns:  ['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', 'subn']   According to the manual, it is supposed to contain      the object's attributes' names, the   names of its class's attributes, and   recursively of the attributes of its   class's base classes.   It says also that     The list is not necessarily complete.   Is there a way to get the complete list? I always assumed that dir returns a complete list but apparently it does not...  Also: is there a way to list only attributes? Or only methods?  Edit: this is actually a bug in python -> supposedly it is fixed in the 3.0 branch (and perhaps also in 2.6)
29409
I have several files with the same base filename. I'd like to remove all but one  foo.org #keep foo.tex #delete foo.fls #delete foo.bib #delete etc   If I didn't need to keep one, I know I could use rm foo.*.    demonstrates ^ to negate a match. Through trial and error, I was able to find that  rm foo.*[^org]   does what I need, but I don't really understand the syntax.   Also, while not a limitation in my use case, I think this pattern also ignores foo.o and foo.or. How does this pattern work, and what would a glob that ignores only foo.org look like?
37099
My question is a bit different from some older questions simply asking for "deleting all but the most recent n files in a directory".  I have a directory that contains different 'groups' of files where each group of files share some arbitrary prefix and each group has at least one file. I do not know these prefixes in advance and I do not know how many groups there are.  EDIT: actually, I know something about the file names, that is they all follow the pattern prefix-some_digits-some_digits.tar.bz2. The only thing matters here is the prefix part, and we can assume that within each prefix there is no digit or dash.  I want to do the following in a bash script:   Go through the given directory, identify all existing 'groups', and for each group of files, delete all but the most recent n files of the group only. If there are less than n files for a group, do nothing for that group, i.e. do not delete any file for that group.   What is a robust and safe way of doing the above in bash? Could you please explain the commands step-by-step?