wzul

Ubuntu Terminal Cheat Sheet

Mar 21st, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.61 KB | None | 0 0
  1. VIM: x to delete left. X to delete right
  2.  
  3. Terminal echo:
  4.  
  5. \r => Erase everything in the same line before this statement
  6. \n => New Line (Enter)
  7. \t => Indent. Make space 5x
  8. \b => Backspace. Omit/Erase 1 character before this statement
  9. \c => Print the next output in the same line
  10. \033[1m => Bold the text. Everything.
  11. \033[0m => Normal the text.
  12.  
  13. Terminal tput:
  14.  
  15. clear => Clear Terminal
  16. lines => Display number of rows on screen (terminal size)
  17. cols => Display number of columns (terminal size)
  18. cup 15 20 => Where on the terminal we want to output a string. It can override existing output
  19. bold => Print in bold. Same with \033[1m
  20.  
  21. _____________________________
  22.  
  23. echo $?
  24. 0 => Success
  25. 1 => Failed
  26. _____________________________
  27.  
  28. echo "Enter source and target file names."
  29. read source target
  30. mv $source $target
  31.  
  32. Terminal if-then:
  33. if 0
  34. then
  35. echo "Your file success"
  36. elif => else if
  37. then
  38. else
  39. fi (closure for if-then-else statement)
  40.  
  41. Terminal Count:
  42.  
  43. Check number input between:
  44. [ $<variable> -lt 10 ]
  45. lt => less than
  46. gt => greater than
  47. le => less than and equal to
  48. ge => more than and equal to
  49. ne => not equal to
  50. eq => equal to
  51. must have space after [ and before ]
  52.  
  53. Terminal run check on files:
  54.  
  55. if [ -f $<variable file name> ] => 0 if file. 1 if folder
  56. -f => file
  57. -d => directory (folder)
  58. -c => character special file
  59. -b => blok/image/video file
  60. -r => Check read permission
  61. -w => Write permission
  62. -x => Execute permission
  63. -s => Size of file
  64. -z => Check null. If null, return 0
  65. -n => Check if more than 0. If more than 0, return 0
  66. -a => AND Logical Operator
  67. -o => OR Logical Operator
Add Comment
Please, Sign In to add comment