当前位置:   article > 正文

linux shell学习

linux shell学习

参考:

http://www.cnblogs.com/suyang/archive/2008/05/18/1201990.html

http://www.cnblogs.com/xuqiang/archive/2011/04/27/2031034.html

http://www.cnblogs.com/xudong-bupt/p/3721210.html


记录学习的笔记

1、hello world

  1. helloshell.sh
  2. #!/bin/bash
  3. #comments
  4. echo "hello world";

运行

  1. [root@u1 shell_learn]# sh helloshell.sh
  2. hello world

查看shell脚本有无语法错误

[root@u1 shell_learn]# sh -n helloshell.sh

查看展开shell脚本执行

  1. [root@u1 shell_learn]# sh -x helloshell.sh
  2. + echo 'hello world'
  3. hello world

打印shell读取内容

  1. [root@u1 shell_learn]# sh -v helloshell.sh
  2. #!/bin/bash
  3. #comments
  4. echo "hello world";
  5. hello world


查看当前执行shell 版本

  1. [root@u1 shell_learn]# ps
  2. PID TTY TIME CMD
  3. 39366 pts/3 00:00:00 bash
  4. 44076 pts/3 00:00:00 ps


 2、一些细节

  1. just for record some detail
  2. like
  3. sh -n ifshell.sh
  4. sh -v ifshell.sh
  5. sh -x ifshell.sh
  6. ``--get the command then execute ,output the result
  7. expr--mean a expression
  8. \*--translate
  9. $*--all parameter,not include the shell name
  10. $#--count the parameter number,not include the shell
  11. $0--the shell name
  12. $1--the first parameter
  13. $2
  14. -eq -ne -lt -le -gt -ge
  15. ! -a -o
  16. = != str
  17. for-- if use ; then
  18. if no ;
  19. then


条件描述

  1. #!/bin/sh
  2. #test condition
  3. #[ condition ]
  4. #echo $?
  5. #1--file--[ -d -f -L -r -w -x -u -s ]
  6. #2--logic--[ -a -o ! ]
  7. #3--string--[ = != -z -n ]
  8. #4--num--[ -eq -ne -gt -lt -le -ge ]
  9. #5--expr--
  10. echo "file desc"
  11. [ -d basename.sh ]
  12. echo "$?"
  13. echo "logic desc"
  14. test -f basename.sh -a -r cat.sh
  15. echo "$?"
  16. echo "string desc"
  17. str="hello"
  18. test -n str
  19. echo "$?"
  20. echo "num desc"
  21. num=10
  22. test $num -gt 5
  23. echo "$?"
  24. echo "expr desc"
  25. echo "`expr 4 + 5`"
  26. echo "`expr 4 - 5`"
  27. echo "`expr 10 / 5`"
  28. echo "`expr 4 \* 5`"

结果

 

  1. [u1@u1 common]$ sh -x test.sh
  2. + echo 'file desc'
  3. file desc
  4. + '[' -d basename.sh ']'
  5. + echo 1
  6. 1
  7. + echo 'logic desc'
  8. logic desc
  9. + test -f basename.sh -a -r cat.sh
  10. + echo 0
  11. 0
  12. + echo 'string desc'
  13. string desc
  14. + str=hello
  15. + test -n str
  16. + echo 0
  17. 0
  18. + echo 'num desc'
  19. num desc
  20. + num=10
  21. + test 10 -gt 5
  22. + echo 0
  23. 0
  24. + echo 'expr desc'
  25. expr desc
  26. ++ expr 4 + 5
  27. + echo 9
  28. 9
  29. ++ expr 4 - 5
  30. + echo -1
  31. -1
  32. ++ expr 10 / 5
  33. + echo 2
  34. 2
  35. ++ expr 4 '*' 5
  36. + echo 20
  37. 20




3、if

  1. [root@u1 shell_learn]# sh ifshell.sh 5
  2. 5 number is postive
  3. [root@u1 shell_learn]# sh ifshell.sh -5
  4. -5 number is negative

内容

  1. #!/bin/bash
  2. #comments
  3. #$# get the input parameter , not include the command
  4. if [ $# -ne 1 ]
  5. #then must seperate if
  6. then
  7. echo "$0 : you must input a number"
  8. exit 1
  9. fi
  10. #test like [ ]
  11. if test $1 -gt 0
  12. then
  13. echo "$1 number is postive"
  14. else
  15. echo "$1 number is negative"
  16. fi


 if -else

  1. [root@u1 shell_learn]# sh ifelshell.sh
  2. ifelshell.sh:you must a number
  3. [root@u1 shell_learn]# sh ifelshell.sh 5
  4. 5 is a positive
  5. [root@u1 shell_learn]# sh ifelshell.sh -5
  6. -5 is a negative
  7. [root@u1 shell_learn]# sh ifelshell.sh 0
  8. 0 is equal 0
  9. [root@u1 shell_learn]# sh ifelshell.sh a
  10. ifelshell.sh: line 10: [: a: integer expression expected
  11. ifelshell.sh: line 13: [: a: integer expression expected
  12. ifelshell.sh: line 16: [: a: integer expression expected
  13. a is not a number


内容

  1. #!/bin/bash
  2. #comments
  3. #test if ..elif else fi
  4. if [ $# -ne 1 ]
  5. then
  6. echo "$0:you must a number"
  7. exit 1
  8. fi
  9. #if elif else fi
  10. if [ $1 -gt 0 ]
  11. then
  12. echo "$1 is a positive"
  13. elif [ $1 -lt 0 ]
  14. then
  15. echo "$1 is a negative"
  16. elif [ $1 -eq 0 ]
  17. then
  18. echo "$1 is equal 0"
  19. else
  20. echo "$1 is not a number"
  21. fi



4、while

  1. [root@u1 shell_learn]# sh whileshell.sh
  2. whileshell.sh: must input a number
  3. [root@u1 shell_learn]# sh whileshell.sh 4
  4. 4 * 0 =0
  5. 4 * 1 =4
  6. 4 * 2 =8
  7. 4 * 3 =12
  8. 4 * 4 =16
  9. 4 * 5 =20
  10. 4 * 6 =24
  11. 4 * 7 =28
  12. 4 * 8 =32
  13. 4 * 9 =36
  14. 4 * 10 =40


内容

  1. #!/bin/bash
  2. #comment
  3. #test while
  4. if [ $# -ne 1 ]
  5. then
  6. echo "$0: must input a number"
  7. exit 1
  8. fi
  9. i=0
  10. while [ $i -le 10 ]
  11. do
  12. #``--mean calculate expr and output the result
  13. echo "$1 * $i =`expr $1 \* $i`"
  14. i=`expr $i + 1`
  15. done



5、for

  1. [root@u1 shell_learn]# sh forshell.sh
  2. weleome 1 times
  3. weleome 2 times
  4. weleome 3 times
  5. 11111
  6. 22222
  7. 33333
  8. 44444
  9. 55555
  10. 11111
  11. 22222
  12. 33333
  13. 44444
  14. 55555

内容

 

  1. #!/bin/bash
  2. #comments
  3. #test for
  4. for ii in 1 2 3
  5. do
  6. echo "weleome $ii times"
  7. done
  8. for(( i = 1; i <= 5; i++ ))
  9. do
  10. for(( j = 1; j <= 5; ++j ))
  11. do
  12. echo -n "$i"
  13. done
  14. # print a new line
  15. echo ""
  16. done
  17. echo ""
  18. # nested for
  19. for(( i = 1; i <= 5; i++ ))
  20. do
  21. for(( j = 1; j <= 5; j++ ))
  22. do
  23. echo -n "$i"
  24. done
  25. #
  26. echo ""
  27. done



6、case

  1. [root@u1 shell_learn]# sh caseshell.sh
  2. caseshell.sh: must input a command
  3. [root@u1 shell_learn]# sh caseshell.sh 1
  4. 1 is not a valid command
  5. [root@u1 shell_learn]# sh caseshell.sh delete
  6. delete the db
  7. [root@u1 shell_learn]# sh caseshell.sh select
  8. select the db


内容

  1. #!/bin/bash
  2. #comments
  3. # test case
  4. if [ $# -ne 1 ]
  5. then
  6. echo "$0: must input a command"
  7. exit 1
  8. fi
  9. action=$1
  10. case $action in
  11. "update")
  12. echo "update the db"
  13. ;;
  14. "select")
  15. echo "select the db"
  16. ;;
  17. "delete")
  18. echo "delete the db"
  19. ;;
  20. *)
  21. echo "$action is not a valid command"
  22. ;;
  23. esac


7、function and args

  1. [root@u1 shell_learn]# sh funcshell.sh
  2. shell name args:funcshell.sh
  3. all function args:-f foo bar
  4. all function agrs_num 3
  5. the first arg : -f
  6. the second arg : foo:
  7. shell name args:funcshell.sh
  8. all function args:foo bar
  9. all function agrs_num 2
  10. the first arg : foo
  11. the second arg : bar:


内容

  1. #!/bin/bash
  2. #comments
  3. # test function
  4. function demo(){
  5. echo "shell name args:$0"
  6. echo "all function args:$*"
  7. echo "all function agrs_num $#"
  8. echo "the first arg : $1"
  9. echo "the second arg : $2:"
  10. shift
  11. echo "shell name args:$0"
  12. echo "all function args:$*"
  13. echo "all function agrs_num $#"
  14. echo "the first arg : $1"
  15. echo "the second arg : $2:"
  16. }
  17. #call the function
  18. demo -f foo bar


8、date

  1. [root@u1 shell_learn]# sh cmd_learn/date.sh
  2. [root@u1 shell_learn]# cat cmd_learn/date.log
  3. 2015-07-22 11:44:21

内容

 

  1. #!/bin/bash
  2. #
  3. echo "`date -d today +"%Y-%m-%d %T"`" > /home/u1/shell_learn/cmd_learn/date.log


9、find

  1. [root@u1 shell_learn]# sh cmd_learn/find.sh
  2. [root@u1 shell_learn]# tail -f cmd_learn/find.log
  3. /opt/ibm/db2/V10.5/license/sl_SI.iso88592
  4. /opt/ibm/db2/V10.5/license/el_GR.iso88597
  5. /opt/ibm/db2/V10.5/license/lt_LT.iso885913
  6. /opt/ibm/db2/V10.5/license/pl_PL.iso88592
  7. /opt/ibm/db2/V10.5/license/cs_CZ.iso88592
  8. /opt/ibm/db2/V10.5/license/fr_FR.iso88591
  9. /opt/ibm/db2/V10.5/license/de_DE.iso88591
  10. /opt/ibm/db2/V10.5/license/es_ES.iso88591
  11. /opt/ibm/db2/V10.5/license/pt_BR.iso88591
  12. /opt/ibm/db2/V10.5/license/en_US.iso88591


内容

  1. #!/bin/bash
  2. #comments
  3. find / -name "[a-z]*[0-9][0-9]" -print > find.log 2>&1
  4. #find ./ -name "*.sh" -print > find.log 2>&1


10、in_out

  1. [root@u1 shell_learn]# sh cmd_learn/in_out.sh
  2. display
  3. display
  4. display display :
  5. first name : qq
  6. second name :ali
  7. qq ali
  8. u1 tty1 2015-07-16 22:00
  9. u1 pts/0 2015-07-17 00:34 (:0.0)
  10. root pts/3 2015-07-22 10:32 (192.168.147.1)
  11. [root@u1 shell_learn]# cat wh
  12. whileshell.sh who.out
  13. [root@u1 shell_learn]# cat who.out
  14. u1 tty1 2015-07-16 22:00
  15. u1 pts/0 2015-07-17 00:34 (:0.0)
  16. root pts/3 2015-07-22 10:32 (192.168.147.1)
  17. [root@u1 shell_learn]# cat in_out.log
  18. 2015-07-22 11:57:59 1


内容

  1. #!/bin/bash
  2. #echo cat read tee |
  3. #in--0 < <<
  4. #out--1 > >>
  5. #err--2 2>&1
  6. #echo
  7. echo "display"
  8. echo -e "display \n"
  9. echo -n -e "display \t"
  10. echo -e "display :\c"
  11. echo ""
  12. #read
  13. echo -e "first name : \c"
  14. read name
  15. echo -e "second name :\c"
  16. read middle
  17. echo "$name $middle"
  18. #cat
  19. #cat -v > cat_read.log
  20. #tee
  21. who | tee who.out
  22. #0 1 2
  23. echo "`date -d today +"%Y-%m-%d %T"`" 1 >> in_out.log 2>&1


11、read

  1. [root@u1 shell_learn]# sh readshell.sh
  2. 1.unix(sun os)
  3. 2.linux(redhat)
  4. select your os choice [1 or 2] ?2
  5. you pick up linux
  6. [root@u1 shell_learn]# sh readshell.sh
  7. 1.unix(sun os)
  8. 2.linux(redhat)
  9. select your os choice [1 or 2] ?4
  10. what you donot like linux/unix


内容

  1. #!/bin/sh
  2. #comments
  3. #define a variable
  4. osch=0
  5. #display prompt
  6. echo "1.unix(sun os)"
  7. echo "2.linux(redhat)"
  8. echo -n "select your os choice [1 or 2] ?"
  9. #wait user input
  10. read osch
  11. #if
  12. if [ $osch -eq 1 ]
  13. then
  14. echo "you pick up unix"
  15. else
  16. #nested if
  17. if [ $osch -eq 2 ]
  18. then
  19. echo "you pick up linux"
  20. else
  21. echo "what you donot like linux/unix"
  22. fi
  23. fi



12、rename file

  1. [root@u1 shell_learn]# ls
  2. back_syncDeptFtp.sh forshell.sh ifshell.sh syncDeptFtp.sh
  3. caseshell.sh funcshell.sh in_out.log whileshell.sh
  4. cmd_learn getFtpFile.sh multisyncDeptFtp.sh who.out
  5. data getSyncStatus.sh readme.txt
  6. debugshell.sh helloshell.sh readshell.sh
  7. find.log ifelshell.sh rename.sh
  8. [root@u1 shell_learn]# sh rename.sh
  9. rename--renames a number of files using sed regular repressions
  10. USAGE: rename 'regexp' 'relpacement' files
  11. EXAMPLE:rename all *.HTM files in *.html
  12. rename 'sh$' 'SH' *.sh
  13. [root@u1 shell_learn]# sh rename.sh sh$ SH *.sh
  14. renaming back_syncDeptFtp.sh to back_syncDeptFtp.SH
  15. renaming caseshell.sh to caseshell.SH
  16. renaming debugshell.sh to debugshell.SH
  17. renaming forshell.sh to forshell.SH
  18. renaming funcshell.sh to funcshell.SH
  19. renaming getFtpFile.sh to getFtpFile.SH
  20. renaming getSyncStatus.sh to getSyncStatus.SH
  21. renaming helloshell.sh to helloshell.SH
  22. renaming ifelshell.sh to ifelshell.SH
  23. renaming ifshell.sh to ifshell.SH
  24. renaming multisyncDeptFtp.sh to multisyncDeptFtp.SH
  25. renaming readshell.sh to readshell.SH
  26. renaming rename.sh to rename.SH
  27. renaming syncDeptFtp.sh to syncDeptFtp.SH
  28. renaming whileshell.sh to whileshell.SH
  29. [root@u1 shell_learn]# ls
  30. back_syncDeptFtp.SH forshell.SH ifshell.SH syncDeptFtp.SH
  31. caseshell.SH funcshell.SH in_out.log whileshell.SH
  32. cmd_learn getFtpFile.SH multisyncDeptFtp.SH who.out
  33. data getSyncStatus.SH readme.txt
  34. debugshell.SH helloshell.SH readshell.SH
  35. find.log ifelshell.SH rename.SH


内容

  1. #!/bin/bash
  2. #comments
  3. # test rename file
  4. if [ $# -lt 3 ]
  5. then
  6. cat<<HELP
  7. rename--renames a number of files using sed regular repressions
  8. USAGE: rename 'regexp' 'relpacement' files
  9. EXAMPLE:rename all *.HTM files in *.html
  10. rename 'sh$' 'SH' *.sh
  11. HELP
  12. exit 0
  13. fi
  14. #
  15. old=$1
  16. new=$2
  17. shift
  18. shift
  19. for file in $*
  20. do
  21. if [ -f $file ]; then
  22. newfile=`echo $file | sed "s/${old}/${new}/g"`
  23. if [ -f $newfile ] ;then
  24. echo "error:$newfile exists already"
  25. else
  26. echo "renaming $file to $newfile"
  27. mv $file $newfile
  28. fi
  29. fi
  30. done


13、debug info

  1. [root@u1 shell_learn]# sh -v debugshell.sh
  2. #!/bin/bash
  3. #comments
  4. # test debug
  5. tot=`expr $1 + $2`
  6. expr $1 + $2
  7. expr: 语法错误
  8. echo $tot
  9. [root@u1 shell_learn]# sh -v debugshell.sh 4 5
  10. #!/bin/bash
  11. #comments
  12. # test debug
  13. tot=`expr $1 + $2`
  14. expr $1 + $2
  15. echo $tot
  16. 9


内容

  1. #!/bin/bash
  2. #comments
  3. # test debug
  4. tot=`expr $1 + $2`
  5. echo $tot


14、crontab & nohup

  1. #!/bin/bash
  2. #cron crontab at & nohup
  3. #crontab [-u user] -e -l -r
  4. #crontab <filename>
  5. #example
  6. #0-59 0-23 1-31 1-12 0-6
  7. #minute hour day month week shell_name
  8. #1-3 1,3 *
  9. #in shell_name ,the path use absolute path,not relative path

crontab--需要注意,提交到crontab中的脚本,需要使用绝对路径,因为crontab调度程序是不识别用户的环境变量的

eg:

每分钟都执行date.sh脚本

* * * * * /home/u1/shell_learn/cmd_learn/date.sh

&--后台进程运行

nohup--无需守护,也可运行


15、再附上几个觉得在部署系统时,常用的几个命令

查找端口、进程

  1. [root@u1 shell_learn]# netstat -aonp | grep 8080
  2. tcp 0 0 :::8080 :::* LISTEN 60571/java off (0.00/0/0)
  3. [root@u1 shell_learn]# ps -ef | grep ps
  4. root 41 2 0 Jul16 ? 00:00:00 [kpsmoused]
  5. root 1615 1 0 Jul16 ? 00:00:00 cupsd -C /etc/cups/cupsd.conf
  6. root 49227 39366 3 12:12 pts/3 00:00:00 ps -ef
  7. root 49228 39366 0 12:12 pts/3 00:00:00 grep ps
  8. 关闭进程
  9. kill -9 49228


最近在做一个项目   需要在shell中 进行数据库的同步、数据库的备份等功能,发现shell的功能,不得不要为他点赞,太强大了,以上为shell的基本内容,继续研究。。。

16、 常用命令

 

  1. #!/bin/sh
  2. #basename cat cp diff dircmp
  3. #dirname du file fuser head
  4. #logname mkdir more nl printf
  5. #pwd rm rmdir shutdown sleep
  6. #strings touch tty uname wc
  7. #wait whereis who whoami


  1. [u1@u1 common]$ cat script.sh
  2. #!/bin/sh
  3. #basename cat cp diff dircmp
  4. #dirname du file fuser head
  5. #logname mkdir more nl printf
  6. #pwd rm rmdir shutdown sleep
  7. #strings touch tty uname wc
  8. #wait whereis who whoami script


basename

  1. [u1@u1 common]$ cat basename.sh
  2. #!/bin/sh
  3. #basename path
  4. #get file name from path
  5. echo "uasge:`basename $0` file"
  6. exit 1
  7. [u1@u1 common]$ sh /home/u1/mtsd3/shell_learn/common/basename.sh
  8. uasge:basename.sh file


tar

  1. [u1@u1 common]$ cat tar.sh
  2. #!/bin/sh
  3. #tar options files
  4. cp cat.sh cat1.sh
  5. ls
  6. tar -zcvf cat.tar.gz cat1.sh
  7. rm -f cat1.sh
  8. ls
  9. tar -zxvf cat.tar.gz
  10. ls

more

  1. [u1@u1 common]$ cat more.sh
  2. #!/bin/sh
  3. #more filename
  4. #space-next b--previous
  5. more ../../gateway3.1_mq/centrumserver/centrumserver.sh

nl

  1. [u1@u1 common]$ cat nl.sh
  2. #!/bin/sh
  3. #nl filename
  4. nl basename.sh


awk

  1. #!/bin/sh
  2. #as line deal
  3. #awk -F":" '{if($1~/u1/)print $1}' /etc/passwd
  4. #awk '{print NF}' basename.sh
  5. #awk '{print $1,$2}' OFS='\t' basename.sh
  6. awk 'BEGIN{math=0;eng=0;com=0;printf "Lineno. Name No. Math English Computer Total\n";printf "------------------------------------------------------------\n"}{math+=$3; eng+=$4; com+=$5;printf "%-8s %-7s %-7s %-7s %-9s %-10s %-7s \n",NR,$1,$2,$3,$4,$5,$3+$4+$5} END{printf "------------------------------------------------------------\n";printf "%-24s %-7s %-9s %-20s \n","Total:",math,eng,com;printf "%-24s %-7s %-9s %-20s \n","Avg:",math/NR,eng/NR,com/NR}' test0


  1. [root@u1 common]# cat test0
  2. Marry 2143 78 84 77
  3. Jack 2321 66 78 45
  4. Tom 2122 48 77 71
  5. Mike 2537 87 97 95
  6. Bob 2415 40 57 62


  1. [root@u1 common]# sh awk.sh
  2. Lineno. Name No. Math English Computer Total
  3. ------------------------------------------------------------
  4. 1 Marry 2143 78 84 77 239
  5. 2 Jack 2321 66 78 45 189
  6. 3 Tom 2122 48 77 71 196
  7. 4 Mike 2537 87 97 95 279
  8. 5 Bob 2415 40 57 62 159
  9. ------------------------------------------------------------
  10. Total: 319 393 350
  11. Avg: 63.8 78.6 70

grep sed cut awk 组合实例:


  1. #!/bin/sh
  2. #grep n--lien number
  3. # i--ignore case
  4. # want_search_text file
  5. #cut -d delimiter -f field 1 2
  6. #awk -v variable ' $1 $2'
  7. #sed s separator $want_text$replace_text$g
  8. #especially want value to variable, use ``
  9. fl=`grep -ni dead alertDeadLock.log | cut -d: -f 2 | awk -v 'OFS=*' '{print $1,$2,$3 }' | sed 's$*$-$g'`
  10. echo $fl


alertDeadLock.log文本内容

  1. ######################## 2015-12-22 18:28:24 ########################
  2. LATEST DETECTED DEADLOCK
  3. ------------------------
  4. 151222 18:10:54
  5. *** (1) TRANSACTION:
  6. TRANSACTION 7A7BE4, ACTIVE 324 sec starting index read
  7. mysql tables in use 1, locked 1
  8. LOCK WAIT 4 lock struct(s), heap size 1248, 3 row lock(s)
  9. MySQL thread id 8574, query id 6854603 172.16.22.243 root statistics
  10. select a,b,c from dltask where a='a8063001' and b='b99088948' and c='c71255728' for update
  11. *** (1) WAITING FOR THIS LOCK TO BE GRANTED:
  12. RECORD LOCKS space id 0 page no 1414168 n bits 336 index `uniq_a_b_c` of table `400_5.1_gsms`.`dltask` trx id 7A7BE4 lock_mode X locks rec but not gap waiting
  13. Record lock, heap no 171 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
  14. 0: len 8; hex 6138303633303031; asc a8063001;;
  15. 1: len 9; hex 623939303838393438; asc b99088948;;
  16. 2: len 9; hex 633731323535373238; asc c71255728;;
  17. 3: len 8; hex 0000000000000002; asc ;;
  18. *** (2) TRANSACTION:
  19. TRANSACTION 7A7BE5, ACTIVE 316 sec starting index read
  20. mysql tables in use 1, locked 1
  21. 4 lock struct(s), heap size 1248, 3 row lock(s)
  22. MySQL thread id 8575, query id 6854605 172.16.22.243 root statistics
  23. select a,b,c from dltask where a='a77584148' and b='b55038073' and c='c42437915' for update
  24. *** (2) HOLDS THE LOCK(S):
  25. RECORD LOCKS space id 0 page no 1414168 n bits 336 index `uniq_a_b_c` of table `400_5.1_gsms`.`dltask` trx id 7A7BE5 lock_mode X locks rec but not gap
  26. Record lock, heap no 171 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
  27. 0: len 8; hex 6138303633303031; asc a8063001;;
  28. 1: len 9; hex 623939303838393438; asc b99088948;;
  29. 2: len 9; hex 633731323535373238; asc c71255728;;
  30. 3: len 8; hex 0000000000000002; asc ;;
  31. *** (2) WAITING FOR THIS LOCK TO BE GRANTED:
  32. RECORD LOCKS space id 0 page no 1347520 n bits 432 index `uniq_a_b_c` of table `400_5.1_gsms`.`dltask` trx id 7A7BE5 lock_mode X locks rec but not gap waiting
  33. Record lock, heap no 190 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
  34. 0: len 9; hex 613737353834313438; asc a77584148;;
  35. 1: len 9; hex 623535303338303733; asc b55038073;;
  36. 2: len 9; hex 633432343337393135; asc c42437915;;
  37. 3: len 8; hex 0000000000000001; asc ;;
  38. *** WE ROLL BACK TRANSACTION (2)

使用上面脚本后 输出

[root@u1 deadlock]# sh grep_cut_sed_awk.sh 
LATEST-DETECTED-DEADLOCK




声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/676228
推荐阅读
相关标签
  

闽ICP备14008679号