Hello again
In the first time you need to create a new file and you call it for example showip but not showip.sh
with the command
touch showip
or
vim showip
now with your text editor like gedit or vim we will create our command
in the first line
#!/bin/sh
it using to link to bash
In your terminal when you need show your you insert the ifconfig command but with this command you will show all about your network address
If you need to show just the address you will insert the command
ifconfig eth0 | grep "inet addr" you will have:
Now I need to select just ip address with the command :
ifconfig eth0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}'
the result is:
Now exit 0 to finish our shell script
Our shell script is like that:
If I need used like any command in my Linux OS, how ???
In the first time we will change access mod with
chmod 777 showip
In the second time we will copy this script in /usr/bin/ with the command :
cp showip /usr/bin/
Enjoy it
I wait for your comment and your suggestion.
In the first time you need to create a new file and you call it for example showip but not showip.sh
with the command
touch showip
or
vim showip
now with your text editor like gedit or vim we will create our command
in the first line
#!/bin/sh
it using to link to bash
In your terminal when you need show your you insert the ifconfig command but with this command you will show all about your network address
If you need to show just the address you will insert the command
ifconfig eth0 | grep "inet addr" you will have:
Now I need to select just ip address with the command :
ifconfig eth0 | grep "inet addr" | gawk -F: '{print $2}' | gawk '{print $1}'
the result is:
Now exit 0 to finish our shell script
Our shell script is like that:
If I need used like any command in my Linux OS, how ???
In the first time we will change access mod with
chmod 777 showip
In the second time we will copy this script in /usr/bin/ with the command :
cp showip /usr/bin/
Enjoy it
I wait for your comment and your suggestion.
0 commentaires:
Post a Comment