Linux shell/makefile/gic/python指令速查-inprocess
生活随笔
收集整理的這篇文章主要介紹了
Linux shell/makefile/gic/python指令速查-inprocess
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 🔴gic
- 1、git commit --amend 的撤銷
- 2、更改git log中的Author name
- 🔴python
- 🔴makefile
- 1、if/elif/else, 判斷變量的值(if xxx==yes)
- 2、makefile自動化變量: $@, $^, $<, $?
- 🔴Linux Shell
- 終端命令
- 1、替換所有文件中的某字符串
- 2、將文件批量重命名
- 3、VirtualBox掛載文件夾
- 字符串操作
- 1、大小寫轉換
- 2、刪除字符串的頭和尾中的空格,類似python的strip()
- 3、比較字符串
- 基本語法
- 1、傳參數
- 2、數組
- linux shell基礎
- 1、for循環/while
- 2、if判斷
- 3、switch-case
- 4、單行命令
🔴gic
1、git commit --amend 的撤銷
git reflog //先執行git reflog,扎送到commit id git reset ab8f210 //不加--hard,退回add/amend之前狀態 git reset --hard ab8f210 //加hard,退回到ab8f210點,改動也刪除了2、更改git log中的Author name
git commit --amend --author=“Baron Zhou zhhh891010@163.com”
🔴python
🔴makefile
1、if/elif/else, 判斷變量的值(if xxx==yes)
ifeq ($(TARGET_BUILD_VARIANT),user)MTKCAM_LOG_LEVEL_DEFAULT := 2 else ifeq ($(TARGET_BUILD_VARIANT),userdebug)MTKCAM_LOG_LEVEL_DEFAULT := 3 elseMTKCAM_LOG_LEVEL_DEFAULT := 4 endif2、makefile自動化變量: $@, $^, $<, $?
$@ 表示目標文件
$^ 表示所有的依賴文件
$< 表示第一個依賴文件
$? 表示比目標還要新的依賴文件列表
🔴Linux Shell
終端命令
1、替換所有文件中的某字符串
sed -i "s/old/new/g" `grep old -rl /www`2、將文件批量重命名
for f in `find ./ -name "*old*"`;do mv "$f" `echo "$f" | sed 's/old/new/g' `; done批量刪除后綴
for f in `find ./ -name "*.txt1"`;do mv "$f" `echo "$f" | sed 's/\.txt1//g' `; done3、VirtualBox掛載文件夾
mount -t vboxsf guazai /mnt/share
字符串操作
1、大小寫轉換
$ test="abcDEF"
把變量中的第一個字符換成大寫 $ echo ${test^} AbcDEF 把變量中的所有小寫字母,全部替換為大寫 $ echo ${test^^} ABCDEF 把變量中的第一個字符換成小寫 $ echo ${test,} abcDEF 把變量中的所有大寫字母,全部替換為小寫 $ echo ${test,,} abcdef2、刪除字符串的頭和尾中的空格,類似python的strip()
kernel_dir=$(grep LINUX_KERNEL_VERSION * -nrs | awk -F"=" '{print $2}' | sed 's/^[ \t]*//g' | sed 's/[ \t]*$//g')3、比較字符串
if [[ $str1 > $str2 ]];thenecho $str1" > "$str2 elseecho $str1" < "$str2 fi基本語法
1、傳參數
$# $? $* = "$1 $2 $3..." $@ = "$1" "$2" "$3"... $$ 腳本運行的當前進程ID號 例子:for i in "$*"; dofor i in "$@"; do2、數組
定義 : array_name=(value0 value1 value2 value3) 賦值 : array_name[0]=value0 引用 : valuen=${array_name[n]} 特殊符號:echo "數組的元素為: ${my_array[*]}"echo "數組的元素為: ${my_array[@]}"echo "數組元素個數為: ${#my_array[*]}"echo "數組元素個數為: ${#my_array[@]}"linux shell基礎
1、for循環/while
until condition docommand done while condition docommand done2、if判斷
3、switch-case
case $aNum in1) echo '你選擇了 1';;*) echo '你沒有輸入 1 到 4 之間的數字';; esac4、單行命令
if [ $(ps -ef | grep -c "ssh") -gt 1 ]; then echo "true"; fi for var in item1 item2 ... itemN; do command1; command2… done;總結
以上是生活随笔為你收集整理的Linux shell/makefile/gic/python指令速查-inprocess的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Linux Kernel aarch64
- 下一篇: leetcode-C语言代码练习