3

How to find files in a directory using grep with wildcards?

 2 years ago
source link: https://www.codesd.com/item/how-to-find-files-in-a-directory-using-grep-with-wildcards.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to find files in a directory using grep with wildcards?

advertisements

I have several hundred files with file names such as: 20110404_091415-R1-sometext

Another file name might be named: 20110404_091415-R1.2-sometext

What I would like to do is use the Unix grep tool in the terminal to find files that start with 2011 and also contain -R1 within the file name. Unfortunately, I have no idea to find files that satisfy both these criteria. I have tried to figure out a regex that would match this, but I am only a beginner programmer. Can anyone help please? Thanks in advance for your time.


why even use grep? I think ls 2011*R1* should suffice..

Related Articles

How to find files in a directory that do not have extension?

I am looking for a code that will find files without extensions. In Rails, there is a file app_name/doc/README_FOR_APP. I am searching for a way to find files simular to this with no extension associated to the file, i.e., 'gemfile'. Something like:

listing files in the directory using grep

List all the files in /usr/bin whose filenames contain lowercase English alphabet characters only and also contain the word file as a (contiguous) substring. For example, file and profiles are such files, but git-ls-files is not. This is the exact qu

How to find patterns on multiple lines using grep?

I want to find files that have "abc" AND "efg" in that order, and those two strings are on different lines in that file. Eg: a file with content: blah blah.. blah blah.. blah abc blah blah blah.. blah blah.. blah blah.. blah efg blah b

How to list files in a directory using the Windows API?

I have this code and it displays the folder with the directory itself and not its contents. I want to display its contents. I don't want to use boost::filesystem. How can I resolve this? Code: #include <windows.h> #include <iostream> int main(

How to download files directly on S3 using PHP and with progress bar

There are some similar questions but none have a good answers in how to upload files directly to S3 using PHP with progress bar. Is it even possible adding a progress bar without using Flash? NOTE: I am referring to uploading from client browser dire

How to browse files in a directory?

I have a directory logfiles. I want to process each file inside this directory using a Python script. for file in directory: # do something How do I do this?With os.listdir() or os.walk(), depending on whether you want to do it recursively.

Count the number of files in a directory using Java

How do I count the number of files in a directory using Java ? For simplicity, lets assume that the directory doesn't have any sub-directories. I know the standard method of : new File(<directory path>).listFiles().length But this will effectively g

Rename multiple files in a directory using Python

I'm trying to rename multiple files in a directory using this Python script: import os path = '/Users/myName/Desktop/directory' files = os.listdir(path) i = 1 for file in files: os.rename(file, str(i)+'.jpg') i = i+1 When I run this script, I get the

Get the last modified date of the files in the directory using PHP

I am trying to get the last modification date of all files in a directory using PHP. I am using this: foreach($dir as $file) { $mod_date=date("F d Y H:i:s.", filemtime($file)); } foreach($dir as $file) is returning the correct files, but all of

How to find @username in a string using regex

How to find @username in given string using javascript and regex and move them to a div ? Allowed Items: @username @user_name Not Allowed Items: @_username // non alphabetical character at the beginning @1username // a number at the beginning @userna

Using grep with a pattern file: print single and duplicate entries

Let me start off by saying I don't want to print only the duplicate lines nor do I want to remove them. I am trying to use grep with a pattern file to parse a large data file. The Pattern file for example may look like this: 1243 1234 1234 1234 1354

Use grep with a large signature file

I just wanted to use grep with option -f FILE. This should make grep use every line of FILE as a pattern and search for it. Run: grep -f patternfile searchfile The pattern-file I used is 400MB large. The file I want to search through is 7GB. After 3

Use grep with a regular expression to filter matches

I'm trying to use grep with -v for invert-match along with -e for regular expression. I'm having trouble getting the syntax right. I'm trying something like tail -f logFile | grep -ve "string one|string two" If I do it this way it doesn't filter

How to read data from all files in a directory using C Language?

I am trying to 1) Find all files in a directory and display them, 2) Open all found files and read data from them (characters) 3) Output the read data to the screen or a new file. This is done in C Language and you will see below my current code. The

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK