I have a file with entries below.
domain1.com.http:
domain2.com.49503:
I need this to be sorted like below. ie remove the patten after the last right-hand side . (dot).
domain1.com
domain2.com
I have a file with entries below.
domain1.com.http:
domain2.com.49503:
I need this to be sorted like below. ie remove the patten after the last right-hand side . (dot).
domain1.com
domain2.com
sed "s/\./ /g" file | awk '{print $1,$2}'|sed "s/ /./g"
Actually u can try with more simpler code but this can work too
perl -pe 's:\.(?!.*\.).*::' file
awk -F. '{$NF=""}1 OFS=. | file
Short code, but have a bug, it ends the line with a .
domain1.com.
domain2.com.
Maybe I find a way to remove it
sed 's/\.[^.]*$//' file
[quote=jotne;302769106]
awk -F. '{$NF=""}1 OFS=. | file
Short code, but have a bug, it ends the line with a .
Try:
awk -F. 'NF--' OFS=.
awk -Fcom '{print $1FS}' file
awk -Fcom '{print $1FS}' file
Not a god solution.
Will not work with url like www.dotcom.com
awk -F. 'NF--' OFS=.
Right on the spot. Short and does the job.