2

I have a file that I am downloading daily what I want to do is create a script that reads the text file and deletes out any lines containing the string "---"

I started with "(get-content L:\holdings.txt) | where {$_ -ne "" | out-file holdings.txt"

This deletes all the blank lines without any issue, I then tried

$del -like "*-*"
"(get-content L:\holdings.txt) | where {$_ -ne $del | out-file L:\holdings.txt"

Which I though would delete out any of the lines of data, whilst it runs without error the line is not being deleted out...

I don't know if it's relevant but the line I want to delete will always be the second line as it is a comma delimited SQL batch file automation.

The file reads as follows

Advice Num ,Bargain Number
--------------------,-----------------

Just to try and give you a graphical representation that I am trying to resolve

Any ideas?

Regards

Richard

1 Answer 1

8

Solved it, a quick amendment and here it is (get-content "L:\movement.txt") -notmatch "---" | out-file "L:\movement.txt"

Sign up to request clarification or add additional context in comments.

1 Comment

hope it helps someone else in the future!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.