Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

There is file that exists in each user profile directory and I need to remove the line from the file in each user profile directory. I'm using a batch script to go through each user profile directory, type the file, use findstr to not display the line, and then re-direct the output to itself. For whatever reason this is not removing the line.

SET ProfileBase=%SystemDrive%\Documents and Settings

for /f "tokens=*" %%a in ('dir /b /ad-h "%ProfileBase%"') do type "%ProfileBase%\%%a\myfile" | findstr /v display >> :%ProfileBase%\%%a\myfile"
share|improve this question
    
typo: "Docuemnts" -- not in your actual code, maybe? –  Lars Rohrbach Jun 22 '12 at 17:15
    
Ah yes, that was a typo here. I verified that it is correct in my actual code. –  hsatterwhite Jun 22 '12 at 17:22
add comment

1 Answer

Is using win32 versions of sed and find out of the question? Those could easily do it*. Also, PowerShell might be worth a look.

*) find /path/to/files -type f -iname 'filename' -execdir sed -i -e '/^exact line you want to disappear$/d' {} \;

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.