![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep statement | Shazin | Shell Programming and Scripting | 1 | 07-30-2009 12:14 PM |
| grep entire statement not just line | shantanuo | UNIX for Dummies Questions & Answers | 3 | 08-28-2008 01:48 PM |
| Using grep in a test/if statement | cbo0485 | Shell Programming and Scripting | 4 | 03-21-2008 12:29 AM |
| How to improve grep performance... | pooga17 | Shell Programming and Scripting | 2 | 02-13-2008 07:34 AM |
| Using grep in if statement | chiru_h | Shell Programming and Scripting | 3 | 09-12-2006 11:00 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
I'm searching the most effective way of doing the following task, so if someone can either provide a working solution with sed or one totally different but more effective then what I've got so far then please go ahead! The debugme directory has 3 subdirectorys and each of them has one .txt file with about 48 entrys each. Code:
time (
for FILE1 in `find debugme -name "*.txt"` ;do
for FILE2 in `cat "$FILE1" | awk '{print $1}' | grep -i '^\([0-9]\+\)$'` ;do
#for FILE2 in `sed 's/\([0-9]\+\) \([a-zA-Z0-9]\+\)/\1/i' "$FILE"` ;do
CHECK=`grep "$FILE2" "debug.files"`
if [ "$CHECK" = "" ]; then
## ADD MISSING ENTRY BLABLA
echo "$FILE2 was missing, added!"
fi
done
done
)
Avg result:
real 0m0.174s
user 0m0.052s
sys 0m0.128s
time (
for FILE1 in `find debugme -name "*.txt"` ;do
FILE2() {
S=`grep $1 debug.files`
if [ "$S" = "" ] ; then
## ADD MISSING ENTRY BLABLA
echo "$FILE2 was missing, added!"
fi
}
while read cola colb ; do
$(FILE2 $cola)
done < $FILE1
done
)
Avg result:
real 0m0.269s
user 0m0.064s
sys 0m0.228s
The .txt files are in this format: Code:
[03:53:22] root:~# cat example.txt 52352578 ABF2778ABD^ 73534536 LASDM337lA^ 83523422 JFAASMM31^ And debug.files in this: Code:
[03:53:25] root:~# cat debug.files 52352578 73534536 |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|