Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ask the user which object type they would like to rename
- echo "Which network object type would you like to edit? "
- echo "policy"
- echo "netgroup"
- echo "zonegroup"
- echo "host"
- echo "iprange"
- echo "ipaddr"
- echo "subnet"
- echo "netmap"
- #echo "all"
- # I would like to add an "all" variable that would equate to the 8 object
- # types listed above (policy through netmap)
- # Read in the user input and assign the variable name "object".
- read object
- # The following command will search for the objects in its respective table.
- cf -TJK name $object q | tail -n +3 |sed 's/ *$//' |grep " " >temp
- # Use the Internal Field Separator in order to assign the x variable to the
- entire object name.
- IFS="`printf 'nt'`"
- for x in `cat temp`
- do
- # The following command output is assigned to the y variable which will
- become the new name.
- y=`printf "$x" | tr ' ' '_'`
- cf $object modify name="$x" newname=$y
- done
- # Create arrays
- my_array=()
- all_objects=(policy netgroup zonegroup host iprange ipaddr subnet netmap)
- # Ask the user which object type they would like to rename
- echo "Which network object type would you like to edit? "
- for o in "${all_objects[@]}"; do
- echo "$o"
- done
- echo "all"
- # Read in the user input and assign the variable name "object".
- read object
- if [ "$object" = all ]; then
- for o in "{all_objects[@]}"; do
- # The following command will search for all objects in their respective tables.
- my_array+=($(cf -TJK name "$o" q | tail -n +3 |sed 's/ *$//' |grep " "))
- done
- else
- # The following command will search for the objects in its respective table.
- my_array+=($(cf -TJK name "$object" q | tail -n +3 |sed 's/ *$//' |grep " "))
- fi
- # Use the Internal Field Separator in order to assign the x variable to the entire object name.
- IFS="$(printf 'nt')"
- for x in "${my_array[@]}"; do
- # The following command output is assigned to the y variable which will become the new name.
- y=$(printf "$x" | tr ' ' '_')
- cf "$object" modify name="$x" newname="$y"
- done
Add Comment
Please, Sign In to add comment