R
R
Roman_ Outside2015-10-30 12:44:38
PowerShell
Roman_ Outside, 2015-10-30 12:44:38

How to remove extra duplicate lines in log file?

Good day, I
ran into a little trouble in PowerShell
When writing to a PowerShell session file, the Start-Transcript cmdlet creates the PS_ColdCopy.log file
in this file, the records are often repeated, it turns out something like
Transcript started, output file is D:\logs_view\PS_ColdCopy.log
Transcript started, output file is D:\logs_view\PS_ColdCopy.log
Transcript started, output file is D:\logs_view\PS_ColdCopy.log
Transcript started, output file is D:\logs_view\PS_ColdCopy.log
ROBOCOPY :: Robust File Copy for Windows
ROBOCOPY :: Robust File Copy for Windows
ROBOCOPY :: Robust File Copy for Windows
ROBOCOPY :: Robust File Copy for Windows
Question - why does he write extra lines to the log file? Because of this, it becomes inconvenient to read the log file.
Here is the text of the
chcp script 1251
# Beginning of the block of variables
$CurrentDate = get-date -format "dd.MM.yyyy" # Set the current date format
$LogFile = "D:\logs_view\PS_ColdCopy.log" # Set the path to relocate the log file
$BackupStoragePath = "\\Backup\week"
$LoginBackStor = "login"
$PassBackStor = "password"
Start-Transcript -Path $LogFile
# Mount network drive U:
net use * $BackupStoragePath /user:$LoginBackStor $PassBackStor
robocopy C:\Oracle\NETWORK\ADMIN\ *.ora $BackupStoragePath\$CurrentDate\Oracle_DataBase\C_Oracle\NETWORK\ADMIN\ /E /NP /Z /R:20 /W:60
net use * /delete /yes
Stop- transcript

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Saboteur, 2015-10-30
@new_Roman

stackoverflow.com/questions/7609884/delete-duplica...
You can try using batfiles, without powershell
@<"1.txt">"2.txt" (for /f "delims=" %%i in ('more' ) do @if not defined %%i (echo %%i& set %%i=*))

A
Anatoly, 2015-10-30
@rbobot

Or you can use a powershell:
Get-Content PS_ColdCopy.log | Select -Unique
Though on a subject there is nothing to tell, did not use this cmdlet.

S
Sergey SA, 2015-10-30
@resetsa

cat file | Get-Unique is the
only thing you may have to play around with the file encoding

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question