#!/bin/bash # info: search for available commands # # This function searches for available Vesta Control Panel commands # that contain all the words that have been pass to it as arguments. # # Originally developed for VestaCP by Federico Krum # https://github.com/FastDigitalOceanDroplets/VestaCP/blob/master/files/v-search-command #----------------------------------------------------------# # Variable&Function # #----------------------------------------------------------# source $VESTA/func/main.sh #----------------------------------------------------------# # Verifications # #----------------------------------------------------------# if [ $# -eq 0 ]; then echo "ERROR: No search arguments specified." echo "Usage: v-search-command ARG1 [ARG2] [ARG...]" exit 1 fi #----------------------------------------------------------# # Action # #----------------------------------------------------------# SearchPath=`ls -a $VESTA/bin/ | sort` TotalItems=`ls -a $VESTA/bin/ | sort | wc -l` for i; do SearchPath=`echo $SearchPath | tr " " "\n" | grep $i` done FoundItems=`echo $SearchPath | tr " " "\n" | grep $i | wc -l` if [ -z "$SearchPath" ]; then echo "No available commands were found matching the specified criteria." echo "There are a total of $TotalItems commands available." else echo "Command Search Results" echo "=================================" echo $SearchPath | tr " " "\n" echo "=================================" echo "Found $FoundItems matching items in $TotalItems commands." fi exit