🔴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
else
MTKCAM_LOG_LEVEL_DEFAULT := 4
endif
2、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' `; done
3、VirtualBox挂载文件夹
mount -t vboxsf guazai /mnt/share
字符串操作
1、大小写转换
$ test="abcDEF"
把变量中的第一个字符换成大写
$ echo ${test^}
AbcDEF
把变量中的所有小写字母,全部替换为大写
$ echo ${test^^}
ABCDEF
把变量中的第一个字符换成小写
$ echo ${test,}
abcDEF
把变量中的所有大写字母,全部替换为小写
$ echo ${test,,}
abcdef
2、删除字符串的头和尾中的空格,类似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 ]];then
echo $str1" > "$str2
else
echo $str1" < "$str2
fi
基本语法
1、传参数
$#
$?
$* = "$1 $2 $3..."
$@ = "$1" "$2" "$3"...
$$ 脚本运行的当前进程ID号
例子:
for i in "$*"; do
for i in "$@"; do
2、数组
定义 : 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
do
command
done
while condition
do
command
done
2、if判断
3、switch-case
case $aNum in
1)
echo '你选择了 1'
;;
*)
echo '你没有输入 1 到 4 之间的数字'
;;
esac
4、单行命令
if [ $(ps -ef | grep -c "ssh") -gt 1 ]; then echo "true"; fi
for var in item1 item2 ... itemN; do command1; command2… done;
1万+

被折叠的 条评论
为什么被折叠?



