Unix/Linux
- How to create a symbolic or soft link?
syntax:
ln [-s] source symbolic link
e.g: ln -s src/build/llvm/install/bin ./my_bin
How to grep all file exclude a ctag file : tags?
alias gnt='grep -rn --exclude="tags"'
- How to get the current directory of the running script?
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Bash maintains a number of variables including
BASH_SOURCE which is an array of source file pathnames.${} acts as a kind of quoting for variables.$() acts as a kind of quoting for commands but they're run in their own context.dirname gives you the path portion of the provided argument.cd changes the current directory.pwd gives the current path.&& is a logical and but is used in this instance for its side effect of running commands one after another.
In summary, that command gets the script's source file pathname, strips it to just the path portion,
cds to that path, then uses pwd to return the (effectively) full path of the script. This is assigned to DIR. After all of that, the context is unwound so you end up back in the directory you started at but with an environment variable DIR containing the script's path.
ref: https://stackoverflow.com/questions/39340169/dir-cd-dirname-bash-source0-pwd-how-does-that-work/39340259#39340259
How to do in place search and repalce using sed?
sed -i 's/foo/bar/g' *.txt
- How to set scp no need for password?
You may create
~/.ssh/authorized_keys if it is not already created;
otherwise, just append to the end of the file, using
cat id_rsa.pub >>~/.ssh/authorized_keys.- What is dot utility?
dot, neato, twopi, these are a collection of programs for drawing graphs.
- What is ldd ? Or how to print the shared object dependencies?
ldd (List Dynamic Dependencies)
ldd - print shared object dependencies
- What is rpath?
In computing, rpath designates the run-time search path hard-coded in an executable file or library. Dynamic linking loaders use the rpath to find required libraries.Best CSDN reference
-rpath和-rpath-link都可以在链接时指定库的路径;但是运行可执行文件时,-rpath-link指定的路径就不再有效(链接器没有将库的路径包含进可执行文件中),而-rpath指定的路径还有效(因为链接器已经将库的路径包含在可执行文件中了。)
- What is the diff between rpath and path-link?
- How to check if a directory exists in a shell script ?
you can use the following:
if [ -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY exists.
fi
Or to check if a directory doesn't exist:
if [ ! -d "$DIRECTORY" ]; then
# Control will enter here if $DIRECTORY doesn't exist.
fi
Comments
Post a Comment