Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Well this may start out a tad bit confusing but here goes:
Dossy bit - I have managed to condense the output details from mem.exe in batch to get a single line of text using:
MEM.EXE | FIND.exe /I "Total memory" >> C:\r1.txt which produces in r1.txt:-
Total<1space> memory<6Spaces>131,008K<7spaces>489K<3spaces>130,519K (all 1 line in r1.txt the <space> bit is just to indicate blank space separations)I have heard of 2No utils which are used in UNIX but can be used in DOS (Batch) that can amend/remove text & numbers so that I am just left with say the first block of numbers without the comma's & the K's at the end of each block of numbers. The 2No programs are TR & SED, however I am unfamiliar with the syntax to remove Total memory, all the comma's & the K's from the first set of numbers then the remaining two blocks of numbers, comma's & K's also. Any one who is familiar with preferably TR, could they reply with the suitable syntax/code & squeeze/remove any blank spaces. The nearest stab i could make at it was, don't laugh!:
echo Totalmery | tr -d 'Totalmery' >> r1.txt then possibly to squeeze multiple charaters into one set numbers: ls -l | tr -s ' '
The removal of the 2 other blocks of numbers I haven't got a clue about?
I want to wind up with 131008 nothing else in r1.txt or possibly r2.txt.
Regards,
appreciably yours,
Dave

This can also be done with Perl. This perl command will do an inline edit of the Totalmery.
perl -pi -e 's/^\D+(\d+),(\d+).*/$1$2/' Totalmery
The sed command would be very similar, the key part is the regex (regular expression).
Using tr would not be the best choice, but if you plan on using it, you'll need to make several passes.

Hi FishMonger,
Thanks for the reply I don't have a clue about perl programming or compiling sorry! If I was to use TR in several passes what would the code be as TR is a smaller program?
If not what would the SED code be please. I was hoping to use this generally on different PC's with different amounts of RAM/MEM installed that would involve %Variables% way 2 complicated for me!
I have noticed that the above code presumeably wouldn't remove the other 2No blocks of numbers yes?Regards,
Dave

![]() |
chmod operation not permi...
|
Name of working directory
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |