[Solved] awk how to parse based on pattern but skip multiple similar lines and accept only single line occurence [closed]

awk ‘ /connection from/{ nr=NR; conn[nr]=$NF; auth_counter[nr]=0; next; } { auth_counter[nr]++; auth_msg[nr]=$NF; } END{ for(i in auth_counter) if(auth_counter[i]==1) print conn[i], auth_msg[i] }’ file x.x.x.x BBB y.y.y.x CCC x.x.x.a ZZZ solved awk how to parse based on pattern but skip multiple similar lines and accept only single line occurence [closed]

[Solved] how to extract word from ps -aux

Since it’s not clear what you’re trying to do: If you expect the following output: yypasswd then do ps -ef | grep yypasswd | awk ‘{print $8}’ if you want the following output: testacc 25124194 2512312620 0 08:00:53 pts/0 0:00 then do ps -ef | grep yypasswd | awk ‘{print $1, $2, $3, $4, $5, … Read more

[Solved] shell – remove numbers from a string column [closed]

You should have been more clearer when you raise the problem. Do not add test cases later You can try this, I have modified the third field to last but one. But credit to @Kaz ~> more test SER1828-ZXC-A1-10002 SER1878-IOP-B1-98989 SER1930-QWE-A2-10301 SER1930-QWE-A2-10301 SER1930-QWS_GH-A2-10301 SER1930-REM_PH-A2-10301 SER1930-REM-SEW-PH-A2-10301 SER1940-REM-SPD-PL-D3-10301 ~> awk -F- ‘BEGIN { OFS=”-” } { sub(/[0-9]/,””,$(NF-1)); … Read more

[Solved] sed, awk, perl or lex: find strings by prefix+regex, ignoring rest of input [closed]

If you won’t have more than one of the pattern on a single line, I’d probably use sed: sed -n -e ‘s%.*https://\([-.0-9A-Za-z]\{1,\}\.[A-Za-z]\{2,\}\).*%\1%p’ Given the data file: Nothing here Before https://example.com after https://example.com and after Before you get to https://www.example.com And double your https://example.com for fun and happiness https://www.example.com in triplicate https://a.bb and nothing here The … Read more

[Solved] Conversion of large .csv file to .prn (around 3.5 GB) in Ubuntu using bash

It’s not clear from your question as you didn’t provide sample input/output we could test against but it SOUNDS like all you’re trying to do is this: $ cat tst.awk BEGIN { split(“7 10 15 12 4″,w) FPAT=”[^,]*|\”[^\”]*\”” } { gsub(/””/,RS) for (i=1;i<=NF;i++) { gsub(/”/,””,$i) gsub(RS,”\””,$i) printf “<%-*s>”, w[i], substr($i,1,w[i]) } print “” } $ … Read more

[Solved] Arithmetic operations using numbers from grep

Assumptions: we want to match on lines that start with the string number we will always find 2 matches for ^number from the input file not interested in storing values in an array Sample data: $ cat file.dat number1: 123 not a number: abc number: 456 We’ll use awk to find the desired values and … Read more

[Solved] PHP exec command is not working with awk command [closed]

As I said in my answer to your previous question, you can fix this easily by using single quotes on the inside. PHP Code <?php $eff=40; $pos=34; $i = ‘hello’; $line=exec(“tail $i.dssp -n $eff | awk -F’ ‘ -v var=$pos ‘{if ($2==var) print FNR}'”); print “$line\n”; ?> Sample Input (hello.dssp): foobar 34 Sample Output: 1 … Read more