Search Results

Search: Posts Made By: alex2005
1,300
Posted By vgersh99
a but convoluted and could be improved, but it's...
a but convoluted and could be improved, but it's a start.
awk -f alex.awk file1 file2 where file1 is your 'command output', file2 is the other file and alex.awk is:

BEGIN{ new="-new"}
FNR==NR {...
2,634
Posted By MadeInGermany
I think the question was about post-processing...
I think the question was about post-processing stderr.
This is not trivial.
The command 2> >( post-command > error.log ) is one method.
There is also the classic { command 2>&1 >&3 | post-command...
2,634
Posted By bakunin
Actually the way you presented your problem you...
Actually the way you presented your problem you were writing into a a file - "error.log". You just happened to redirect stderr to point to that file.

You might picture UNIX processes (running...
2,634
Posted By bakunin
I am not sure what exactly you want to do, but in...
I am not sure what exactly you want to do, but in this case you can simply test for the existence of the file(s) and then construct your own error message:

for i in 1 2 3 4 5 6 7 8 ; do
if [...
2,634
Posted By MadeInGermany
If you have single lines in a loop you do not...
If you have single lines in a loop you do not need another loop within
for i in {1..8} ; do ls -al file$i 2> >( read line; echo "$(date): ${line}" >> error.log ) ; done
It is more efficient to have...
1,283
Posted By Scrutinizer
Perhaps this : function pr_sum (txt,arr,end,...
Perhaps this :

function pr_sum (txt,arr,end, i) {
print txt
for (i in arr)
print i, arr[i] " records"
print end
}


FNR == 1 {
if (NR>FNR) {
pr_sum(file "...
1,283
Posted By Scrutinizer
Hi alex2005, see if this adaptation works for...
Hi alex2005, see if this adaptation works for you:

function pr_sum (txt,arr,end, i) {
print txt
for (i in arr)
print i, arr[i] " records"
print end
}

FNR == 1 {
if (NR>FNR)...
17,312
Posted By wisecracker
This is a demonstration longhand using 'eval' OSX...
This is a demonstration longhand using 'eval' OSX 10.12.3, default bash terminal.
It shows how to create a new variable on the fly and how to extract its contents:-
Last login: Mon Feb 13 09:41:28...
17,312
Posted By Chubler_XL
Using bash you can try: declare...
Using bash you can try:

declare ${var2}Value01=$(command 01)
declare ${var2}Value02=$(command 02)

or

printf -v ${var2}Value01 "%s" $(command 01)
printf -v ${var2}Value02 "%s" $(command 02)...
17,312
Posted By wisecracker
I can honestly say I have no idea what you are...
I can honestly say I have no idea what you are trying to do.
There are many errors:-
"$var2Value01=$(command 01)"
"$var2Value02=$(command 02)"
Should be:-
var2Value01=$(command 01)...
17,312
Posted By Don Cragun
In addition to what bakunin has already said,...
In addition to what bakunin has already said, please consider the following...

I am having difficulty understanding what you are trying to do. The shell command language defined by the POSIX...
17,312
Posted By bakunin
This is correct, but maybe in a different way...
This is correct, but maybe in a different way than you may have thought.

The shell parses the commandline in several distinct steps and one of these steps is the "expansion" of variables - that...
2,243
Posted By Don Cragun
The spacing in your output is inconsistent and it...
The spacing in your output is inconsistent and it would have helped if you had explicitly stated that you wanted to remove a trailing period, if present, from each word present in lines being joined;...
3,089
Posted By Don Cragun
If you don't mind reversing the order of the...
If you don't mind reversing the order of the output of the two sections of your output and don't mind a random order of reporting of boxes and items missing from boxes, you could try something like:...
1,388
Posted By Yoda
Try:- awk ' /Time_result/ && $3 > 50...
Try:-
awk '
/Time_result/ && $3 > 50 {
t_flag = 1
next
}
/SELECT/ {
s_flag = 1
}
/^#/ && s_flag {
...
4,320
Posted By MadeInGermany
With awk it looks simpler: ls -r | awk -F_...
With awk it looks simpler:
ls -r | awk -F_ '/\.xml$/ && $1!=p1 {print; p1=$1}'
2,221
Posted By Chubler_XL
Nice solution RudiC! You can set TZ for your awk...
Nice solution RudiC! You can set TZ for your awk process like this:

TZ=GMT-3 awk -F"-" '
...
2,221
Posted By RudiC
You're adding arbitrary 17 hours - why should it...
You're adding arbitrary 17 hours - why should it advance to 100000 next day (unless you are at 170000)?

Tryawk -F"-" '

function strftime(FMT,SECS) {("date \"+" FMT "\" -d@" SECS) | getline...
2,159
Posted By Don Cragun
Building on top of Chubbier_XL's code and...
Building on top of Chubbier_XL's code and incorporating MadeInGermany's suggestion:
awk '
NR > 1 {if (key == ($1 " " $2) && t5 == int(t5) && $5 == int($5) &&
(t5 + 1) == $5) {
t3 = $3...
2,159
Posted By Don Cragun
As long as all of the data in the fields in...
As long as all of the data in the fields in question are written with a decimal point and one digit after the decimal point, you don't need to look for the decimal point. You could just check if the...
2,159
Posted By MadeInGermany
If x ~ ".0$" is to be an integer test, then...
If x ~ ".0$" is to be an integer test, then should be x ~ "\.0$" or x ~ "[.]0$" or better the speaking x==int(x).
2,159
Posted By RudiC
What about 27.30, then? I'd prefer the int($5)...
What about 27.30, then? I'd prefer the int($5) way.

---------- Post updated at 12:18 ---------- Previous update was at 12:16 ----------



Wasn't the first condition $1 and $2 be the key?
2,159
Posted By Scrutinizer
Presumably, besides the condition that column $5...
Presumably, besides the condition that column $5 an $6 are integers (technically 27.0 is not an integer, but you seem to mean numbers that end with .0) they should als be only one higher than the...
2,159
Posted By Chubler_XL
How about this: awk 'key { if (key ==...
How about this:

awk 'key {
if (key == $1" "$2 && f5 ~ ".0$" && $5 ~ ".0$") {
t3=$3
t5=$5
next
}
print key,f3,t3,f5,t5
}
{ key=$1" "$2; f3=t3=$3;...
998
Posted By Chubler_XL
If your find supports -printf, can I suggest...
If your find supports -printf, can I suggest this:

find FOLDER[12] -type f -printf "%s_%p\n" | awk -F_ '
BEGIN { print "ID -","VALUE-FOLDER1|","COUNT FOLDER1|", "VALUE-FOLDER2|","COUNT...
Showing results 1 to 25 of 42

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