Path: get the dirname of a full path
Tasks: 1.1. define a variable with value of a file's full path 2.2. print the directory of the file
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.1. define a variable with value of a file's full path 2.2. print the directory of the file
Bash | Perl | Python |
---|---|---|
|
|
|
Tasks: 1.1. define a variable with value of a file's full path 2.2. print the filename of the file
Bash | Perl | Python |
---|---|---|
|
|
|
1. create the script file. 2. run the script file to get it's path
Tasks:
Bash | Perl | Python |
---|---|---|
|
|
|
In bash: A good practice is to use subshell,and thus will not affect the working directory of parent shell. alias new_job='(cd /boot; pwd; echo "in subshell: $$ $BASHPID. working dir: `pwd`")'
Tasks:
Bash | Perl | Python |
---|---|---|
|
|
|
In bash: If you are running bash v4 or better, the PID of the subshell is available in $BASHPID. In python: The best way is to use File::chdir and $CWD variable Using below maybe problematic in case of exeptions: my $cwd_orig = cwd; chdir "$cwd_new"; #do some work... chdir $cwd_origin;
Tasks:
Bash | Perl | Python |
---|---|---|
|
|
|