Search Results

Search: Posts Made By: RavinderSingh13
Forum: What is on Your Mind? 2 Hours Ago
194
Posted By RavinderSingh13
Thanks a TON Neo for giving me this GREAT honor...
Thanks a TON Neo for giving me this GREAT honor :b:, its always an honor to become a proud member of this GREAT site :b:, whatever I know in scripting/*nix I learnt from this forum/site and whatever...
101
Posted By RavinderSingh13
Hello big123456, IMHO I think you are...
Hello big123456,

IMHO I think you are looking for grep -l option, since it will only print Filenames which have that specific text in them, try something like:


find /tmp/ -type f -exec grep...
652
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...
306
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' ...
306
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...
520
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? 3 Weeks Ago
156
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...
813
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,...
813
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...
793
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? 4 Weeks Ago
139
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
730
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? 4 Weeks Ago
275
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? 4 Weeks Ago
275
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? 4 Weeks Ago
275
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...
849
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
849
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...
996
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 |...
992
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,161
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,161
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
912
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,074
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...
845
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...
3,754
Posted By RavinderSingh13
Hello jcdole, Yes, that could be shorten to...
Hello jcdole,

Yes, that could be shorten to following.

MY_PATTERN="="
SOME_VAR=$(awk -F"$MY_PATTERN" '{split($1,array," ");print array[3]}' Input_file)
echo "$SOME_VAR"


Thanks,
R. Singh
Showing results 1 to 25 of 500

 

Featured Tech Videos

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