• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

use of variables in awk to search for pattern from a file

 
Greenhorn
Posts: 24
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need to extract all the content between two strings stored in two variables "startstring" and "endstring"



The above code is not working with variables. It works when actual string values are used as pattern.



Can someone help me to use these two variables in awk.

Thanks.

Regards,
Jean
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unix shells have several different "quote" characters, and each one has a special meaning. For example, the backtick "quotes" cause the quoted expression to be run as a shell command.

Unfortunately, the single-quote "quotes" mean "don't expand shell variables". Use the double-quote "quotes" instead. Or, in other words:


It's a convention that environment variables should be named all in uppercase, BTW. However, that's just a convention, so using lower-case names won't actually hurt anything.
reply
    Bookmark Topic Watch Topic
  • New Topic