Everyone will like to get a pearl in an ocean but it's not so easy.Same way grepping a exact string from the selected content is a tricky task. I spent much time to get the exact command in internet ,so i am sharing the information here that it might helpful for all of you.
Suppose I would like to get the exact domain from the system information using below command.While i use awk or cut command it will provide the result but it will also includes the extra spaces along the result to us.It might not helpful to us while passing such result into scripts like perl/shell etc.
So trimming the space here is much more important to us.To achieve this we can follow final command which given here.
# facter domain - xxx.yyyyyy.com
2.Need to get the xxx value from the above domain name:
# facter domain | cut -d "." -f 1 - xxx ( partial success ) this result will provide unwanted space along with this
3.Finally By using below command we can remove unwanted spaces:
# facter domain | cut -d "." -f 1 | tr -d '[:space:]' -- xxx
Facter is small program that gathers system information such as hardware details, network settings, virtualisation type and kernel/OS information. Facter was created for Puppet to gather system information, but is also available as a standalone command.
Example:
Suppose I would like to get the exact domain from the system information using below command.While i use awk or cut command it will provide the result but it will also includes the extra spaces along the result to us.It might not helpful to us while passing such result into scripts like perl/shell etc.So trimming the space here is much more important to us.To achieve this we can follow final command which given here.
Commands:
1.Grepping domain name from your system:# facter domain - xxx.yyyyyy.com
2.Need to get the xxx value from the above domain name:
# facter domain | cut -d "." -f 1 - xxx ( partial success ) this result will provide unwanted space along with this
3.Finally By using below command we can remove unwanted spaces:
# facter domain | cut -d "." -f 1 | tr -d '[:space:]' -- xxx
No comments:
Post a Comment