3377 ex2

studied byStudied by 0 people
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 108

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

109 Terms

1

what does chsh do?

changes your login shell

New cards
2

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

New cards
3

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

New cards
4

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)

New cards
5

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)

New cards
6

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)

New cards
7

What would be in a textr in a makefile

included files and libraries

New cards
8

echo -n “Hello”

print “Hello” without a newline

New cards
9

echo -e “Hello\nWorld”

print “Hello”

“World”

New cards
10

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

Hi, \n this is a test.

New cards
11

echo -e "Hello\aWorld"

will trigger an alert sound if enabled

New cards
12

echo -e "Hello\bWorld"

“HellWorld”

New cards
13

echo -e "Hello\cWorld"

“Hello”

New cards
14

echo -e "Hello\fWorld"

“Hello” followed by form feed

New cards
15

echo -e "Hello\rWorld"

“World”

New cards
16

echo -e "Hello\tWorld"

“Hello World”

New cards
17

echo -e "Hello\vWorld"

Hello

World

New cards
18

name="Fatima"

echo 'Hello, $name'

“Hello, $name”

New cards
19

what does set do

will see all shell variables and functions

New cards
20

unset

removes variables or function from the current shell enviorment

New cards
21

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

New cards
22

PS1

set to the string used as your prompt sign

New cards
23

PS2

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

New cards
24

CD

set to absolute pathname

New cards
25

SHELL

set to the full pathname of your login shell

New cards
26

TERM

sets your terminal type

New cards
27

TZ

sets the time zone that you are in

New cards
28

echo "Today is `date`"

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

New cards
29

what does ; do

allows multiple commands on the same line

New cards
30

(ls -C ; date ; pwd) > outfile

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

New cards
31

what does & do

sends command to run in the background

New cards
32

pipe operator |

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

New cards
33

-n

number all output lines

New cards
34

-A

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

New cards
35

-b

number only non-empty output lines

New cards
36

cut -c 1-5 data.txt

print the first 5 characters from each line

New cards
37

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

print the first and third columsns using , as delimiter

New cards
38

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

will print hi and the thanks for wiating after 10s

New cards
39

wc command

counting command takes file as an argument

New cards
40

wc -l example.txt

num example.txt

New cards
41

ps -a

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

New cards
42

ps -f

displays full list of information including the full command line

New cards
43

kill command

terminates process

New cards
44

tee command

New cards
45

ls _C | tee dir.list

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

New cards
46

grep command

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

New cards
47

grep UNIX myfile

finds the lines that contain the word UNIX in myfile

New cards
48

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

apple

banana

New cards
49

grep -i "apple" fruits.txt

Apple; makes the search regardless of upper or lower

New cards
50

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

fruits.txt; the file that the word is in

New cards
51

grep -n "apple" fruits.txt

1:apple

New cards
52

grep -v "apple" fruits.txt

banana

cherry

words that are not apple

New cards
53

sort -b data.txt

will ignore leading blanks when sorting

New cards
54

sort -d data.txt

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

New cards
55

sort -f data.txt

will sort ignoring upper and lower case

New cards
56

sort -n numbers.txt

sort numbers in a file

New cards
57

sort data.txt -o sorted_data.txt

sort and save th output in data.txt

New cards
58

sort -r data.txt

sort in reverse order

New cards
59

what is shell script

a command language - interpreted not compiled

New cards
60

sh command

run a script

New cards
61

$0

contains the name of the script

New cards
62

$1, $2…

contains the first through x command line parameters

New cards
63

$#

conatins the number of command line parameters

New cards
64

$@

contains all command line parameters: $` $2…

New cards
65

$?

conatins the exit status of the last command

New cards
66

$*

contains all command line parameres

New cards
67

$$

conatins PID number of the executing process

New cards
68

what does the read command do

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

New cards
69

exit n

exit

New cards
70

echo $?

print exit status of the last executed command

New cards
71

num1 -eqnum2

is num1 equal to num2

New cards
72

num1 -nenum2

is num1 not equal to num2

New cards
73

num1 -gtnum2

is num1 greater than num2

New cards
74

num1 -genum2

is num1 greater than or equal to num2

New cards
75

num1 - ltnum2

is number1 less than num2

New cards
76

num1 -lenum2

is num1 less than or equal to num2

New cards
77

string1 = string2

does string1 match string2

New cards
78

string1 != string2

does string1 not match string2

New cards
79

-n string

does string conatin characters (nonzero length)

New cards
80

-z string

is string an empty string(zero length)

New cards
81

-r filename

does filename exist and is it readable

New cards
82

-w filename

does filename exist and is it writable

New cards
83

-s filename

does filname exist and does it have a nonzero length

New cards
84

-f filename

does filename exist, but is it not a directory file

New cards
85

-d filename

does filename exist and is it a directory file

New cards
86

${variable: -string}

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

New cards
87

${variable: +string}

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

New cards
88

${variable: =string}

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

New cards
89

${variable: ?string}

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

New cards
90

expr 10 \* 2

20

New cards
91

expr 10 \% 3

1

New cards
92

x=`expr $x + 1`

adds 1 to x

New cards
93

can you use expr and let interchangibly

yes

New cards
94

for format

for variable

in list-of-values

do

  • commands

  • last command

done

New cards
95

while format

while

do

commands

last command

done

New cards
96

until

until

do

commands

last

done

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

New cards
97

alias command

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

New cards
98

history command

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

New cards
99

how to restart the history

remove the .sh_history

New cards
100

history 104

start from the command number 104

New cards
robot