I want to grep a pattern in some files and count the occurrence with the filename. Right know, if I use
grep -r "month" report* | wc -l
it will sum all instances in all files. So the output is a single value 324343. I want something like this
report1: 3433
report2: 24399
....
The grep command will show the filename but will print every instance.
1. Write a menu driven shell program to
a. Display calendar of current month.
b. Search for a pattern in all the files/subdirectories from current directory.
c. Count the no. of directories / sub directories in current directory.
2. Display day of week for a given date.
I would like to recursively list all files in a directory which match a given input pattern using ls. (Oh, and this is in Bash).
The only way I can think of to do this using ls is to shopt -s extglob and then use the ls --ignore=pattern option with the extended glob negate pattern !( pattern-list ).
Hi Folks,
I wanted to know if i can use RegEx in a for-loop of a shell script.
Here's a scenario, I have a set of files say x1, x2, x3..x9 in a directory(obviously with files other than this pattern). I want to append a line of text to all files that follow pattern x[1-9]. Can someone help me out? I know its simple.
Problem Statement:-
I need to search a particular `String Pattern` in around `10000 files` and find the records which contains that `particular pattern`.
I am trying to search a file for a patterns ERR-[0-9][0-9][0-9][0-9][0-9] in a file and return a count for each of the error reported
Input file is a free flowing file without any format
example of output
ERR-00001=5
....
ERR-01010=10
.....
ERR-99999=10
My friend works in a IT company where he is required to keep a count of XML files inside a directory (including subdirectories).
However the count using ls -LR | grep .xml or similar takes a lot of time as the count of files is in the millions.
I was thinking what can be a better approach?
Can some kind of background process take care of this, so that whenever there is a new file created or mod
I'm trying to find all files whose name matches certain C++ file extensions but exclude certain directories matching a pattern with this:
find /home/palchan/code -name "*.[CcHh]" -o -name "*.cpp" -o -name "*.hpp" -a !
Hello,
Have a folder with lots of files & directories.
Want to delete all stuff except a particular pattern say "abc*".
Pattern will be in base directory & descending the structure is not required.
Can easily do it with looping or "grep -v", but wondering if there is an elegant solution.