How to do it...

  1. At the Bash prompt, enter ls -l to list out all the files along with the metadata that the command shows by default.
  1. Go to the terminal that has PowerShell running, and type in Get-ChildItem at the prompt.
  1. Now, let us 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}'
  1. Next, let us pick the same information on PowerShell as well.
Get-ChildItem | select LastWriteTime, Name

If you notice, the output is very similar in both the cases, however, with PowerShell, you see the names of the columns as well, which means that you don't 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 use the awk command to manipulate the text output.

  1. Let's go one step further and create a sub-directory with a space in the name.
$ mkdir 'test subdirectory'
$ ls -l | awk '{print $6, $7, $8, $9}'

Notice that what should have been test subdirectory, appears as test.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.80.45