File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ A collection of simple Bash scripts.
28281 . [ Encrypt.sh] ( scripts/encrypt.sh ) : encrypt a file/folder with password
29291 . [ Archive-and-encrypt.sh] ( scripts/archive-and-encrypt.sh ) : archive a path into a file and encrypt the file
30301 . [ weather.sh] ( scripts/weather.sh ) : check the weather in a specified location or using the geolocation of the ip address by default.
31-
31+ 1 . [ WhereIP.sh ] ( scripts/whereIP.sh ) : Get location of an IP address.
3232## System Administration
3333
34341 . [ DirectorySize.sh] ( scripts/directorysize.sh ) : output a specified directory's size
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ #
4+ # Author: Abhishek Shingane ([email protected] )5+ # Date: 11 Sep 2020
6+ #
7+
8+ if ! [ -x " $( command -v jq) " ]; then
9+ echo ' Error: jq is not installed. Install via https://stedolan.github.io/jq/download/'
10+ exit 1
11+ fi
12+
13+ if [[ $# -ne 1 ]]; then
14+ echo ' Provide I.P as command line parameter. Usage: ' $0 ' 15.45.0.1 '
15+ exit 1
16+ fi
17+ link=$( echo " http://ip-api.com/json/" $1 )
18+ data=$( curl $link -s) # -s for slient output
19+
20+ status=$( echo $data | jq ' .status' -r)
21+
22+ if [[ $status == " success" ]]; then
23+
24+ city=$( echo $data | jq ' .city' -r)
25+ regionName=$( echo $data | jq ' .regionName' -r)
26+ country=$( echo $data | jq ' .country' -r)
27+ echo $city , $regionName in $country .
28+ fi
29+
30+
You can’t perform that action at this time.
0 commit comments