Help me to find files in a shell script with any matching pattern
Hi friends.. I have many dirs in my working directory. Every dir have thousands of files (.jsp, .java, .xml..., etc). So I am working with an script to find every file recursively within those directories and subdirectories ending with .jsp or .java which contains inside of it, the the pattern "System.out.println", but at the same time it has to ingnore in the output those files which have same pattern, but with comment out lines: like this for example ( // System.out.println ). It has been difficult to me to ingnore those files with // System.out.println. files have tabs in some cases but in others not, I mean the format of files are diferent each others.
Here's my code.
--
The result are not the expected..
found_projects --> is the list of dirs i am using the search inside of them. sed 's/^[ \t]*//' --> for deleting all tabs and then check what files have lines starting with System.out.println
In conclusion, what I need is:
in conclusion is, get all the files that have the pattern System.out.println and ignore those on whose pattern is coment out, for example //System.out.println
Last edited by methyl; 01-25-2012 at 06:48 PM..
Reason: please use code tags.
Hi,
I want to list only the file names which do not contain a specific keyword or search string.
OS: Solaris
Also is there any way ; through the same script I can save the output of search to a CSV (comma seperated) so that the file can be used for inventory purpose.
Any assistance will... (5 Replies)
I'm looking for a way to match a particular string in another string and if a match is found execute some command.
I found the case statement can be used like this;
case word in
)
command ;; ] ...
esac
If my string to find is say "foo" in the string $mystring... (1 Reply)
Hi,
I am writing a BASH shell script. I would like to count all the files in the CURRENT directory matching a specific pattern. Could someone suggest the best/simplest way to do this. I have thought of these solutions (for simplicity the pattern is all files starting with A):
ls -1 *A | wc -l... (5 Replies)
Hi,
I have following files in my directory:
/TESTDONTDEL> ls -alt
total 14
drwxr-xr-x 2 oracle dba 1024 May 15 06:30 .
-rw-r--r-- 1 oracle dba 40 May 15 06:30 exception.txt
-rw-r--r-- 1 oracle dba 19 May 15 06:22 ful_1234_test1.txt
-rw-r--r-- 1... (2 Replies)
Hi,
I need to create a shell script through which i need to populate email addresses in email columns of database table in mysql. Let say if email contains yahoo, hotmail, gtalk than email addresses need to move in their respective columns.
# !/bin/sh
yim="example@yahoo.com"... (3 Replies)
Hi,
I am using following command to extract string from a file. String will be after last / (slash).
awk -F\ / '{print $NF}' $FILE
but while appending the output in file in script, it dosent work. File created but of zero size... can anyone please help
`awk -F\\\/ '{print $NF}' $FILE` >... (3 Replies)
Hi all,
I have to check whether certain files exist using a if statement. I have to check this by matching a pattern of filename: e.g.
if ]
This statement should be "true" if any files like test.dat11, test.dat22 etc are present in the source dir. However, this statement is checking only... (2 Replies)
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
Write an automated shell program(s) that can create, monitor the log files and report the issues for matching... (0 Replies)
Hi,
I want to find all directories matching given pattern in current directory and zip those files.
I am trying to do somethign like this. But it is not working.
for FNAME in $(find . -type d | grep './\{2\}-\{2\}$');
do
zip -r MatchedFiles.zip $FNAME
rm -fr $FNAME
done
... (4 Replies)
Hello all,
this is my first and probably not my last question around here. I do hope you can help or at least point me in the right direction.
My question is as follows, I need to find files and possible folders which are not owner = AAA group = BBB with a said location and all sub folders ... (7 Replies)
Discussion started by: kilobyter
7 Replies
LEARN ABOUT SUSE
stapex
STAPEX(3stap)STAPEX(3stap)NAME
stapex - systemtap examples
LANGUAGE BASICS
These examples give a feel for basic systemtap syntax and control structures.
global odds, evens
probe begin {
# "no" and "ne" are local integers
for (i=0; i<10; i++) {
if (i % 2) odds [no++] = i
else evens [ne++] = i
}
delete odds[2]
delete evens[3]
exit ()
}
probe end {
foreach (x+ in odds) {
printf ("odds[%d] = %d0, x, odds[x])
}
foreach (x in evens-) {
printf ("evens[%d] = %d0, x, evens[x])
}
}
This prints:
odds[1] = 1
odds[3] = 5
odds[4] = 7
odds[5] = 9
evens[5] = 8
evens[4] = 6
evens[2] = 2
evens[1] = 0
Note that all variables types are inferred, and that all locals and globals are automatically initialized.
This script prints the primes between 0 and 49.
function isprime (x) {
if (x < 2) return 0
for (i=2; i<x; i++) {
if (x % i == 0) return 0
if (i * i > x) break
}
return 1
}
probe begin {
for (i=0; i<50; i++)
if (isprime (i)) printf("%d0, i)
exit()
}
This script demonstrates recursive functions.
function fibonacci(i) {
if (i < 1) error ("bad number")
if (i == 1) return 1
if (i == 2) return 2
return fibonacci (i-1) + fibonacci (i-2)
}
probe begin {
printf ("11th fibonacci number: %d0, fibonacci(11))
exit ()
}
Any larger number may exceed the MAXACTION or MAXNESTING limits, and result in an error.
PROBING
To trace entry and exit from a function, use a pair of probes:
probe kernel.function("sys_mkdir") { println ("enter") }
probe kernel.function("sys_mkdir").return { println ("exit") }
To list the probeable functions in the kernel, use the listings mode.
% stap -l 'kernel.function("*")'
To list the probeable functions and local variables in the kernel, use another listings mode.
% stap -L 'kernel.function("*")'
MORE EXAMPLES
The directory to find more examples can be found in the stappaths(7) manual page.
SEE ALSO stap(1)stapprobes(3stap)stapfuncs(3stap)stappaths(7)STAPEX(3stap)