Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Unix/dos amending text

Original Message
Name: jackngill
Date: April 8, 2006 at 12:05:09 Pacific
Subject: Unix/dos amending text
OS: Windows/DOS
CPU/Ram: 384
Model/Manufacturer: Acer
Comment:
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


Report Offensive Message For Removal


Response Number 1
Name: FishMonger
Date: April 8, 2006 at 12:53:37 Pacific
Subject: Unix/dos amending text
Reply: (edit)
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.


Report Offensive Follow Up For Removal

Response Number 2
Name: jackngill
Date: April 8, 2006 at 14:56:44 Pacific
Subject: Unix/dos amending text
Reply: (edit)
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


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Unix/dos amending text

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC