Tuesday, May 14, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 955  / 3 Years ago, mon, july 19, 2021, 4:14:15

I have a list of domains matched and piped in through grep with various length but all match the last three records. I'm trying to output all of the non-qualified sub-domains.



I have:



awk -F'.' -v OFS='.' '{$(NF-3)=$(NF-2)=$(NF-1)=""; print $0}' 


my output leaves trailing ...... on the output



Thanks


More From » awk

 Answers
1

Try substituting them:



$ awk -F'.' 'sub(FS $(NF-2) FS $(NF-1) FS $NF,"")' <<<"www.cse.iitb.ac.in"
www.cse


I'm not sure why this works and your method doesn't, but according to this unix.com post, that's the way.


[#22887] Tuesday, July 20, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulerio

Total Points: 172
Total Questions: 124
Total Answers: 109

Location: Hungary
Member since Thu, Aug 6, 2020
4 Years ago
;