Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. Baraka69

    FIlter double lines

    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 ...
  2. Baraka69

    record too long

    I agree to vlad, the limitations on standard awk are quite restrictive. I had a similar problem and using nawk instead solved my problem.
  3. Baraka69

    Searching in fixed locations with AWK...

    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...
  4. Baraka69

    Counting links in html page

    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...
  5. Baraka69

    Counting links in html page

    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...
  6. Baraka69

    Counting links in html page

    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...
  7. Baraka69

    Counting links in html page

    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 = &quot;http://www.mytest.com/sample.htm&quot;>Sample</A> # <a...
  8. Baraka69

    Counting links in html page

    Could you supply a sample input file? Just copy&paste the HTML source code you are trying to parse.
  9. Baraka69

    setting FS to &quot;

    Hi SotonStu, I guess you want to solve your problem counting HTML href's with the FS = &quot;\&quot;&quot;, 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 = &quot;\&quot;&quot; too.
  10. Baraka69

    Counting links in html page

    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=&quot;myLink&quot;>myText</a> } /href=/ { # a line contains 'href=' for ( i=1; i<=NF; i++ ) { # for each field in that...
  11. Baraka69

    print output to same file

    OK, now I understand - thanks for clearing that up Vlad.
  12. Baraka69

    print output to same file

    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...
  13. Baraka69

    print output to same file

    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 &quot;/&quot; with &quot;-&quot; can be done using...
  14. Baraka69

    cannot see the error, need help

    Hi sampsonr, your idea sounded great and did work for me - thanks a lot!
  15. Baraka69

    cannot see the error, need help

    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...
  16. Baraka69

    cannot see the error, need help

    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 &quot;access_log.gz&quot;. In order to get a &quot;per file&quot; output I use...
  17. Baraka69

    Piping parameters to awk

    On HP-UX-11.00 both work: awk -v myIP=${ip_address} 'BEGIN{print myIP}' and awk -v myIP=$ip_address 'BEGIN{print myIP}' I don't know about Linux ...
  18. Baraka69

    Piping parameters to awk

    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 &quot;sed & awk&quot;, page 13)
  19. Baraka69

    Piping parameters to awk

    Then the &quot;-v&quot; should do the trick. Have you tried that?
  20. Baraka69

    Piping parameters to awk

    try using either (a) the &quot;-v&quot; option e.g. awk -v myIP=$ip_address '{if ($1 == myIP) print $3}' (b) the enviroment variable e.g. awk '{if ($1 == ENVIRON[&quot;ip_address&quot;]) print $3}' A simple script to check what's available for you in your enviroment array...

Part and Inventory Search

Back
Top