The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-21-2008
Franklin52 Franklin52 is offline
Moderator
 

Join Date: Feb 2007
Posts: 2,471
Place the xml string within single quotes and use an awk variable.
This should work:

Code:
#!/bin/sh

XMLSTRING='<thema xmlns=\"x-schema:df.ase\" uid=\"asd_F\" displayname=\"Jdddf 1\" asd_jg_id=\"6\" asd_jg_id_an=\"F\"/>'

awk -v var="$XMLSTRING" '
  {if ( $0 ~ /4/ ) {
    printf( "%s\n%s\n", $0, var )
  }
  else {
    print $0
  }
}' testfile
Regards
Reply With Quote