Explanation of the Get-content parameter-readcount

Source: Internet
Author: User
Most users are more concerned about the latest logs, here is a simple example to get the last few lines of line from a text log: # show the latest 5 rows of windowsupdate.log files $logs = Get-content-path $env: windir \windowsupdate.log-readcount 0$logs[-5..-1] The above example returns the last 5 lines of text in the Windows Update log file. It is very efficient to perform because Get-content uses the –readcount 0 parameter. Readcount refers to the number of lines of text sent to the pipe each time, 0 for all, and 0 more efficient in the current scenario. However, there is another criticism, variable $logs will be in the form of an array of text stored in memory, and still contiguous memory. So there's a more efficient way to do this in PowerShell 3.0. # Displays the latest 5 rows of Windowsupdate.log files Get-content-path $env: Windir\windowsupdate.log-readcount 0-tail 5 The tail parameter here allows the get-content command to return only the text of the specified end line number. This avoids the problem of a large amount of text content residing in memory. Reference link: Accessing Latest Log File Entries

Explanation of the Get-content parameter-readcount

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.