Last change
on this file since 30037 was 30037, checked in by ak19, 9 years ago |
Moving new scripts to GS3/bin/script instead of cluttering top level folder
|
-
Property svn:executable
set to
*
|
File size:
1.2 KB
|
Line | |
---|
1 | #!/bin/bash
|
---|
2 |
|
---|
3 | #http://www.wikihow.com/Find-Your-IP-Address-on-a-Mac#Finding_Your_Internal_IP_Using_the_Terminal_sub
|
---|
4 | #http://stackoverflow.com/questions/1469849/how-to-split-one-string-into-multiple-strings-in-bash-shell
|
---|
5 | #http://www.linuxforums.org/forum/red-hat-fedora-linux/193076-ifconfig-doesnt-display-ipv4-address.html
|
---|
6 |
|
---|
7 |
|
---|
8 | # The following echoes the IPv4, e.g. 100.200.300.45
|
---|
9 | # But need to still replace the . with \.
|
---|
10 |
|
---|
11 | #echo `ifconfig | grep "inet " | grep -v 127.0.0.1`|cut -d' ' -f 2|cut -d':' -f 2
|
---|
12 |
|
---|
13 |
|
---|
14 | tmp=`ifconfig | grep "inet " | grep -v 127.0.0.1`
|
---|
15 |
|
---|
16 | tmp=`echo $tmp|cut -d' ' -f 2|cut -d':' -f 2`
|
---|
17 |
|
---|
18 | #http://stackoverflow.com/questions/13210880/replace-one-substring-for-another-string-in-shell-script
|
---|
19 | #${original_string//searchterm/$string_to_replace_searchterm_with}
|
---|
20 | replace="."
|
---|
21 | replacement="\."
|
---|
22 |
|
---|
23 | tmp=${tmp//$replace/$replacement}
|
---|
24 |
|
---|
25 | # next, if the tmp variable is not the empty string, prefix the | operator
|
---|
26 | # http://unix.stackexchange.com/questions/146942/how-can-i-test-if-a-variable-is-empty-or-contains-only-spaces
|
---|
27 | # Can just return | if $tmp is empty, as that doesn't really matter. Will be consistent with windows
|
---|
28 | if [[ ! -z "${tmp// }" ]]; then
|
---|
29 | tmp="|$tmp"
|
---|
30 | else
|
---|
31 | tmp="|"
|
---|
32 | fi
|
---|
33 |
|
---|
34 |
|
---|
35 | echo $tmp
|
---|
Note:
See
TracBrowser
for help on using the repository browser.