设置变量:
在 shell中设置变量和python中类似:

  1. #!/bin/bash
  2. variable=value
  3. variable='value'
  4. variable="value"
  5. echo $variable
  6. echo ${variable}

单引号和双引号的区别:

  1. #!/bin/bash
  2. name="silence"
  3. sentence1="My name is ${name}"; // My name is silence
  4. sentence2='My name is ${name}'; // My name is ${name}

控制台颜色

  1. // Colors reference
  2. // You can use the following as so:
  3. // console.log(colorCode, data);
  4. // console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`);
  5. //
  6. // ... and so on.
  7. export const reset = "\x1b[0m"
  8. export const bright = "\x1b[1m"
  9. export const dim = "\x1b[2m"
  10. export const underscore = "\x1b[4m"
  11. export const blink = "\x1b[5m"
  12. export const reverse = "\x1b[7m"
  13. export const hidden = "\x1b[8m"
  14. export const black = "\x1b[30m"
  15. export const red = "\x1b[31m"
  16. export const green = "\x1b[32m"
  17. export const yellow = "\x1b[33m"
  18. export const blue = "\x1b[34m"
  19. export const magenta = "\x1b[35m"
  20. export const cyan = "\x1b[36m"
  21. export const white = "\x1b[37m"
  22. export const black = "\x1b[39m"
  23. export const BGblack = "\x1b[40m"
  24. export const BGred = "\x1b[41m"
  25. export const BGgreen = "\x1b[42m"
  26. export const BGyellow = "\x1b[43m"
  27. export const BGblue = "\x1b[44m"
  28. export const BGmagenta = "\x1b[45m"
  29. export const BGcyan = "\x1b[46m"
  30. export const BGwhite = "\x1b[47m"