2
votes
3answers
67 views

Make grep work for special filenames

I have a set of txt files whose names may contain space or special characters like #. I have a grep solution grep -L "cannot have" $(grep -l "must have" *.txt) to list all the files who have must ...
2
votes
2answers
174 views

grep and directories containing spaces

I would like to search all files containing an association of strings (here the files should contain 'arthur' AND ('déni' OR 'deni') for instance) in a directory and subdirectories. After some search ...
2
votes
2answers
295 views

How do I check that a filename conforms to a pattern?

I'm tasked with writing a shell script which checks that a filename conforms to a specific pattern and I'm not sure how to go about it. The filename should follow a pattern which looks like: ...
2
votes
3answers
209 views

Finding a number of occurrences of a certain character in tcsh

I am trying to find the number of certain types of files that have a '_' in the filename. I'm a massive beginner so my syntax looks like this at the moment; foreach txt ( 'ls *.txt') set n=0 if(grep ...
2
votes
4answers
1k views

Grep for a string with list of files as source

I have a plain text file, in every line is a path to a file. Now I have to grep for a string in these files. Is there any way to use this file as "search source" for grep? Or do I have to copy and ...
1
vote
1answer
239 views

How can I grep through files whose name begins with `-`? [duplicate]

I've tried this. grep -r thanks * slave-iv grep: invalid option -- '@' Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information. Here's ...