would it not be possible to simply assign a variable to the current line and then compare it with the next line?
something in the style of:
if $0 == lastLine {next}
else {print}
lastLine = $0
ps: I know that this code will not work, it's not a sample code, but it's to give you an idea ...
I believe CaKiwi got an extra "s" in, so it should actually read:
'/^....Job /'
I really wonder, why your example does not work for you, because it does for me ... your pattern matches exactly the desired line in your example ... that is really odd.
have a look at relative...
Regarding the sorting part, sure can it be done!
Type "man sort" and simply pipe the output through sort.
Sorting is a wide field and you will have alot of fun at that, I'm sure.
One (maybe) useful hint is what I used in my script at one point:
# how to call a system shell command...
One last thing (then I'll go back to my regular work *g*) my solution in using one big summary or multiple summaries works perfectly well for subdirectories as well.
I use it to go through all my log files that are stored in a filesystem that uses something like:
/year/month/day/logfiles...
Re-reading the discussion I would like to point out to SotonStu, that your sample HTML code is not actually good HTML, that's why my first script wouldn't work and also why the "cnn.com page" solution failed.
Your code has a space between the "href" and the equal sign and...
While you guys progressed in the solution(s) I worked on my own little solution. Since I got it working and it's there I'll let you take a look, even though it's too late:
BEGIN {
# now works with different style HTML e.g.
# <A HREF = "http://www.mytest.com/sample.htm">Sample</A>
# <a...
Hi SotonStu,
I guess you want to solve your problem counting HTML href's with the FS = "\"", but I think that's not necessary really, see my answer to your other question. Of course you could solve the problem using the FS = "\"" too.
There might be more elegant solutions, but I gues that will work:
BEGIN {
# count HTML href tags
# assuming correct HTML syntax e.g. <a href="myLink">myText</a>
}
/href=/ {
# a line contains 'href='
for ( i=1; i<=NF; i++ ) {
# for each field in that...
FILENAME works on the tests I made on HP-UX-11.00.
You are absolutely right that reading everything into an array depends on file size. Drawback is that you use massive ressources. But then the ownership of the original is unchanged. Creating a new file and moving it to the original might...
I'm not sure if I completely misunderstood the problem, but as I understand it there is a way to write output to the same file with awk. Simply read the file into an array and output during END into FILENAME. Isn't that right?
Also substituting "/" with "-" can be done using...
Hi vlad,
thanks for the quick reply. You are right on both accounts, the one parameter for gzcat and the space in front of the -v. But (excuse me for pointing this out) the variables are in my example and they do contain all the information to clarify that.
if [ $2 ]; then...
I am writing a script that calls an awk script and takes 2 arguments:
argument #1 is a directory
argument #2 is a filter
The awk script performs some statistical operations. The input file(s) are gzip-ed files called "access_log.gz". In order to get a "per file" output I use...
Regarding the question 'what's nawk?':
Revised awk, offering more support for writing larger programs and tackling general-purpose programming problems. This new version, with minor improvements, is now codified by the POSIX standard. (from O'Reilly's "sed & awk", page 13)
try using either
(a) the "-v" option
e.g.
awk -v myIP=$ip_address '{if ($1 == myIP) print $3}'
(b) the enviroment variable
e.g.
awk '{if ($1 == ENVIRON["ip_address"]) print $3}'
A simple script to check what's available for you in your enviroment array...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.