CS265

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

A Bash script MUST have execute permissions to be able to run.

False

In AWK, $0 is the first field of the current record

False

In a regular expression, .? matches exactly one character

False

Is this a valid statement in C? for (int i = 0; i < 10; i++)/* Do something */

False

The following statements are equivalent c="X" c='X'

False

The output of the gcc compiler is always a complete executable.

False

The system administrator can look at your password

False

There is NO difference between [ ] and [[ ]] in Bash.

False

These two commands give the same output wc -w x wc -w < x

False

This is valid C code. char s1[10], s2[10]; s1="CS265"; s2=s1;

False

Use long variable names everywhere, for clarity

False

Use short variable names everywhere, to save space

False

Use sizeof() to find that the string "Dimitra" has 7 characters.

False

Weak quoting (double quotes) inhibits name globbing and parameter expansion.

False

When main does not return any values, it's return value can be declared as void.

False

When you change working directories, your current working directory will be added to the PATH parameter.

False

You cannot redirect the standard input and the standard output at the same time.

False

a is NOT matched by the regular expression [aa|hh]

False

cat is matched by the regular expression [^hcb]at

False

Which symbol is used to separate more than one command in the same command line?

;

What is a hidden file or directory?

A file with a filename that begins with a . (dot)

What is a hidden file or directory?

A filename that begins with a . (dot)

What is a side-effect of a function?

Any change that persists after the function exits

How do we redirect I/O in Unix?

By using > < or |

Suppose c is a char variable. If the ASCII character encoding for 'A' is 65 what is the output of the printf command below: c=65; c = c+ 1; c++; printf("%c \n", c);

C

In C all variables have a type, but implicit conversions are possible. This is because ...

C supports a typing system that is weakly enforced

What permission do you need to enter a directory

Execute

Sometimes these two commands have identical behavior command > output command >> output

True

The ASCII character set does not contain an EOF character. There is no EOF character.

True

The following is a valid Bash for loop: for (( i=0; i<3; ++i )) ; do echo $i done

True

The following two commands are equivalent ls -lF ls -l -F

True

This commandtest 1 \< 2is equivalent to this command[ 1 \< 2 ]

True

[[ ]] supports all of the tests supported by [ ].

True

catt is matched by the regular expression (h|c|b)at*

True

hello (at the end of a line) is matched by lo$

True

multi-programmer task should have coding standards to be followed by each programmer

True

which f tells you where in the filesystem the executable f is located.

True

Standard IO functions return EOF when

When the EOF condition is detected (no more characters to read

The command ["$foo"=bar && "$bar"=foo] is not syntactically correct. Which one of the statements below fixes the command? Check all that apply.

["$foo"=bar -a "$bar"=foo] [["$foo"=bar && "$bar"=foo]]

Given a variable dir that contains a filename, write a single command using [[ ]] to check if dir is an existing directory that contains a file called index.html.Don't use if - just show the test.Quote your variables but don't use curly braces (you won't need them).

\[\[ \s*-d \s*"\$dir" \s*&& \s*-[ef] \s*"\$dir/index.html" \s*\]\]

Given two strings, stored in variables s1 and s2, write a test using [ ] to determine if s1 comes after s2 in the dictionary.Don't use if - just show the test.

\s*\[ \s*"\$s1" \s*\\> \s*"\$s2" \s*]|\s*\[ \s*"\$s2" \s*\\< \s*"\$s1" \s*]

What is the output of the following command?echo {a..c} abc

\s*a\s+b\s+c\s*

Show the command to set permissions on file foo so that the user has read and write, the group has read and write, and everybody else has only execute.

\s*chmod\s+661\s+foo\s*|\s*chmod\s+u=rw,g=rw,o=x\s+foo\s*

Which utility allows you to search for files by name, type, time, etc.?

\s*find\s*

Given: foo="Gargleblaster" What is the output of: echo ${foo:2:3}

\s*rgl\s*

When we don't care about the output of a command, we can redirect it to

a special device

What is a phony target in the makefile?

a target that is not a filename

Which awk command outputs all lines where the second field contains onlythe string xyzzy and where the third field exactly matches the first field:

$1 == $3 && "xyzzy" == $2 { print }

User abc types echo "\$USER is $USER". What is printed?

$USER is abc

Use a single ls command to list all files that either begin with rt or end with rt

(\s*ls \s*rt\* \s*\*rt)|(\s*ls \s*\*rt \s*rt\*)

What will the following commands print?[ 1 = 2 ]; echo $?

1

POSIX defines a text file as a file containing a sequence of lines and in turn each line as a sequence of non-newline characters followed by one newline. How many characters are in a text file that contains the following two lines: CS265 CS571

12

We define the function fun as void fun(int *ptr) { *ptr = 20; } If a=10 and we call the function fun(&a), what would be the value of a afterwards?

20

What is the output of the following C program? int i = 1;switch (i++) {case 1: printf("%d", ++i);case 2: printf("%d", i++);}

33

What are i and j set to after the following code executes i = 5;j = i++;j += ++i;

7,12

If you start the bash program from within a bash shell , what kind of shell will you be creating? Check all that apply.

Non-login Interactive

What will the following command print if file exists?[ -e file ]

Nothing - the command will only set the exit code

Match the Bash parameters on the left with their descriptions on the right. $$ $? $PWD $PATH $USER $HOME $PS1

PID of the shell exit status of the last command prints the current working directory list of directories to search for commands User's ID User's home directory The primary prompt string (i.e. the text you see on each line before you type commands, e.g. abc123@tux2:~$).

Match the Bash metacharacters on the left with their descriptions on the right. ; " ' # \ > I <

Separates commands on the same line Weak quote Strong Quote Line comment Escape character Redirects stdout Pipe Redirects stdin

If you want a user to run your script without having to specify an interpreter, what should be the first line of your script?

Sha-bang

Check all that apply about an operating system

The OS manages the memory of a computer The OS is responsible to ensure that processes run in isolation from each other An OS is a resource manager The OS interacts with users via a shell program

Choose the statements that are true about C

There is a NULL character ('\0') at the end of every string

What is the output of the following command?(true && echo "Thing 1") || echo "Thing 2"

Thing 1

What is the output of the following command?(false && echo "Thing 1") || echo "Thing 2

Thing 2

(( )) can be used to evaluate arithmetic expressions.

True

A Unix shell is a program.

True

C is faster than python because C is a compiled language.

True

If c is a int, the following is a valid condition in C ((c == 'Y' || (c = 'Y'))

True

In a regular expression, [xyz] matches exactly one character

True

What is the output of this command gcc test.c

a.out

Suppose a and b are int variables and x is a float variable. Suppose that we call scanf as follows scanf("%d%f%d", &a,&x,&b); If the user enters 1.2 3 4 what will the values of a, b and x be?

a=1 x=0.2 b=3

Suppose the contents of the file test.txt is czar dAze maZe lAZy HAZY what would the output of this command be? tr '[A-Z]' '[a-z]' < test.txt

all lowercase

To exit this loop and continue script execution, you could use:

break

Which command is used to assign only read permission to all three categories of the file 'note'?

chmod ugo=r note

How can I execute three commands one after another? Check all that apply.

cmd1 cmd2 cmd3 cmd1;cmd2;cmd3

To exit the current loop iteration and skip to the next iteration, you could use:

continue

The statement cp $file $target will not work if $file contains spaces. Which one of the following commands will fix the statement?

cp "$file" "$target"

The command make drexel will

create the executable if drexel.c is in the current directory

What permissions is 777

everybody reads, wrties, executes

To exit this script, you could use:

exit

Which of the following command deletes all files whose filename ends in .tmp?

find -name "*.tmp" -print | xargs rm -rf

running the make command without any arguments starts which of the following targets?

first target whose name does not start with a

How do i undo a git add before commit?

git rm

The following git command git reset [ < mode > ] [ < commit > ] resets the current branch HEAD to commit and possibly updates the index (resetting it to the tree of commit ) and the working tree depending on mode , which can be one of the following: -- soft Does not touch the index file or the working tree at all. -- mixed Resets the index but not the working tree (the changed files are preserved but not marked for commit). This is the default option. -- hard Resets the index and the working tree. Any changes to tracked files in the working tree since commit are discarded. -- merge Resets the index and updates the files in the working tree that are different between commit and HEAD but keeps those that are different between the index and working tree -- keep Resets the index entries and updates files in the working tree that are different between commit and HEAD. If a file that is different between commit and HEAD ha

hard

The shell:

is a command interpreter, provides a user interface

Consider the following bash script. What is wrong with this? Check all that apply. for f in $(ls *.jpg)do some command $f done

it does not work if the filename contains whitespace it does not work if the filename contains a glob character (common name for * ? [] )

Which command is used to terminate a process?

kill

Match the options with the associated behavior of ls ls -a ls -l ls -F ls -R

list hidden files display a long list of info about files display a/after directory recursively list subdirectories

When you ssh into tux, what kind of shell are you getting?

login interactive

what does the following command do? rm -rf

operates recursively deletes files including directories

What permissions do you need to see the contents of a directory?

read

What permissions are included in 700?

read for owner write for owne

Match the command with its meaning cat tail touch ls

shows the contents of a file shows the end of a file create a new empty file list files

Choose the command that creates a tar file

tar cvf file

The makefile starts executing from

the first target whose name does not start with a . (dot)

getopts is a useful utility to process command line options.

true

If v and value are local variables in a bash script, check the statement that represents a correct assignment

v=$value

Which awk command outputs the sum of the first two fields on every line:

{ print $1+$2 }


Ensembles d'études connexes

MEA1304 QUIZZES FOR FINAL CH 6-10

View Set

ACG 2071 Test 3 Multi Choice (Chapter 11)

View Set

Chapter 6: The circulatory system

View Set

SOCI305 Marriage and the Family Test 2

View Set