Four Flashcards

1
Q

what are the file descriptor number of standard file input and output

A

stdin 0 cat output.txt

stderr 2 command file 2> errorfile.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to create an empty file

A

> newfile.name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to discard unwanted output

A

command > /dev/null

The output to /dev/null is ignored by the shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to discard both the output and the error output

A

command &> /dev/null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The cheat sheet for file checkings

A

Operator Description

  • a file Returns true if file exists
  • b file Returns true if file exists and is a block special file
  • c file Returns true if file exists and is a character special file
  • d file Returns true if file exists and is a directory
  • e file Returns true if file exists
  • r file Returns true if file exists and is readable
  • s file Returns true if file exists and has a greater size that zero
  • s file Returns true if file exists and has a greater size that zero
  • w file Returns true if file exists and is writable
  • x file Returns true if file exists and is executable
  • N file Returns true if the file exists and has been modified since it was last read
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the normal exit value of a successful command

A

$? which is always 0 when command is implemented successfully

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the value of grep command when the string is not present

A

the exit value is non-zero then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to specify a exit value for a script

A

when exit is explicitly given, the exit value is the value of the last command

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is command1 && command2

and command1 || command2

A

command1 && command2: command2 is executed iff command1 gives a 0 exit value
command1 || command2: command2 is executed iff command1 gives a non-zero value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the difference between

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

grep into string

A

grep “string”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

redirect error output

A

./scripts.sh 2>scripts.err

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Append a output

A

command_output&raquo_space; file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

strd output to strd output

A

2>&1

error output to standard output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what does

A

-tells the I/O that in the file, the leading tab character is ignored

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

what does quoting or escaping a limitstring in redirecting the input do?

A

this will tells the redirection that in the contxt, the $,’ and \ will be escaped.