BASH Cmds Flashcards

(35 cards)

1
Q

What is the syntax you write at the start?

A

!/bin/ksh

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

How do we allow our program to run in bash?

A

command 1:
chmod +x example.ksh
command 2:
./example.ksh

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

what is echo?

A

output
eg. echo hello

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

What is read?

A

Userinput when script is ran the saved to a variable
eg. read variable

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

What is cat?

A

display the content of a file
cat filename

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

What is cp?

A

To copy a file
cp source_file destination_file

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

How is a variable outputted?

A

using a $

variable = 15
echo $variable

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

What does who| wc -1 do?

A

displays the no. of users logged on

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

What is the equal to operators in bash?

A

-eq

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

What is the not equal to than operator in bash?

A

-ne

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

What is the less than or equal to operator in bash?

A

-le

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

What is the greater than operator in bash?

A

-gt

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

What is the equal to operators in bash?

A

-eq

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

What is the greater than or equal to operators in bash?

A

-ge

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

What is the file test operator (-e) in bash

A

Checks if a file exists

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

What is the file test operator (-d) in bash

A

Checks if a directory exists

17
Q

What is the file test operator (-f) in bash

A

Checks if a file is a regular file

18
Q

What is the file test operator (-s) in bash

A

Checks if a file is not empty

19
Q

How is a if statement written in bash?

A

num=15
if [ condition ]; then
echo “Number is greater than 10”
fi

20
Q

What is fi in an if statement in bash?

A

How the if statement ends?

21
Q

How is a for statement written in bash?

A

for i in {1..5}; do
echo “Iteration $i”
done

22
Q

what does date do?

A

Displays the current date and time

23
Q

What does the variable $0 output?

A

Contains the name of the script
so if you run ./file.ksh

echo $0

console output: ./file.ksh

24
Q

What does the variable $1,$2,…$9 output?

A

Contains the command line parameter for whatever number is next to(basically $3 output the third word)
so if you run ./file.ksh hi this is a test by myself

echo $2
console output: this
echo $4
console output: test
echo $5
console output: by

25
What does the variable $@ output?
Contains all command line paramenters so if you run ./file.ksh this is a test by myself echo $@ console output: this is a test by myself
26
27
28
29
30
test command
31
32
expr
33
34
expr arthemtics
35