![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
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 |
| read and drop files | shantanuo | UNIX for Dummies Questions & Answers | 1 | 09-26-2008 03:00 AM |
| Drop a Column from a File | Raamc | UNIX for Dummies Questions & Answers | 4 | 01-09-2008 10:36 AM |
| Dynamic Drop down boxes | garric | Shell Programming and Scripting | 13 | 10-18-2007 11:54 AM |
| Drop records with non-numerics in field X | akxeman | Shell Programming and Scripting | 3 | 08-15-2007 12:55 AM |
| Drop Users | trfrye | UNIX for Dummies Questions & Answers | 2 | 08-31-2005 03:39 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Quote:
Also, thanks for fixing my code tags before. I was trying to do that, and then saw it was already done. So the 'tr' line can be changed to: Code:
tr -s '\012' ' ' < $FILE1 > $FILE2 Code:
sed -e 's/ \([0-2][0-9][0-5][0-9] TMU\)/\ \1/g' $FILE2 | sed -n -e '/[0-2][0-9][0-5][0-9] TMU [MW][EX]/P' |
|
||||
|
I don't want anyone to think I'm ignoring posts, but I got pulled into an all-day meeting and it may last through tomorrow. Next week I'm traveling (Hawaii, yeah!) so won't be able to test anything on a Linux box. I will still try things on my Windows laptop, but as I've already found, what works here may not work there.
![]() I really appreciate all the help, and I'm sure we'll come up with a solution. I'm excited to try using awk instead of sed, and I have it on my laptop as well. Please keep the suggestions coming! |
|
||||
|
I may have it!
Back from Hawaii, leave for Florida tomorrow. Jacksonville is as cold as Seattle right now!
![]() I did some testing today (on Linux), and I think I have what I need. This is what I did: Code:
cat 15.txt | tr -s '\012' ' ' > tmp.txt echo WEATHER: > tmp3.txt echo cat tmp.txt | sed 's/ \([0-2][0-9][0-5][0-9] TMU\)/\ \1/g' | sed -n '/[0-2][0-9][0-5][0-9] TMU [WX:]/P' >> tmp3.txt echo EQUIPMENT: >> tmp3.txt echo cat tmp.txt | sed 's/ \([0-2][0-9][0-5][0-9] TMU\)/\ \1/g' | sed -n '/[0-2][0-9][0-5][0-9] TMU [EQ:]/P' >> tmp3.txt echo METERING: >> tmp3.txt echo sed -e 's/ \([0-2][0-9][0-5][0-9] TMU\)/\ \1/g' tmp.txt | sed -n -e '/[0-2][0-9][0-5][0-9] TMU [MET][EX]/P' >> tmp3.txt rm tmp.txt . The 3rd time through looking for METERING: I have problems. For some reason it returns the metering lines, plus more that don't match the string. However, I add in the [EX] and then it works! That confuses me, since I have a few more keywords to search for, and I don't want to have to ask for help every time ![]() Thanks again for the help. I'll be working on this again next Monday when I return from Florida. To bad all this travel is work related and I can't spend some time looking around! ![]() |
|
|||||
|
Quote:
![]() Quote:
![]() Quote:
![]() Quote:
ME MX EE EX TE TX If the word in that position doesn't start with the above you don't get it. If it does, you do. Quote:
![]() Last edited by rwuerth; 02-03-2009 at 06:05 PM.. Reason: (hopefully) clarified some statements. |
|
||||
|
Quote:
Thanks! And thanks for the explanation for what those nasty brackets were doing. That means the first two scans were just lucky that nothing else matched that request. I got the flick now! Mr Johnson: Tolerable is in the mind of the beholder !You're right, my code is really sloppy. I like the idea of blocking the code, didn't even occur to me . Also letting the results return to the terminal will help a lot. Where I thought I was looking for the METERING keyword [MET] I now understand was only looking for words with the first character matching any of those three letters. That explains why I got the results I did.As soon as I get back Monday I'll clean it up and use your suggestions. I see now I'm almost there, with all the great advice here. Thanks! Last edited by atc98092; 02-03-2009 at 06:19 PM.. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| awk, awk trim, trim, trim awk |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|