In writing hive scripts, we often see the following ways of writing:
#!/bin/bash basepath=$(cd `dirname $0`; pwd)
The specific meanings are as follows:
dirname $0, get the parent directory of the currently executing script file cd `dirname $0`, enter this directory (switch the current working directory) pwd, display the current working directory (after cd is executed)
Notice:
In the process of using it, please pay attention to this:
"`" in the command is not an English single quotation mark, but the symbol under the same key of "~" in the English input method.
To put it bluntly, it is to get the absolute path of the folder where your file is currently located:
[zm@sandbox job_scheduling]$ pwd /home/zm/test/job/job_scheduling/name.sh After executing the above command, the result is: /home/zm/test/job/job_scheduling