Posted on 10-14-2014 01:58 PM
Hi all,
What would be the line/commands to delete all network locations except for two (one named "Ethernet" and one named "Wi-Fi"). I want to delete any other network locations users may have except for two that i've create on their machines.
Thanks for your help forum!!!
Solved! Go to Solution.
Posted on 10-14-2014 02:08 PM
#!/bin/sh
defaultIFS=$IFS
IFS=$'
'
for i in $(networksetup -listlocations | grep -v -e "Location 1" -e "Location2")
do
echo "Removing location $i"
networksetup -deletelocation "$i"
done
IFS=$defaultIFS
quick & dirty, so test, test, test ;)
Posted on 10-14-2014 02:00 PM
networksetup help
look for listallnetworkservices then loop on the result. and delete what you don't want.
Posted on 10-14-2014 02:03 PM
I'm actually looking to write a command to add to a script...
Posted on 10-14-2014 02:06 PM
I don't want to edit the "networkservices", but want to delete actual "networklocations"
Posted on 10-14-2014 02:06 PM
networksetup -help is still your friend
Posted on 10-14-2014 02:08 PM
#!/bin/sh
defaultIFS=$IFS
IFS=$'
'
for i in $(networksetup -listlocations | grep -v -e "Location 1" -e "Location2")
do
echo "Removing location $i"
networksetup -deletelocation "$i"
done
IFS=$defaultIFS
quick & dirty, so test, test, test ;)
Posted on 10-14-2014 02:10 PM
I've done that.. i know how to delete locations but don't know how to write an IF statement. I guess that what i need help with. I know the basic networksetup -deletelocation "locationname" and how to use it.
I just need help writing a command/statement that says if the network location name isn't (Wi-Fi or Ethernet) then delete it...
Sorry for the confusion...
Posted on 10-14-2014 02:12 PM
@Chris Thats exactly what i needed. Thank you for the quick response! I'll test and reply back..Thanks again!