Find a file type and verify a line exists replace if value is different than expected -


i'm trying write batch file search directory file type. after find file name need read file verify line exists , overwrite line if different specific value.

if on unix/linux system, can this:

find . -name "*.txt" | xargs -l1 sed -i.bak 's/old contents/new contents/' 

this search current directory (and subdirectories) files end ".txt". each file finds, lines have "old contents". if finds such line, replace "new contents", , save old file previous name plus ".bak".

if on windows, install msys or cygwin, , same command.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -