cisc 5500 data analytics tools and scripting
play

CISC 5500 Data Analytics Tools and Scripting Special characters; - PowerPoint PPT Presentation

CISC 5500 Data Analytics Tools and Scripting Special characters; permissins; processes; vi Computer and Information Science Fordham University Table of contents 1. vi 2. Special characters in Bash (expansions and substitutions) 3. File


  1. CISC 5500 Data Analytics Tools and Scripting Special characters; permissins; processes; vi Computer and Information Science Fordham University

  2. Table of contents 1. vi 2. Special characters in Bash (expansions and substitutions) 3. File Permissions 4. Processes 1

  3. review • essential commands: pwd, cd, ls, cp, mv, rm, mkdir • important commands: man, cat, more/less, • very useful commands: wc, head, tail • what is a script 2 • I/O redirection: > , >> , < , |

  4. vi

  5. vi Difgerent modes: • command mode (example commands: i x r R o O dd p A $ :) • insert mode (ESC back to command mode) • ‘command-line’ mode 3

  6. Special characters

  7. Special characters Every command and its options, arguments are made of characters. Which characters are ‘regular’, not ‘special’? Alphabets, digits, underscores. The obviously special ones: spaces, ‘pound sign’ #, quotes. A useful command: echo 4

  8. asterisk and tilde • * - pathname expansion (the wildcard to match any characters in a pathname) 5 • ∼ - home directory expansion

  9. arithmetic expansion $$(( )) Include simple computation in the command or the script • only integers • supported operations: +, -, *, /, %, ** • space is NOT signifjcant • can be nested or include parenthesis echo $((5+ $((7-6)) )) echo $((5+ (7-6) )) 6

  10. brace expansion (list) Two types: 1. comma-separated list 2. range of integers or single character • it can have a preamble and/or a postscript • it can be reversed • no space embedded echo front-{a,b,c}-back echo backward: {100..95} 7 echo front-{a, b, c}-back # wrong!

  11. variables (parameter expansion) ‘variables’: store the value for later use x=7 echo $x Pay attention to the spaces 8

  12. Command substitute execute a command and replace with its result using backtick ̀ or $( ) echo my name is `whoami` echo yes, it is $(whoami) echo and the current time is `date` 9

  13. double quotes vs single quotes double quotes suppress special character (thus expansion) except for $, \, and ̀ Particularly, spaces single quotes leave the quoted more ‘literal’ (less expansion) echo * echo "*" echo "$USER" echo '$USER' 10

  14. escape characters Backslash \ makes special characters ‘normal’ characters. How does it work together with quotes? echo $USER echo \$USER echo "$USER" echo "\$USER" 11

  15. Permissions

  16. users and groups in Linux Users – every user has an ID and a name Groups - each user can belong to multiple groups What is the primary group? Command to fjnd out identity information id 12

  17. Linux fjle permissions What do we see from ls -l command? three ‘targets’: owner, group, all three permissions: read, write, execute Table 1: Type/permission fjelds type owner group everyone ? rwx rwx rwx 13

  18. change fjle permissions Two ways of using chmod command (change the permission) 1. set 2. modify – u for owner chmod 740 fjle2 chmod u+x fjle1 binary/octal representation r:4, w:2, x:1 4+2+1 = 7 14

  19. Processes

  20. processes What is a process? ps command Options: -ef top command kill command 15

  21. run a process in the background some-command & nohup some-command & Other related commands exit nice 16

  22. Summary • special characters • permissions • processes • vi 2020.9.3 17

  23. Questions? 17

  24. keyboard tricks and command history up arrow brings back the previously used command tab key auto-completes path names history command

  25. programmer’s jokes • There are 10 types of people in this world... • Why do programmers get confused between Halloween and Christmas?

  26. ”With great power comes great responsibility” Command su Substitute user – you need superuser password Command sudo As another user – confjgured by the superuser

Recommend


More recommend