Search Results

Search: Posts Made By: james2009
8,526
Posted By rdrtx1
line="01/05/2017 10:23:41 [ABCD-22357$0]:...
line="01/05/2017 10:23:41 [ABCD-22357$0]: file.log.38: database error, MODE=SINGLE, LEVEL=critical, STATE: 01170255 (mode main"

echo "$line" | perl -e 'foreach my $str (split(/ /, <>)) {if...
8,526
Posted By MadeInGermany
The perl code print $1 if /STATE:\s+(\d+)/; ...
The perl code
print $1 if /STATE:\s+(\d+)/;
works on a line that is in $_.
8,526
Posted By durden_tyler
In a Perl program, you'd accept the input log...
In a Perl program, you'd accept the input log file name (if so desired), open it, loop/process through it and then close it.
Here's a short program called "process_log.pl".
Hopefully the inline...
1,824
Posted By RavinderSingh13
Hello james2009, Could you please go...
Hello james2009,

Could you please go through the following explanation and let me know if this helps you.

awk '
!a[$2]{ ## checking if an array named a whose index is...
1,824
Posted By MadeInGermany
This one compares the current line with the...
This one compares the current line with the previous line
awk '
function prt() { if (NR>1) print p1, p2 }
{ if ($2!=p2) { prt(); p1=$1; p2=$2 } else { p1=(p1 "," $1) } }
END { prt() }
' inputfile
1,824
Posted By RavinderSingh13
Hello james2009, Could you please try...
Hello james2009,

Could you please try following and let me know if this helps you.

awk '!a[$2]{b[++i]=$2} {a[$2]=a[$2]?a[$2] "," $1:$1} END{for(j=1;j<=i;j++){print b[j],a[b[j]]}}' Input_file
...
4,257
Posted By drl
Hi. Also: grep -E -o '[0-9]{6}' <file> ...
Hi.

Also:
grep -E -o '[0-9]{6}' <file>

producing:
123456
333444
111111
444444
555555
on a system:
OS, ker|rel, machine: Linux, 3.16.0-4-amd64, x86_64
Distribution : Debian 8.4...
1,863
Posted By RudiC
Any ideas/thoughts/attempts from your side? ...
Any ideas/thoughts/attempts from your side?

---------- Post updated at 12:31 ---------- Previous update was at 12:30 ----------

Howsowever, try while read FN1; do read FN2; echo mv $FN1 $FN2;...
1,272
Posted By RudiC
If it's always two consecutive rows, this simple...
If it's always two consecutive rows, this simple one might do:awk '{printf "%s;", $0; getline; print}' file
123456,22222,John,0,xyz;234567,22222,John1,1,cde...
1,272
Posted By Corona688
# -F, means "split columns on comma", so it knows...
# -F, means "split columns on comma", so it knows that 22222 is column 2, or $2.
# $ means column in awk and has absolutely nothing to do with shell variables.
#
# The single quote begins a single...
1,223
Posted By Don Cragun
Note that neither RudiC nor Akshay Hegdes...
Note that neither RudiC nor Akshay Hegdes provided suggestions that printed a header because the output you said you wanted did not include a header!

Reformatting RudiC's code, adding code to...
1,223
Posted By Akshay Hegde
I skipped header, you can set i=1 in END block.
I skipped header, you can set i=1 in END block.
1,223
Posted By RudiC
If order doesn't matter, tryawk 'NR>1...
If order doesn't matter, tryawk 'NR>1 {T[$1]=T[$1] "," $2} END {for (t in T) print t, substr(T[t],2)}' OFS=: file
5550:3282,9465,7607
7064:4456
8781:4319,2332,0269
Showing results 1 to 13 of 13

 
All times are GMT -4. The time now is 02:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy