courses.cs.washington.edu · –mkdir hw1/{old,new,test} – hw1/old, hw1/new, hw1/test – ~bob – [abc] [a-c]

Post on 19-Oct-2020

7 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

Transcript

● – – grep–

● ●

● ● ● ● ●

● ls -l *.txt●

– –

● – mkdir hw1/{old,new,test}

– hw1/old, hw1/new, hw1/test

● – ~bob

– ~

● *, ?, [–

● *

● ?

● [ ]– [abc][a-c]

● [!abc] [^abc]

● “. ”●

– mv mytaxes*19* very-old

– mv mytaxes*200[0-4]* old

abcdef  abcXdef  abcXXdef  abcYdef  CVS  zzzz

> ls abc*def

abcdef  abcXdef  abcXXdef  abcYdef

> ls abc?def

abcXdef  abcYdef

> ls [!zC]*

abcdef  abcXdef  abcXXdef  abcYdef

● \x x

● 'xxx'

● “xxx”$``\

a.txt, a*.txt, a?*.txt

> ls a*.txt

a?*.txt  a.txt  a*.txt

> ls a\*.txt

a*.txt

> ls a\?\*.txt

a?*.txt

> ls “a?*.txt”  ls 'a?*.txt'

a?*.txt

● history

● !– !!

– !n

– ●

● – ~/.bashrc

● ●

– alias ls=”ls ­­color”

– alias ls

– unalias ls 

● ● “ ”

C-x C-f:

C-x 5 f

C-x C-s

C-x C-w

C-x C-c:

C-x b

C-g:

● C-k

● C-y

● M-/MESC

● C-x 2C-x 0● ●

● “”

● ● ●

● ●

– ●

– – $?

● “ ”

● –

● –

● – –

● cmd < file

● cmd > file

● cmd >> file

● cmd 2> file

● cmd &> file

man ls > manual­page.txt

man idonotexit > manual­page.txt

man idonotexit 2> manual­page.txt

man ls > manual­page.txt 2>&1

man idonotexist > manual­page.txt 2>&1

man ls &> manual­page.txt

man ls >> manual­page.txt

history > my­history

cmd1 | cmd2

● –

– wc –help | less– history | grep man

● cmd1; cmd2

● cmd1 || cmd2– “ ”

● cmd1 && cmd2 ● cmd1 `cmd2`

– – mkdir `whoami`

– echo `date`

● – – – –

● #!/bin/bash– –

● ● trivial.sh

#!/bin/bash

echo “Hello world”

● chmod u+x my_script.sh

./my_script.sh

● bash my_script.sh

● source my_script.sh

– variable.sh

● #!/bin/bash

echo “Hello world”

● > chmod u+x trivial.sh

> ./trivial.sh● “ ” “ ”

“ ”

● #!/bin/bash

echo “Hello world”

● #!/bin/bash

echo “Hello world” > &2

● – i=42

– q=”What is the answer”

● – echo $q $i

– a=”The answer is $i”

● – a2=”The answers are ${i}s”

> chmod u+x variable.sh

> ./variable.sh

Hello World

Value of MYVAR is 3

> echo $MYVAR

              

> source variable.sh

Hello World

Value of MYVAR is 3

> echo $MYVAR

3             

● $i

● $0

● $#●

if [ $# -lt 1 ]

then

...

fi

● test [ – [ ]

– [ aabb = aabb ]

– [ 1 ­lt 5]

–  [ ­e my­file ]

– -a-o● [ -f $1 -o -d $1 ]

– && ||● [ -f $1 ] || [ -d $1 ]

● – –

– ●

● “ ”

● – –

top related