Awk help backspace

From: Raja (sura_12_at_yahoo.com)
Date: 03/29/04

  • Next message: Matthias Czapla: "Re: preventing program from being swapped out"
    Date: 28 Mar 2004 14:15:11 -0800
    
    

    Why is my program not working? Earlier the data file was delimited
    with "|"(Pipe) and the program worked. But now we changed the
    delimiter to X and a backspace character. I have tried this by
    replacing the "|" in my programm as follows and it does not work. Any
    help would be greatly appreciated.

    Regards,
    Raja
    ********************************************************
    awk -F"X\b" '{
    if ( NF < 6 ){
    newline=$0
    oldline = newline
    getline
    newline = substr(oldline,1,length(oldline))";" $0
    while (substr(newline,length(newline),1) != "X^H"){
    oldline = newline
    getline
    newline = substr(oldline,1,length(oldline))";" $0
    }
    print newline
    next
    }
    else print $0
    }' test.txt

    **************************************************
    Earlier version with pipes which worked
    -----------------------------------------
    awk -F"|" '{
    if ( NF < 6 ){
    newline=$0
    oldline = newline
    getline
    newline = substr(oldline,1,length(oldline))";" $0
    while (substr(newline,length(newline),1) != "|"{
    oldline = newline
    getline
    newline = substr(oldline,1,length(oldline))";" $0
    }
    print newline
    next
    }
    else print $0
    }' test.txt
    --------------------------------------------


  • Next message: Matthias Czapla: "Re: preventing program from being swapped out"

    Relevant Pages

    • Re: using default values on <Enter> with no input
      ... but as newline is entered. ... how to get cin to work if there isn't any actual input. ... I think you want to look at getline. ... Put the input into a string object and either parse it manually or you ...
      (comp.lang.cpp)
    • Awk help backspace
      ... oldline = newline ... newline = substr)";" $0 ...
      (comp.unix.admin)
    • Awk help backspace
      ... oldline = newline ... newline = substr)";" $0 ...
      (comp.unix.misc)
    • Re: How to change delineator in iostream?
      ... >whitespace or a newline. ... How do I change the delineator, for example, ... Use getline() instead of the>> operator. ... terminator character in place of the default '\n'. ...
      (comp.lang.cpp)
    • Re: using and in echo command
      ... echo command doesn't know to translate "\n" as newline ... and "\t" as tab. ... how can I print newline without a "real" newline in the script? ...
      (comp.unix.programmer)