在用awk问题 [英] problem in using awk

查看:109
本文介绍了在用awk问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不可能解决这个问题。当我执行这个节目,我得到以下错误
7号线:在寻找匹配的意外EOF'''

  A = 115292a1504606846976ULL
B = 2
如果[$ B=2];然后
VAR1 ='回声$ A | awk的-FU'\\
{
VAR2 =`回声$ VAR1 | AWK -F一
{打印,$ 2}'`
} \\
科幻

更新:其他,最近关闭的问题。

要更具体,这是我的项目code

 如果[$ FORMAT=java的];然后
        猫$ INPUT_FILE | AWK -F:'\\
                / ^ $ / {打印} \\
                /^\\/\\/.*/ {打印$ 0} \\
                /:字符串:/ {打印公共静态最后的字符串$ 1=$ 3; } \\
                /:字符:/ {打印公共静态最后的字符$ 1=$ 3; } \\/:ullong:/ {打印公共静态最后长$ 1=$ 3; } \\
                /:ULONG:/ {打印公共静态最终诠释$ 1=$ 3; } \\
                /:长:/ {打印公共静态最终诠释$ 1=$ 3; } \\
        '>> $ CONST_FILE
网络连接;

现在我需要截断$ 3(该值实际上是从另一个文件中读取)分为两部分(仅限于ullong)。让说

  $ 3 = 1256985361455ULL

我需要截断到1256985361455和ULL。 (只有当它被ullong)
请帮我出这个问题。

我尝试使用以下内的另一个AWK,但在混乱中结束了。

  /:ullong:/ {打印公共静态最后长$ 1=$ 3; } \\


解决方案

如果你期望的$值3的ullong记录像1256985361455ULL,那么

  /:ullong:/ {
    子(/ ULL $ /,,$ 3)
    打印公共静态最后长$ 1=$ 3;
}

i couldn't solve this. when i execute this program i get the following error " line 7: unexpected EOF while looking for matching `'' "

a=115292a1504606846976ULL
b=2
if [ "$b" = "2" ]; then
var1=`echo $a | awk -F"U" '\
{
var2=`echo $var1 | awk -F"a"
{print " "$2}'`
}\
fi

Update: from other, recently closed question

To be more specific, this is my project code

if [ "$FORMAT" = "java" ]; then
        cat $INPUT_FILE | awk -F":" '\
                /^$/ { print "" }\
                /^\/\/.*/ { print "     "$0}\
                /:string:/ { print "    public static final String "$1" = "$3";" }\
                /:char:/   { print "    public static final char "$1" = "$3";" }\

/:ullong:/ { print "    public static final long "$1" = "$3";" }\
                /:ulong:/  { print "    public static final int "$1" = "$3";" }\
                /:long:/   { print "    public static final int "$1" = "$3";" }\
        ' >> $CONST_FILE
fi;

Now i need to truncate $3 (this value is actually read from another file) into two parts(only for ullong). lets say

$3=1256985361455ULL

i need to truncate into 1256985361455 and ULL. (only when it is ullong) please help me out in this issue.

i tried using another awk inside the the following, but ended up in chaos.

/:ullong:/ { print "    public static final long "$1" = "$3";" }\

解决方案

If you expect the value of $3 for the ullong records to be something like "1256985361455ULL" then

/:ullong:/ { 
    sub(/ULL$/, "", $3)
    print "    public static final long "$1" = "$3";" 
}

这篇关于在用awk问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆