General Bash Command
1. Assignment of the value of variable word to parameter if and only if it is null
${parameter:=word}
2. Text processing using AWK example 1
echo $CODEBUILD_BUILD_ID | awk -F":" '{print $2}'
Output and pipe the string of variable CODEBUILD_BUILD_ID to awk as input, use ":" as separator and output the second element of the separated words
3. Cut out a range of characters for further processing
echo abcde | cut -c 1-2
cut accepts standard input and file as the reading source, cut -c 1-2 "xxx" is not allowed
4. Find row of string existence and replace the whole line
SOME_VER=v1.0 && sed -i "/LINE TO FIND/c\VER=$SOME_VER" ./dir/to/file
Variable "SOME_VER" is defined, and then search for the line contains words "ROW TO FIND" and substitute with VER=v1.0 (variable substituted)
Note: The double quote "", single quote cannot perform variable substitution, single quote does not interpolate anything
"c\SomeText" is to replace the selected line with SomeText
Docker command
1. Close all running containers
docker stop $(docker ps -a -q) docker rm $(docker ps -a -q)
2. Show docker entrypoint command without truncate
docker ps --no-trunc --format '{{.Command}}'
沒有留言:
張貼留言