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

cisc 5500 data analytics tools and scripting
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

CISC 5500 Data Analytics Tools and Scripting

Special characters; permissins; processes; vi

Computer and Information Science

Fordham University

slide-2
SLIDE 2

Table of contents

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

1

slide-3
SLIDE 3

review

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

2

slide-4
SLIDE 4

vi

slide-5
SLIDE 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

slide-6
SLIDE 6

Special characters

slide-7
SLIDE 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

slide-8
SLIDE 8

asterisk and tilde

  • * - pathname expansion (the wildcard to match any characters

in a pathname)

  • ∼ - home directory expansion

5

slide-9
SLIDE 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

slide-10
SLIDE 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} echo front-{a, b, c}-back # wrong!

7

slide-11
SLIDE 11

variables (parameter expansion)

‘variables’: store the value for later use x=7 echo $x Pay attention to the spaces

8

slide-12
SLIDE 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

slide-13
SLIDE 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

slide-14
SLIDE 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

slide-15
SLIDE 15

Permissions

slide-16
SLIDE 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

slide-17
SLIDE 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

  • wner

group everyone ? rwx rwx rwx

13

slide-18
SLIDE 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

slide-19
SLIDE 19

Processes

slide-20
SLIDE 20

processes

What is a process? ps command Options: -ef top command kill command

15

slide-21
SLIDE 21

run a process in the background

some-command & nohup some-command & Other related commands exit nice

16

slide-22
SLIDE 22

Summary

  • special characters
  • permissions
  • processes
  • vi

2020.9.3 17

slide-23
SLIDE 23

Questions?

17

slide-24
SLIDE 24

keyboard tricks and command history

up arrow brings back the previously used command tab key auto-completes path names history command

slide-25
SLIDE 25

programmer’s jokes

  • There are 10 types of people in this world...
  • Why do programmers get confused between Halloween and

Christmas?

slide-26
SLIDE 26

”With great power comes great responsibility”

Command su Substitute user – you need superuser password Command sudo As another user – confjgured by the superuser