File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
- # A Bash script (soon to be a command) that displays my IP address
3
- # This script works on Ubuntu Linux
4
- #
5
- # Installing the necessary packages
6
- sudo apt install net-tools
7
- # Store the username in a variable
8
- user=$( whoami)
9
- # A variable that stores my IP address
10
- myIPAddress=$( ifconfig | grep " netmask" | awk ' {print $2}' | grep -v " 127.0.0.1" | head -n 1)
11
- echo " "
12
- echo " "
13
- echo " Displaying your IP address"
14
- sleep 2.5
15
- echo " Dear $user , your IP address is: $myIPAddress "
16
- sleep 1.25
17
- echo " "
18
- echo " "
2
+ # echo ""
3
+ # This Bash script creates a global alias to display my IP address, regardless of my machine
4
+ echo " " >> ~ /.bashrc
5
+ echo " " >> ~ /.bashrc
6
+ echo " " >> ~ /.bashrc
7
+ echo " # ======= My Created Aliases =======" >> ~ /.bashrc
8
+ echo " #" >> ~ /.bashrc
9
+ echo " # This Alias displays my IP Address with just a command: displayMyIPAddress" >> ~ /.bashrc
10
+ # echo 'alias displayMyIPAddress="echo \$(ifconfig | grep 'netmask' | awk '{print \$2}' | grep -v '127.0.0.1' | head -n 1)"' >> ~/.bashrc
11
+ echo " alias displayMyIPAddress=\" echo Your IPv4 Address is \$ (ifconfig | grep netmask | awk '{print \$ 2}' | grep -v 127.0.0.1 | head -n 1)\" " >> ~ /.bashrc
12
+ echo " Done!"
13
+ sleep 3
14
+ echo " Do run this command:"
15
+ echo " sudo source ~/.bashrc"
16
+ echo " After doing that, run this command, to display your IP address: displayMyIPAddress"
You can’t perform that action at this time.
0 commit comments