I am a newbie in shell scripting and I need to produce a script to work and achieve the following:
1) Look into the file /etc/defaultrouter , and store the value in it
2) If the value is a number, go to LIST and print out the second column corresponding to the value.(eg London)
3) If the content of /etc/defaultrouter is not a number then go to /etc/host to check for the corresponding number
4) Get the number in step 3 and execute step 2
Content of LIST
22.123.2.1.1 canada
192.11.2.1 india
177.235.1.1.1 spain
172.44.5.1 london
66.112.4.1 newyork
I am moVing forward with this script, thanks to joeyg. However i am still having problem with the line highlighted in red. I actually want the script to check the value of invalue if it contain alperbert, if yes, then go to /etc/host.
i have the script bellow but i keep getting the error;
./locatenew.sh: line 13: syntax error near unexpected token `="[a-z]"'
./locatenew.sh: line 13: `(cat $invalue |grep [a-z]) ="[a-z]" '
( line 13 is highlighted in red in my script bellow).
Point being, are the contents of the file a single line, or multiple lines? Assuming it's a single line, the script I posted should do what you asked for, if I correctly interpreted your requirements.