Awk 忽略特定列编号后的空格

Awk 忽略特定列编号后的空格,awk,aix,text-processing,Awk,Aix,Text Processing,大家好,我有以下数据 61684 376 23 106 38695633 1 0 0 -1 /C/Program Files (x86)/ 16704 root;TrustedInstaller@NT:SERVICE root;TrustedInstaller@NT:SERVICE 0 1407331175 1407331175 1247541608 8634 416 13 86 574126 1 0 0 -1 /E/KYCImages/ 16832 root;kycfinal@CGKYCAPP

大家好,我有以下数据

61684 376 23 106 38695633 1 0 0 -1 /C/Program Files (x86)/ 16704 root;TrustedInstaller@NT:SERVICE root;TrustedInstaller@NT:SERVICE 0 1407331175 1407331175 1247541608
8634 416 13 86 574126 1 0 0 -1 /E/KYCImages/ 16832 root;kycfinal@CGKYCAPP03 root;None@CGKYCAPP03 0 1406018846 1406018846 1352415392
60971 472 22 86 38613076 1 0 0 -1 /E/KYCwebsvc binaries/ 16832 root;kycfinal@CGKYCAPP03 root;None@CGKYCAPP03 0 1390829495 1390829495 1353370744
1 416 10 86 1 1 0 0 -1 /E/KycApp/ 16832 root;kycfinal@CGKYCAPP03 root;None@CGKYCAPP03 0 1411465772 1411465772 1351291187
现在我使用以下代码:

awk 'BEGIN{FPAT = "([^ ]+)|(\"[^\"]+\")"}{print $10}' | awk '$1!~/^\/\./' | sort -u | sed -e 's/\,//g' | perl -p00e 's/\n(?!\Z)/;/g' filename
我得到这个输出

/C/Program;/E/KycApp/;/E/KYCImages/;/E/KycServices/;/E/KYCwebsvc
但是,我需要从$10开始输出,直到再次遇到“/”,基本上我想忽略第10列中的任何空格,直到遇到“/”。 可能吗

期望输出为

/C/Program Files (x86)/;/E/KycApp/;/E/KYCImages/;/E/KycServices/;/E/KYCwebsvc binaries/
用单目瞪口呆

awk 'BEGIN{ FPAT="/[^/]+/[^/]+/"; PROCINFO["sorted_in"]="@ind_str_asc"; IGNORECASE = 1 }
     { a[$1] }END{ for(i in a) r=(r!="")? r";"i : i; print r }' filename
输出(没有
/E/KycServices/;
-因为它不在您的输入中):


在单awk中也尝试以下操作

awk '{match($0,/\/.*\//);VAL=VAL?VAL ORS substr($0,RSTART,RLENGTH):substr($0,RSTART,RLENGTH)} END{num=split(VAL, array,"\n");for(i=1;i<=num;i++){printf("%s%s",array[i],i==num?"":";")};print""}'  Input_file

awk'{match($0,/\/.*\/);VAL=VAL?VAL-ORS substr($0,RSTART,RLENGTH):substr($0,RSTART,RLENGTH)}END{num=split(VAL,array,“\n”);for(i=1;ii如果您有
grep
-o
选项,看起来这就是您想要的…
grep-o'/[^.].*/'filename | sort-u | paste-sd';
…您的示例数据应该包含行,以显示为什么需要
awk'$1!~/^\/\./'
sed-e's/\,//g'
paste-sd';'在AIX中不起作用,因此我使用perl-p00e's/\n(?!\Z)/;/g'我需要awk'$1!~^\/\./'来忽略任何在开头加“/”的内容另外,grep-o在AIX中不起作用。所以需要一些其他的东西。单个命令
perl-lne'($p)=/(\/[^.].*\/)/;$h{$p}=1;END{print join”;“,key%h}”文件名
如何?输出中有
/E/KycServices/;
。我在输入中没有看到它
awk '{match($0,/\/.*\//);VAL=VAL?VAL ORS substr($0,RSTART,RLENGTH):substr($0,RSTART,RLENGTH)} END{num=split(VAL, array,"\n");for(i=1;i<=num;i++){printf("%s%s",array[i],i==num?"":";")};print""}'  Input_file
awk '{
        match($0,/\/.*\//);
        VAL=VAL?VAL ORS substr($0,RSTART,RLENGTH):substr($0,RSTART,RLENGTH)
     }
        END{
                num=split(VAL, array,"\n");
                for(i=1;i<=num;i++){
                                        printf("%s%s",array[i],i==num?"":";")
                                   };
                print""
           }
    '    Input_file
awk '{
        match($0,/\/.*\//); ##Using match functionality of awk which will match regex to find the string in a line from / to \, note I am escaping them here too.
        VAL=VAL?VAL ORS substr($0,RSTART,RLENGTH):substr($0,RSTART,RLENGTH) ##creating a variable named VAL here which will concatenate its own value if more than one occurrence are there. Also RSTART and RSTART are the variables of built-in awk which will be having values once a match has TRUE value which it confirms once a regex match is found in a line.
     }
        END{ ##Starting this block here.
                num=split(VAL, array,"\n");##creating an variable num whose value will be number of elements in array named array, split is a built-in keyword of awk which will create an array with a defined delimiter, here it is new line.
                for(i=1;i<=num;i++){ ##Starting a for loop here whose value will go till num value from i variable value 1 to till num.
                                        printf("%s%s",array[i],i==num?"":";") ##printing the array value whose index is variable i and second string it is printing is semi colon, there a condition is there if i value is equal to num then print null else print a semi colon.
                                   };
                print"" ##print NULL value to print a new line.
           }
    '  Input_file    ###Mentioning the Input_file here.