3377 ex2

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/108

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

109 Terms

1
New cards

what does chsh do?

changes your login shell

2
New cards

Makefile definition

A GNU utility that determines which pieces of a large program need to be compiled or recompiled; issues commands to compile and link them in an automated fashion

3
New cards

Variables in a Makefile

PROG = textr

CC = g++

CPPFLAGS = -g –Wall –I/usr/class/cs193d/textrInc

LDFLAGS = -L/usr/class/cs193/lib –lCoolFns

OBJS = main.o blurb.o database.o

4
New cards

Targets in a Makefile

$(PROG) : $(OBJS)

$(CC) $(LDFLAGS) -o $(PROG) $(OBJS)

main.o :

$(CC) $(CPPFLAGS) -c main.cpp

blurb.o : blurb.h

$(CC) $(CPPFLAGS) -c blurb.cpp

database.o : database.h

$(CC) $(CPPFLAGS) -c database.cpp

clean:

rm -f core $(PROG) $(OBJS)

5
New cards

Pre-req in a Makefile

$(PROG) : $(OBJS)

$(CC) $(LDFLAGS) -o $(PROG) $(OBJS)

main.o :

$(CC) $(CPPFLAGS) -c main.cpp

blurb.o : blurb.h

$(CC) $(CPPFLAGS) -c blurb.cpp

database.o : database.h

$(CC) $(CPPFLAGS) -c database.cpp

clean:

rm -f core $(PROG) $(OBJS)

6
New cards

Rules in a Makefile

$(PROG) : $(OBJS)

$(CC) $(LDFLAGS) -o $(PROG) $(OBJS)

main.o :

$(CC) $(CPPFLAGS) -c main.cpp

blurb.o : blurb.h

$(CC) $(CPPFLAGS) -c blurb.cpp

database.o : database.h

$(CC) $(CPPFLAGS) -c database.cpp

clean:

rm -f core $(PROG) $(OBJS)

7
New cards

What would be in a textr in a makefile

included files and libraries

8
New cards

echo -n “Hello”

print “Hello” without a newline

9
New cards

echo -e “Hello\nWorld”

print “Hello”

“World”

10
New cards

$echo “Hi, \n this is a test.”

Hi, \n this is a test.

11
New cards

echo -e "Hello\aWorld"

will trigger an alert sound if enabled

12
New cards

echo -e "Hello\bWorld"

“HellWorld”

13
New cards

echo -e "Hello\cWorld"

“Hello”

14
New cards

echo -e "Hello\fWorld"

“Hello” followed by form feed

15
New cards

echo -e "Hello\rWorld"

“World”

16
New cards

echo -e "Hello\tWorld"

“Hello World”

17
New cards

echo -e "Hello\vWorld"

Hello

World

18
New cards

name="Fatima"

echo 'Hello, $name'

“Hello, $name”

19
New cards

what does set do

will see all shell variables and functions

20
New cards

unset

removes variables or function from the current shell enviorment

21
New cards

shell variable rules

must begin with a lowercase or uppercase letter and not a digit, no spaces on either side of the equal sign ex. age=32

22
New cards

PS1

set to the string used as your prompt sign

23
New cards

PS2

set to the prompt sign that is displayed whenever you press RETURN

24
New cards

CD

set to absolute pathname

25
New cards

SHELL

set to the full pathname of your login shell

26
New cards

TERM

sets your terminal type

27
New cards

TZ

sets the time zone that you are in

28
New cards

echo "Today is `date`"

Today is Mon Oct 30 10:45:00 UTC 2024

29
New cards

what does ; do

allows multiple commands on the same line

30
New cards

(ls -C ; date ; pwd) > outfile

three commands in sequence, grouped together, with the output redirected to a file

31
New cards

what does & do

sends command to run in the background

32
New cards

pipe operator |

uses the output of one command as the input to another command

33
New cards

-n

number all output lines

34
New cards

-A

show all charcters inclufing non-printing charcters ex. ^I as tabs

35
New cards

-b

number only non-empty output lines

36
New cards

cut -c 1-5 data.txt

print the first 5 characters from each line

37
New cards

cut -d ',' -f 1,3 data.csv

print the first and third columsns using , as delimiter

38
New cards

echo “Hi, `sleep 10` Thanks for waiting”

will print hi and the thanks for wiating after 10s

39
New cards

wc command

counting command takes file as an argument

40
New cards

wc -l example.txt

num example.txt

41
New cards

ps -a

displays the status of all the active process, not just users

42
New cards

ps -f

displays full list of information including the full command line

43
New cards

kill command

terminates process

44
New cards

tee command

45
New cards

ls _C | tee dir.list

displays the current directory file names and also saves the output in dir.list

46
New cards

grep command

search for a specified pattern in a file or list of files

47
New cards

grep UNIX myfile

finds the lines that contain the word UNIX in myfile

48
New cards

grep -e "apple" -e "banana" fruits.txt

apple

banana

49
New cards

grep -i "apple" fruits.txt

Apple; makes the search regardless of upper or lower

50
New cards

grep -l "apple" fruits.txt vegetables.txt

fruits.txt; the file that the word is in

51
New cards

grep -n "apple" fruits.txt

1:apple

52
New cards

grep -v "apple" fruits.txt

banana

cherry

words that are not apple

53
New cards

sort -b data.txt

will ignore leading blanks when sorting

54
New cards

sort -d data.txt

sort with dictionary order; upper and lower case matter, upper first

55
New cards

sort -f data.txt

will sort ignoring upper and lower case

56
New cards

sort -n numbers.txt

sort numbers in a file

57
New cards

sort data.txt -o sorted_data.txt

sort and save th output in data.txt

58
New cards

sort -r data.txt

sort in reverse order

59
New cards

what is shell script

a command language - interpreted not compiled

60
New cards

sh command

run a script

61
New cards

$0

contains the name of the script

62
New cards

$1, $2…

contains the first through x command line parameters

63
New cards

$#

conatins the number of command line parameters

64
New cards

$@

contains all command line parameters: $` $2…

65
New cards

$?

conatins the exit status of the last command

66
New cards

$*

contains all command line parameres

67
New cards

$$

conatins PID number of the executing process

68
New cards

what does the read command do

used to read a line of input from standard input; accept input from user

69
New cards

exit n

exit

70
New cards

echo $?

print exit status of the last executed command

71
New cards

num1 -eqnum2

is num1 equal to num2

72
New cards

num1 -nenum2

is num1 not equal to num2

73
New cards

num1 -gtnum2

is num1 greater than num2

74
New cards

num1 -genum2

is num1 greater than or equal to num2

75
New cards

num1 - ltnum2

is number1 less than num2

76
New cards

num1 -lenum2

is num1 less than or equal to num2

77
New cards

string1 = string2

does string1 match string2

78
New cards

string1 != string2

does string1 not match string2

79
New cards

-n string

does string conatin characters (nonzero length)

80
New cards

-z string

is string an empty string(zero length)

81
New cards

-r filename

does filename exist and is it readable

82
New cards

-w filename

does filename exist and is it writable

83
New cards

-s filename

does filname exist and does it have a nonzero length

84
New cards

-f filename

does filename exist, but is it not a directory file

85
New cards

-d filename

does filename exist and is it a directory file

86
New cards

${variable: -string}

the valua of variable if it is set and not empty; otherwise the valus of string

87
New cards

${variable: +string}

the value of string if variable is set and not empty; otherwise variable is set to the value of string

88
New cards

${variable: =string}

the value of variable is it is set and not empty; otherwise variable is set to the value of string

89
New cards

${variable: ?string}

the value of variable if it is set and not empty; otherwise print the value of string and exit

90
New cards

expr 10 \* 2

20

91
New cards

expr 10 \% 3

1

92
New cards

x=`expr $x + 1`

adds 1 to x

93
New cards

can you use expr and let interchangibly

yes

94
New cards

for format

for variable

in list-of-values

do

  • commands

  • last command

done

95
New cards

while format

while

do

commands

last command

done

96
New cards

until

until

do

commands

last

done

-similar to while but will continue executing as along as the condition is false

97
New cards

alias command

for shortening the names of frequently used commands or changing command names

98
New cards

history command

keeps a list of all the commands you enter during the session

99
New cards

how to restart the history

remove the .sh_history

100
New cards

history 104

start from the command number 104