Linux checking shell command (bash) -


how can check if shell command ends text? instance if type

$ http://example.com/file.webm 

(ends .webm) automatically replaced

$ wget http://example.com/file.webm 

of course if command consists of 1 part.

i'm using bash shell.

bash 4 provides hook handling "command not found" error. in case, http://example.com/file.webm not valid command, define following function in .bashrc file:

command_not_found_handle () {   if [[ $1 = http://*.webm ]];       wget "$1"   else       return 127   fi } 

when attempt run url command, command_not_found_handle called url first argument. function checks if command name matches webm url, , if does, runs wget url argument. (for other unrecognized command, return 127, command still unrecognized.)


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -