I have a file (Flags.txt
) that looks like this:
...
C_INCLUDES = ... ... .../xxx
...
CXX_INCLUDES = ... ... .../yyy
where the line with C_INCLUDES
can end with any string (here e.g xxx
).
At the end, the file shall look like this:
...
C_INCLUDES = ... ... .../xxx/
...
CXX_INCLUDES = ... ... .../yyy
Therefore I want to use a windows batch file (not possible to use sed
or awk
) to search for the name C_INCLUDES
and append at the end of the line the forward slash (but could be any smbol e.g "xxxz" or "xxx!" )?
I tried the solution from:
$original = "flags.txt"
$tempfile = "tmp.txt"
get-content $original | foreach-object {
if ($_ -match "^C_INCLUDES") {
$_ + "/" >> $tempfile
}
else {
$_ >> $tempfile
}
}
copy-item $tempfile $original
remove-item $tempfile
But it don't work
Thanks