Batch: multiple tokens
|
Original Message
|
Name: marto
Date: March 15, 2008 at 16:56:46 Pacific
Subject: Batch: multiple tokensOS: VistaCPU/Ram: /Model/Manufacturer: / |
Comment: Hi everyone, I'd like to extract some words out of a txt file. Here's an example: mcdonnalds@pc1 account: marto/pass1 burgerking@pc2 account: test/pass2 Now I want to extract the words "mcdonnalds", "marto" and "pass1" into a new txt all on thesame line. And I'd like to have thesame for everyline again. I hope you guys can fix this. Thx in advance ;)
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: ghostdog
Date: March 15, 2008 at 20:52:15 Pacific
Subject: Batch: multiple tokens |
Reply: (edit)if you can download and install gawk here http://gnuwin32.sourceforge.net/pac... code: BEGIN { FS="[@:]" #set field delimiter to @ and : } /mcdonnalds/{ print $1,$3 # print 1st(mcdonnalds) and 3rd field (marto/pass1) # if you don't want the / , uncomment the below line # sub("/","",$3) } save the above as script.awk and from command line c:\test> gawk -f script.awk myfile.txt > newfile
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: IVO
Date: March 16, 2008 at 03:51:45 Pacific
Subject: Batch: multiple tokens |
Reply: (edit)@echo off> fileOUT.txt for /f "tokens=1,3,4 delims=@:/" %%a in (fileIN.txt) do ( echo.%%a %%b %%c >> fileOUT.txt) :: End_Of_Batch
Report Offensive Follow Up For Removal
|
Use following form to reply to current message: