Search Results

Search: Posts Made By: RavinderSingh13
212
Posted By RavinderSingh13
Thank you :) For your questions, why a[$1]...
Thank you :)

For your questions, why a[$1] didn't throw errors because if any variable is NOT initialized in awk and we are using it in any condition or etc then its value will be considered as...
212
Posted By RavinderSingh13
Hello beca123456, Could you please try...
Hello beca123456,

Could you please try following.


awk 'BEGIN{FS=OFS="|"} FNR==NR{b[$1]=length($3)>a[$1]?$3:b[$1];a[$1]=length($3)>a[$1]?length($3):a[$1];next} length($3)<a[$1]{$3=b[$1]} 1' ...
558
Posted By RavinderSingh13
Hello abhaydas, Always try to following rule...
Hello abhaydas,

Always try to following rule of 1 thread ==> 1 question please.

Geeks have really helped you in this thread, so for future users who want to get reference from this thread, will...
437
Posted By RavinderSingh13
Hello kumarinfa, I am considering that you...
Hello kumarinfa,

I am considering that you have saved output of ls command into a file and then I have written this code.


awk '{split($NF,array,"[_.]");$NF=array[2] OFS $NF} 1' Input_file
...
Forum: What is on Your Mind? 2 Weeks Ago
149
Posted By RavinderSingh13
Happy New Year 2020 to all :)
Hello All,

I would like to wish A very Happy New Year 2020 to all. May GOD bless all of us with TRUE knowledge, wisdom, great attitude, honesty, hard working capability, great health :b:

Cheers...
716
Posted By RavinderSingh13
Hey nez, How about some Monday fun :cool: ...
Hey nez,

How about some Monday fun :cool:


echo "all of the kings of Norway" | awk '{sum+=gsub(/of/,"&")} END{print sum}'


Taken example from Jim's sample echo message, cheers.

Thanks,...
716
Posted By RavinderSingh13
Hello milhan, If you see OP's question...
Hello milhan,

If you see OP's question carefully, OP needs to know total number of matched count of string NOT number of lines and as per your posted quote seems -c Option gives matched number of...
693
Posted By RavinderSingh13
Hello nez, How are you? I hope you are...
Hello nez,

How are you?
I hope you are doing fine :)

For your this solution, if you ask me IMHO we could avoid using renaming of a Input_file with system while reading Input_file itself...
Forum: What is on Your Mind? 3 Weeks Ago
134
Posted By RavinderSingh13
Merry Christmas 2019 :) :)
Hello All,

I would like to wish merry x-mas to all of you. May GOD bless us all with wisdom, love, positivity and great positive energy, cheers and happy holidays :)

Thanks,
R. Singh
631
Posted By RavinderSingh13
Hello cowa, Welcome to forums, special...
Hello cowa,

Welcome to forums, special thanks for using CODE TAGS for samples.

On UNIX.com we encourage users to show their efforts in their questions which they have put in order to solve...
Forum: What is on Your Mind? 3 Weeks Ago
258
Posted By RavinderSingh13
Hey Neo, IMHO Rich is who is blessed with...
Hey Neo,

IMHO Rich is who is blessed with knowledge and you are blessed with it(with your hard work, intelligence you gained it). So you are Richer than most of influential people out there IMHO...
Forum: What is on Your Mind? 3 Weeks Ago
258
Posted By RavinderSingh13
Hello Neo, Sorry for not mentioning details...
Hello Neo,

Sorry for not mentioning details in post.

What personally I like is the way A.I progressing in video they shown how they are making a baby(virtual one) learn by feeding data to it(I...
Forum: What is on Your Mind? 3 Weeks Ago
258
Posted By RavinderSingh13
A nice YT video on A.I
Hello All,

Just went through a nice YT video of A.I

Age of A.I YT video (https://youtu.be/UwsrzCVZAb8)

See who is the host of this video :) if you are a Hollywood fan(a bit spoiler)
I...
833
Posted By RavinderSingh13
Hello tomato00, Could you please try...
Hello tomato00,

Could you please try following.


cat script.ksh
declare -a arr=("test" "Monday" "Tuesday" "Wednesday" "Thurday" "Friday" "Saturday" "Sunday")

while read first second...
833
Posted By RavinderSingh13
Hello tomato00, On UNIX.com we encourage...
Hello tomato00,

On UNIX.com we encourage users to add their efforts whatever they have put in order to solve their own problems.
So kindly do let us know your efforts.

Thanks,
R. Singh
971
Posted By RavinderSingh13
Hello kshitij, Could you please try...
Hello kshitij,

Could you please try following. Written and tested with GNU awk and GNU sort.


awk '
/^[0-9]+/{
val=$NF
}
{
print val "@" $0
}' Input_file |
sort -t'@' -nrsk1,1 |...
964
Posted By RavinderSingh13
Hello kshitij, Could you please try...
Hello kshitij,

Could you please try following.


awk '
FNR==NR{
if($0~/^[0-9]+/){
++count
}
sum[count]+=$NF
next
}
/^[0-9]+/{
print $0,sum[++var]
next
}
1
' ...
1,059
Posted By RavinderSingh13
Hello green_k, Could you please try...
Hello green_k,

Could you please try following.


awk '
/^\[/{
if(count){
for(i=1;i<=count;i++){
print val,a[i],count
}
}
val=$0
count=""
next
}
{
...
1,059
Posted By RavinderSingh13
Hello green_k, Could you please try...
Hello green_k,

Could you please try following.


awk '/^\[/{val=$0;next} {print val,$0}' Input_file


On Sun o.s use nawk in place of awk.

Thanks,
R. Singh
884
Posted By RavinderSingh13
Hello mcesmcsc, Good that you have shown us...
Hello mcesmcsc,

Good that you have shown us what you have tried to solve your own problem, keep it up.
Could you please do let us know sample of Input_file and expected output in CODE TAGS too it...
1,046
Posted By RavinderSingh13
Hello Sennenmut, Good that you were able to...
Hello Sennenmut,

Good that you were able to solve the problem by your own. But after working on few posts in this thread and suddenly declaring that you have solved the problem will not help...
820
Posted By RavinderSingh13
Hello jvoot, Could you please try following....
Hello jvoot,

Could you please try following.

awk 'FNR==NR{a[$1]=$2;next} ($0 in a){print $1,a[$1]}' Input_file2 Input_file1


Output will be as follows.

ABC 123
DEF 345
XYZ 678
ABC...
667
Posted By RavinderSingh13
Hello jiam912, We encourage users to add...
Hello jiam912,

We encourage users to add their efforts which they have put in order to solve their own problems in their post.
So kindly do let us know what you have tried to solve this?
...
832
Posted By RavinderSingh13
Hello sand1234, Following is the complete...
Hello sand1234,

Following is the complete explanation on same.

awk ' ##Starting awk command here.
{
ORS=length==80?"":RS ##Setting ORS by checking condition if...
832
Posted By RavinderSingh13
Hello sand1234, Here is the explanation of...
Hello sand1234,

Here is the explanation of it:

As you could see there are 2 %s written in printf which are connected to following.

%s -----> length($0)==80?ORS:""
%s -----> $0

1st one...
Showing results 1 to 25 of 500

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