AWK / shell / bash variable issue summary

2010-05-14  来源:本站原创  分类:OS  人气:150 

awk shell environment variables used in one: "'$ var'"
This kind of presentation you need to change with the 'habit of enclosed awk program is a foreigner commonly used form. Such as:
var = "test"
awk 'BEGIN (print "' $ var '")'
The wording of the actual is a two brackets into the single constant in parentheses, passed to the awk.
If the var contains a space, in order not to space as a sub-shell grid operator, it should be used as follows:
var = "this is a test"
awk 'BEGIN (print "'" $ var "'"}'
2: '"$ var"'
This style of writing, on a similar. If the variable contains spaces, then become a '"" $ var ""' more reliable.
3. The enclosed awk program''to "", use "$ var"
Such as:
$ Var = "this is a test"
awk 'BEGIN (print "$ var") "
This is because the "" in $ are special characters, and in the''ordinary characters in $.
4: export variable, use the ENVIRON ["var"] form
Such as:
$ Var = "this is a test"; export $ var
awk 'BEGIN (print ENVIRON ["var"])'
5: Of course you can use the-v option such as:
$ Var = "this is a test"
awk-vnvar = "$ var" '(print nvar)'
This brings the definition of system variables into awk variable.

2. In awk the value attached to the system variables

eval $ (awk 'BEGIN (print "a = ggg b = 3")')

eval $ (grep-v '#' "$ CONFFILE" | awk 'BEGIN (FS ="|"} NR =="'$ var_list' "(printf (" HOST = \ "% s \" MAX = \ "% s \ "EMAILLIST = \"% s \ "PHONE = \"% s \ "\ n", $ 1, $ 2, $ 3, $ 4)) ')

相关文章
  • AWK / shell / bash variable issue summary 2010-05-14

    awk shell environment variables used in one: "'$ var'" This kind of presentation you need to change with the 'habit of enclosed awk program is a foreigner commonly used form. Such as: var = "test" awk 'BEGIN (print "' $ var '"

  • [Change] SHELL (BASH) 13 Q 2010-09-17

    1) Why is called shell ? What is the introduction before the shell , Let us re-examine the relationship between user and computer system : Figure (FIXME) We know that the operation can not leave the computer hardware, but the user can not be driven d

  • (R) Oracle character set issue summary 2011-02-25

    Article summary is very good, go , For later viewing . Oracle character set issue summary 2005-10-08 14:57 Author: vstonet Source: daisy Forum Editor: Wang Yuhan <! - Advertising -> <! - Please check block file -> <! - Please check block fi

  • From DOS to switch to mysql: environment variable issue 2011-01-05

    From DOS to switch to mysql: environment variable issue In WindowsXP, open DOS, by typing the command "mysql-u root-p" switch to mysql, the switch fails, as follows: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp.

  • From DOS to switch to the mysql: environment variable issue 2011-01-05

    From DOS to switch to the mysql: environment variable issue In WindowsXP, open DOS, by typing the command "mysql-u root-p" switch to the mysql and the switch fails, as follows: Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Micr

  • Oracle character set issue summary 2010-02-05

    Staff will consult oracle database character set-related issues, such as different databases to do data migration, data exchange with other systems, often as a result of migration of different character set failure or database data garbled. Now I wil

  • awk shell function to call the method 2010-05-15

    The foreigner to see the forum: http://www.unix.com/shell-programming-scripting/49026-external-function-awk.html Hi. Here is a script that attempts various methods of calling functions: Code: <!-- ntstart-->#!/usr/bin/env sh # @(#) s1 Demonstrate fu

  • Oracle Database issue summary (part of the switched network) 2010-06-03

    1.Oracle basic types of databases that when you create a data table in the database, you need to define the type of all fields in the table. ORACLE There are many kinds of data types to meet your needs. Some data types are divided into: character, nu

  • Linux SHELL Bash 2009-02-24

    Bash 网站 : http://tiswww.case.edu/php/chet/bash/bashtop.html bash 是一个为GNU项目编写的Unix shell.它的名字是一系列缩写:Bourne-Again SHell - 这是关于Bourne shell(sh)的一个双关语(Bourne again / born again).Bourne shell是一个早期的重要shell,由Stephen Bourne在1978年前后编写,并同Version 7 Unix一起发布.bas

  • [转]linux shell bash 比较操作 2012-02-24

    整数比较 -eq 等于,如:if [ "$a" -eq "$b" ] -ne 不等于,如:if [ "$a" -ne "$b" ] -gt 大于,如:if [ "$a" -gt "$b" ] -ge 大于等于,如:if [ "$a" -ge "$b" ] -lt 小于,如:if [ "$a" -lt "$b"

  • LINUX 常用命令awk SHELL学习第四弹 2012-04-17

    惭愧啊,昨天虽然工作到12点,但是没有抽出时间来学习shell,实在不应该,学习应该是一个持续的过程,半途而废肯定是学不好shell的 今天自己准备学习命令提示符下的又一神器,awk 刚开始的时候不知道awk是个什么东西,只是知道类似java中的split,按照一定格式进行分列,然后打印其中某一列.... 今天看到权威的解释为:Awk将传递进来的每行输入都分割成域. 默认情况下, 一个域指的就是使用空白分隔的一个连续字符串, 不过我们可以修改属性来改变分隔符. Awk将会分析并操作每个分割域.

  • java.J2EE basic issue summary 2010-03-29

    1, Java-based areas: 1, scope public, protected, private, and not write the difference between public in other packages in the class can also quote, protected confined to a single package of classes, private only they can use. Do not write the same t

  • SQL2000 issue summary 2010-04-03

    December 5, 2007 at 02:50 PM2007-11-26 21:00 After a night of hard work has finally succeeded during the connection quite a few detours here to share my little experience First, prepare the environment Windows XP + JDK5.0 + Microsoft SQL Server 2000

  • java (Web) in a relative path, absolute path issue summary 2010-04-09

    1. Basic understanding of the concept Absolute path: absolute path is your home page file or directory on your hard disk real path, (URL and the physical path) example: C: \ xyz \ test.txt test.txt file represents the absolute path. http://www.sun.co

  • CDT Debugging issue summary 2010-06-09

    CDT Debug is dependent on the eclipse-cpp on gdb's support for the installation of mingw users, as long as installed in C: \ MINGW and extract the gdb to the directory, the default button configuration will automatically link to the gdb debugger runn

  • Bash example, the first part-Bourne again shell (bash) Basic programming 2010-06-17

    By learning how to use the bash scripting language programming, will allow the day to day Linux is more interesting and productive interaction, but also can use those who are already familiar with and like the standard UNIX concepts (such as pipeline

  • arcgis server 9.3 issue summary 2010-06-30

    Beginning with the 9.3 version of the meal problem. 1. On the issue of landing - Turn off Windows Firewall - Sign som, to see if the user password is correct - Changed a bit, tools - "folder options -" Use simple file sharing - Whether the user

  • Mask layer GreyBox issue summary 2010-08-11

    A recent project used the greybox, using the many problems encountered in the process, to sum up: 1. Close method is called the mask layer: <a href="#"> My Close Button </ a> 2. Pop-up mask layer: <a href="http://google.com/&

  • package global variable issue 2011-02-27

    ORA-04061: existing state of has been invalidated . Session 1: Session_1> create package pck is 2 a number; 3 procedure print_a; 4 end pck; 5 / Package created. Session_1> create or replace package body pck is 2 procedure print_a is 3 begin 4 dbms_o

  • the oracle jdbc jar version issue summary package 2011-06-13

    From oracle8 to oracle11, JDBC driver package directory are different, supported JDK versions are different. Example: large data storage in terms of the clob. First, the system architecture: spring + hibernate + webwork 1, the program used to connect