简体   繁体   中英

How to remove the first 3 symbols in a text file?

如何使用PowerShell删除文本文件中的前3个符号并保持文件名称相同?

Just read the file using the Get-Content cmdlet, remove the file using a regex that replaces the first three characters with nothing and finally write it back using the Set-Content cmdlet:

(Get-Content 'yourfilePath.txt' -raw) -replace '^...' | Set-Content 'yourfilePath.txt'

Note: You probably want to specify the encoding using the -Encoding parameter when writing the content back to the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM