Skip to content

Commit c92e55f

Browse files
authored
Merge pull request #50258 from v-thpra/azure-triage-fix-427039
Fix for User Feedback 427039: UUF - learn-pr - Exercise - Use Bash and grep to filter CLI output - Training | Microsoft Learn
2 parents 680aa2e + f596418 commit c92e55f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

learn-pr/student-evangelism/bash-introduction/includes/6-exercise-filter-cli-output.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
Until now, you've been running Bash commands on their own. Bash is powerful when combined with other tools, so let's get some practice by using Bash to filter output from the Azure CLI.
22

3-
1. Let's say you want to see an up-to-date list of the virtual machine (VM) sizes available in the westus region of Azure. You can do that with this command:
3+
1. Let's say you want to see an up-to-date list of the virtual machine (VM) SKUs available in the westus region of Azure. You can do that with this command:
44

55
```bash
6-
az vm list-sizes --location westus --output table
6+
az vm list-skus --location westus --output table
77
```
88

9-
1. You should see a long list of VM types as an output. To narrow down this list to the VM sizes that interest you, you can use `grep`, Linux's universal pattern-matching program. To find the "DS" sizes, popular for use in data science, use the following command:
9+
1. You should see a long list of VM types as an output. To narrow down this list to the VM SKUs that interest you, you can use `grep`, Linux's universal pattern-matching program. To find the "DS" SKUs, popular for use in data science, use the following command:
1010
1111
```bash
12-
az vm list-sizes --location westus --output table | grep DS
12+
az vm list-skus --location westus --output table | grep DS
1313
```
1414
1515
This pipes output from the `az` command to `grep`, which filters out lines that lack the "DS" string.
1616
1717
1. That's still a lot of VMs. You know that DS V2 VMs are a more recent series. Let's adjust the `grep` command to use a more intricate regular expression:
1818
1919
```bash
20-
az vm list-sizes --location westus --output table | grep DS.*_v2
20+
az vm list-skus --location westus --output table | grep DS.*_v2
2121
```
2222
23-
This filters out lines that don't match the regular expression `DS.*_v2`. You might recognize some of the characters in that expression from our discussion of "wildcards" in an earlier unit. Regular expressions make great use of wildcards.
23+
This command filters out lines that don't match the regular expression `DS.*_v2`. You might recognize some of the characters in that expression from our discussion of "wildcards" in an earlier unit. Regular expressions make great use of wildcards.
2424

2525
Regular expressions are a topic for another module, but come in handy for Bash scripting.
2626

0 commit comments

Comments
 (0)