
上QQ阅读APP看书,第一时间看更新
How to do it…
- At the Bash prompt, enter ls -l to list all of the files, along with the metadata that the command shows by default:

- Go to the Terminal that has PowerShell running and type in Get-ChildItem at the prompt:

- Now, let's pick only the name of the folders and the last modified date and time. This is done in Bash by passing the output of ls -l to awk:
ls -l | awk '{print $6, $7, $8, $9}'

- Next, let's pick the same information on PowerShell as well:
Get-ChildItem | select LastWriteTime, Name

As you may have noticed, the output is very similar in both cases. However, with PowerShell, you can see the names of the columns as well, which means that you do not have to look for further documentation. Also, the selection of columns is simpler in PowerShell; no text manipulation is required. On the other hand, in Bash, we can use the awk command to manipulate the text output.
- Let's go one step further and create a subdirectory with a space in the name:
$ mkdir 'test subdirectory'
$ ls -l | awk '{print $6, $7, $8, $9}'

Note that what should have been test subdirectory appears as test. Compare this with the output from PowerShell: