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 IamaSherpa 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. vlad9999

    read the contents of a file into a awk variable

    Finally, my program: cat $in_file | awk -v m2_file=$m2_file ' BEGIN {RS="@" ; getline s1 < m2_file ; close(m2_file) ; RS="\n"} { toto=substr($0,12,27) ; gsub(/ *$/,"",toto) titi=substr($0,81,11) tata=substr($0,242,3) s2=s1 gsub("TOTO",toto,s2)...
  2. vlad9999

    read the contents of a file into a awk variable

    Yes, by playing on the RS I simplify the program. BEGIN {RS="@" ; getline s1 < m2_file ; close(m2_file) ; RS="\n"} (the variable m2_file is transmitted with option -v Thank you !!
  3. vlad9999

    read the contents of a file into a awk variable

    That means I have to read the file line by line and concatenate the results ?
  4. vlad9999

    read the contents of a file into a awk variable

    How to store into a awk variable the contents of a small file, which has several lines (obviously without affecting its content - the line breaks, the successive spaces, etc) ? In fact I must make with awk the equivalent of cat file | sed "s|TOTO|$toto|g;s|TITI|$titi|g;s|TATA|$tata|g" the...
  5. vlad9999

    complex modification file - awk ?

    then we waited (for the example with files t1, list_file): NR=1 FNR=1 one NR=2 FNR=2 two NR=3 FNR=3 three NR=4 FNR=1 ident1 NR=5 FNR=2 ident2
  6. vlad9999

    complex modification file - awk ?

    otherwise the station is an IBM - AIX, oslevel 5.3.0.0
  7. vlad9999

    complex modification file - awk ?

    I concluded too quickly that only the first word is taken for the file passed with "|" + "-". In fact the problem is different. With file t1 and list_file yields: t1: one two three list_file: ident1 ident2 > cat t1 | awk '{print "NR="NR" FNR="FNR" "$0}' - list_file NR=1 FNR=1 one NR=2 FNR=1...
  8. vlad9999

    complex modification file - awk ?

    Anyway this is beside the point, and then I have the solution to my problem. This must be an old version of awk ... ..nawk behaves the same way..
  9. vlad9999

    complex modification file - awk ?

    my awk does not recognize these options
  10. vlad9999

    complex modification file - awk ?

    I confess I do not know, nor know how to find it..
  11. vlad9999

    complex modification file - awk ?

    This is not on the original topic, but just for accuracy, after testing, the "-" causes only reading the first word of the file !
  12. vlad9999

    complex modification file - awk ?

    waw! with all these examples, I see otherwise awk now. THANK YOU
  13. vlad9999

    complex modification file - awk ?

    I tested and the result is almost good.ident3 1635 00000000 miscellaneous informations ident3 1635 00000000 miscellaneous informations ident1 1635 00000001 miscellaneous informations ident1 1635 00000001 miscellaneous informations ident4 1635 00000000 miscellaneous informations ident4 1635...
  14. vlad9999

    complex modification file - awk ?

    Whatever_file file also contains other ident-s we do not want:ident3 1635 miscellaneous informations ident3 1635 miscellaneous informations ident1 1635 miscellaneous informations ident1 1635 miscellaneous informations ident4 1635 miscellaneous informations ident4 1635 miscellaneous informations...
  15. vlad9999

    complex modification file - awk ?

    So then (CH1="0ZZZ", CH2="9ZZZ", CODE0="1635"): cat $work_file | sort | awk "/ $CH1/,/ $CH2/" | \ awk -v CODE0=$CODE0 -v CH1=$CH1 '$2==CH1{n=$3} {sub(CODE0,CODE0""n)}1' \ | egrep -v " $CH1| $CH2"
  16. vlad9999

    complex modification file - awk ?

    No, name is obtained with cat -n to numbering the extracted dossiers in the file of dossiers to extract. That is how I insert the two lines "start" and "end" in the original file: cat $list_file | sed "s|$| 0ZZZ|g" | cat -n | awk '{printf "%7s %4s %08d\n",$2,$3,$1}' \ >> $work_file cat...
  17. vlad9999

    complex modification file - awk ?

    Now my whole script is finished. My question on awk was part of an script whose mission was to extract dossiers from a file (we has into an other file the list of dossiers to extract). Each dossiers in the file is identified with an identifier ident1, ident2 ... and can have multiple lines. To...
  18. vlad9999

    complex modification file - awk ?

    Good to know! Both work great!
  19. vlad9999

    complex modification file - awk ?

    Sorry, it's true, in a first moment I had not noticed this, but the part miscellaneous informations contain successive spaces.
  20. vlad9999

    complex modification file - awk ?

    Finally I use perl, because awk converts several successive spaces into one. By cons, how to pass variables to the perl program (the equivalent of -v var = $ var for awk) ?

Part and Inventory Search

Back
Top