Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

WGU D 848 Scripting Examples for Pen Test: Bash, PowerShell, Python Western Governors University LATES 2026

Rating
-
Sold
-
Pages
3
Grade
A+
Uploaded on
15-07-2026
Written in
2025/2026

Bash Variable Here’s our birthday cake price script in Bash: #!/bin/bash birthdaycake=2 birthdaycake =$(( birthdaycake / 2 )) echo The price of a birthday cake is $ birthdaycake When we run this code, we get the following result: The price of a birthday cake is 1 The = operator assigns a value to the variable. The $ operator before the variable name references the value stored in that variable. The double parenthesis (( )) tells Bash we are performing a calculation example divide birthdaycake/2 Bash Array dates=(1,2,5,16,23,25,28) date [0] The date[0] would give us the value of 1 from our array above. #!/bin/bash dates=(1,2,5,16,23,25,28) echo 'The third day offering a discount is: ' ${dates[2]} The script will produce the following output: The third day offering a discount is 5 When referencing an array in Bash we use the {} curly braces. Note: Bash uses zero-indexing which means when counting elements in an array, you start with 0. Therefore when dates[2] this would be the 3rd position in the array; as 1 would be in position 0, 2 would be in position 1, and 5 would be in position 2 (where our script points). WGU D 848 Scripting Examples for Pen Test: Bash, PowerShell, Python Scripting Language Operating System Example How to run PowerShell Windows (originally) Mac Linux Write-Host "Hello, world!" .1 Hello, World! PowerShell Variable Here’s our birthday cake price script in PowerShell: $ birthdaycake _price = 2.00 $ birthdaycake _price = $ birthdaycake _price / 2 Write-Host "The price of a birthday cake is" $ birthdaycake _price When we run this script, we get the following result: The price of a birthday cake is 1 PowerShell Array $dates=1,2,5,16,23,25,28 Write-Host 'The third day offering a discount is: ' $dates[2] The script will produce the following output: 'The third day offering a discount is: 5 Here we access the array element by using the array name and placing our index point is square brackets [].

Show more Read less
Institution
Wgu
Course
D 848

Content preview

WGU D 848 Scripting Examples for Pen
Test: Bash, PowerShell, Python
Operating Example How to run
System
Bash Linux #!/bin/bash chmod u+x hello.sh
Mac echo "Hello, world!" ./hello.sh
Hello, World!
Bash Variable
Here’s our birthday cake price script in Bash:
#!/bin/bash
birthdaycake=2
birthdaycake =$(( birthdaycake / 2 ))
echo The price of a birthday cake is $ birthdaycake

When we run this code, we get the following result:
The price of a birthday cake is 1

The = operator assigns a value to the variable.
The $ operator before the variable name references the value stored in that variable.
The double parenthesis (( )) tells Bash we are performing a calculation
example divide birthdaycake/2

Bash Array
dates=(1,2,5,16,23,25,28)
date [0]
The date[0] would give us the value of 1 from our array above.

#!/bin/bash
dates=(1,2,5,16,23,25,28)
echo 'The third day offering a discount is: ' ${dates[2]}

The script will produce the following output:
The third day offering a discount is 5

When referencing an array in Bash we use the {} curly braces.
Note: Bash uses zero-indexing which means when counting elements in an array, you start with
0. Therefore when dates[2] this would be the 3rd position in the array; as 1 would be in position 0,
2 would be in position 1, and 5 would be in position 2 (where our script points).

Written for

Institution
Course

Document information

Uploaded on
July 15, 2026
Number of pages
3
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$13.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Brainarium Delaware State University
View profile
Follow You need to be logged in order to follow users or courses
Sold
1969
Member since
3 year
Number of followers
1045
Documents
23691
Last sold
7 hours ago

3.8

333 reviews

5
155
4
63
3
57
2
16
1
42

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions