why exactly do you need to 'cat' into 'tr' and 'sed'?
Thanks for challenging that. As you already know (since I've seen you issue this challenge before ;-) ), I don't have to cat into either command, when I can use redirect for 'tr' and sed will work on a specified file. Saves a couple of processes.
Also, thanks for fixing my code tags before. I was trying to do that, and then saw it was already done.
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!
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:
If I am following the flow correctly, after the first cat changes the newlines to spaces and saves into a temp file, I can then scan for my keywords to retrieve the individual entries required. On the first two I scan for WX: and EQ: and it returns exactly what I want .
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!
Back from Hawaii, leave for Florida tomorrow. Jacksonville is as cold as Seattle right now!
You mean it's tolerable?
Quote:
I did some testing today (on Linux), and I think I have what I need. This is what I did:
If I am following the flow correctly, after the first cat changes the newlines to spaces and saves into a temp file,
cat doesn't change anything; it is useless in this context.
Bloated code is hard to read. First, get rid of all instances of cat.
Then get rid of all the >> tmp3.txt and redirect an entire block, e.g.:
That way, you can easily comment out the redirection when testing, and you will see the output in your terminal.
Quote:
I can then scan for my keywords to retrieve the individual entries required. On the first two I scan for WX: and EQ: and it returns exactly what I want .
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.
There is no search for METERING in your code.
It's very difficult to debug code that you don't show.
Quote:
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
Back from Hawaii, leave for Florida tomorrow. Jacksonville is as cold as Seattle right now!
Yeah, but you were in Hawaii ...
Quote:
I did some testing today (on Linux), and I think I have what I need. This is what I did:
If I am following the flow correctly, after the first cat changes the newlines to spaces and saves into a temp file, I can then scan for my keywords to retrieve the individual entries required. On the first two I scan for WX: and EQ: and it returns exactly what I want .
The 3rd time through looking for METERING: I have problems.
Yeah, but you were in Hawaii ... oh I said that already!
Quote:
For some reason it returns the metering lines, plus more that don't match the string.
That's because you're using the bracket expression incorrectly. You've put 'MET' in the bracket expression thinking that will give you lines with 'METERING' in there, but in reality it will give you lines that have an 'M' 'E' OR 'T' in that character position. So you'll get 'Metering' or 'METERING' but you'll also get 'Equipment' and 'EQUIPMENT' and if you have words like 'Time' or 'TUNDRA' or 'The' or you get the picture!
Quote:
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
Because the second bracket expression is for the second character position in that word, so you still could conceivably get things other than just 'METERING' but if you have '[MET][EX]' your combinations for those two character positions are:
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:
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!
Yeah, but you were in ... oh forget it!
Last edited by rwuerth; 02-03-2009 at 06:05 PM..
Reason: (hopefully) clarified some statements.
Yeah, but you were in Hawaii ... oh I said that already!
Yeah, but you were in ... oh forget it!
I needed a good chuckle today! 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!
Quote:
Originally Posted by cfajohnson
You mean it's tolerable?
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!
Hi all,
Let's say I have a script calling for the two variables PA_VALUE and PB_VALUE.
for pa in PA_VALUE
blah blah
do
for pb in PB_VALUE
blah blah
do
I have a text file with two columns of values for PA and PB.
14.5 16.7
7.8 9.5
5.6 3.6
etc etc
I would like to read this... (7 Replies)
Sed command to replace a line in a file using line number from the output of a pipe.
Is it possible to replace a whole line piped from someother command into a file at paritcular line...
here is some basic execution flow..
the line number is 412
lineNo=412
Now i have a line... (1 Reply)
All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed...
I have an input file similar to:
&LOG
&LOG Part: "@DB/TC10000021855/--F"
&LOG
&LOG
&LOG Part: "@DB/TC10000021852/--F"
&LOG Cloning_Action: RETAIN
&LOG Part: "@DB/TCCP000010713/--A"
&LOG
&LOG... (5 Replies)
Hi,
I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :-
./sample.sh: line... (12 Replies)
here is what i want to achieve.. i have a file with below contents
cat fileName
blah blah blah
.
.DROP this
REJECT that
.
--sport 7800 -j REJECT --reject-with icmp-port-unreachable
--dport 7800 -j REJECT --reject-with icmp-port-unreachable
.
.
.
more blah blah blah
--dport 3306... (14 Replies)
my requirement is,
consider a file output
cat output
blah sdjfhjkd jsdfhjksdh
sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf
hellow there
this doesnt look good
et cetc etc
etcetera
i want to replace a line of line number 4 ("this doesnt look good") with some other line
... (3 Replies)
Hi How Are you?
I am doing fine!
I need to go now?
I will see you tomorrow!
Basically I need to replace the entire line containing "doing" with a blank line:
I need to the following output:
Hi How Are you?
I need to go now?
I will see you tomorrow!
Thanks in advance.... (1 Reply)
I am trying to delete lines in archived Apache httpd logs
Each line has the pattern:
<ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL>
This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Hi,
Is there a print option to drop the data 1 line?
Basically the page is too close to the top of the page and I would like to drop it one line automatically, editing the actual data is complicated. (8 Replies)
I'm new to using sed and grep commands, but have found them extremely useful. However I am having a hard time figuring this one out:
Delete every line containing the word CEN and the next line as well.
ie. test.txt
blue
324 CEN
green
red
blue
324 CEN
green
red
blue
to produce:... (2 Replies)