grep -i test $(find . -name "*.txt")
sample output :$ grep -i test $(find . -name "*.txt")
./apiclasses_all.txt:atg.commerce.order.processor.ProcValidateStoreCredit
you can also try with
$ find . -name "*.txt" -exec grep -i test {} \; -print
atg.commerce.order.processor.ProcValidateStoreCredit./apiclasses_all.txt
In some environments grep with recursive will work
$ grep -r -i raj *.txt
test1.txt:rajtext2.txt:raj
If there are many instances running on same machine and logs are redirecting to same directory
for example:
$ ls -ltr
total 1779040
-rw-r--r-- 1 sr8879 sysadmin 6243 Aug 5 10:42 jdbc.rar
drwxr-xr-x 2 root root 178 Aug 26 16:29 hsperfdata_root
drwx------ 2 root root 117 Aug 26 16:30 vx.004203.035257.110400.1642
drwx------ 2 root root 117 Aug 26 16:30 vx.106663.005702.043400.1753
drwx------ 2 root root 117 Aug 26 16:30 vx.113510.132240.132400.1883
-rw------- 1 root other 133 Aug 26 16:30 sh22020
-rw------- 1 root other 430 Aug 26 16:30 croutAAA4Aaisc
-rw-r--r-- 1 wlsadmin atg 203422 Aug 27 05:07 dynolog.PREMIERQA1CAAPP-20100827050632
-rw-r--r-- 1 wlsadmin atg 352234 Aug 27 05:14 PQACAMAIN1logs.txt.3326163321
-rw-r--r-- 1 wlsadmin atg 179579 Aug 27 05:14 PQACASTAGlogs.txt.3326163343
-rw-r--r-- 1 wlsadmin atg 892162 Aug 27 16:18 PQACAMAIN1logs.txt.1427051427
-rw-r--r-- 1 wlsadmin atg 178808 Aug 27 16:19 PQACASTAGlogs.txt.1427051449
-rw-r--r-- 1 wlsadmin atg 172779 Aug 27 16:52 dynolog.PREMIERQA1CAAPP-20100827165130
you want to search for error containing "repository does not have SELECT permission" only in Staging logs
PQACASTAG* logs belongs to Staging instance
So inorder to search those logs
To get only PQACASTAG* logs
by using grep and sed
$ ls -ltr | grep -i 'PQACASTAG*' | sed 's/^.*PQA/PQA/g'
PQACASTAGlogs.txt.3326163343PQACASTAGlogs.txt.1427051449
PQACASTAGlogs.txt.5927165947
or by using awk and grep
$ ls -ltr | awk '{print $9}' | grep -i 'PQACASTAG*'
PQACASTAGlogs.txt.3326163343PQACASTAGlogs.txt.1427051449
PQACASTAGlogs.txt.5927165947
Now we need to search only those logs
$ grep -i error.*select.*permission $(ls -ltr | awk '{print $9}' | grep -i 'PQACASTAG*')
PQACASTAGlogs.txt.3326163343:**** Error Thu Aug 26 16:51:57 PDT 2010 1282866717694 /com/att/wireless/reporting/ReportingRepository The table: "V_ONLINE_ORDER_INFO" does not appear to be defined correctly in the database. Either the table does not exist, the repository does not have SELECT permission on it, or the definition of the table is incompatible with the template in use.PQACASTAGlogs.txt.3326163343:**** Error Thu Aug 26 16:51:57 PDT 2010 1282866717701 /com/att/wireless/reporting/ReportingRepository The table: "V_ONLINE_ORDER_STATUS_INFO" does not appear to be defined correctly in the database. Either the table does not exist, the repository does not have SELECT permission on it, or the definition of the table is incompatible wit
h the template in use.
To replace all "text" in all ".txt" files in current directory
find . -name "*.txt" -exec sed -i 's/text/raj/g' {} \;
or
sed -i 's/raj/text/g' $(find . -name "*.txt")
or
sed -i 's/raj/text/g' $(find . -name "*.txt")
Displaying all html's which contains a word as links in browser (more like a local search engine)
grep -il $1 $(find /cygdrive/c/ATGPlatform91docs/ -name "*.htm[l]" -type f) | sed 's/\(.*\)/\1<\/a>
/g' > search.html; links search.html
to use/g' > search.html; links search.html
./satg Repository
which will display results in links browser with all html's as links which contains"Repository".
You can either use links or lynx or firefox to view search.html
No comments:
Post a Comment