Computing.Net > Forums > Disk Operating System > Extract part of a text line

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Extract part of a text line

Reply to Message Icon

Name: dualpurpose
Date: September 28, 2003 at 06:08:23 Pacific
OS: XP Pro Sp1
CPU/Ram: 2000/384mb
Comment:

Hi....
I need some help with a batch to extract only part of a text string in a file..eg:
Myfile.txt has lines consisting of "this is a text line"
I need to know how to remove "this" and output "is a text line" to another file?
the first word is the only part not needed i should mention each of the first word in each line ends with ">" without a space eg: "string>"
Any help would be appreciated :) thanks in advance.



Sponsored Link
Ads by Google

Response Number 1
Name: uli_glueck
Date: September 28, 2003 at 22:46:20 Pacific
Reply:


Maybe this helps:
FOR /f "skip=2 delims= " %%a in ('find "is a text line" Myfile.txt') do >%%a

skip=2 means not to seek in the first two lines
(not necessary)
delims=" is what you need. After= you give the
last sign before
the words you are seeking and the last sign. like
"delims=x " or whatever.
beginning and empty at the end of the word your
seeking for).

uli


0

Response Number 2
Name: dualpurpose
Date: September 29, 2003 at 00:29:55 Pacific
Reply:

Hi Uli..

This works but results in giving me the first word in the string...the part i dont need eg: "this> is a string" resulting in an output of "this>" ( using > as the delims)
Also i do not know what the strings consist of, the only constant is ">"
Am i making a mistake somewhere? i tried this....
FOR /f "skip=2 delims=>" %%a in ('find/v "0.0.0.0" Myfile.txt') do echo>%%a

I can still use this elsewhere though or something along those lines

thanks for your help

dual


0

Response Number 3
Name: uli_glueck
Date: September 29, 2003 at 10:48:33 Pacific
Reply:

Hi dual,

if I understand right I know the mistake.

"delims=>"
takes > as last sign.

"delims=>-"
takes > as first sign and - as last sign. (for example)

So you need a start and a end sign.
This should work.

uli


0

Response Number 4
Name: dualpurpose
Date: September 29, 2003 at 12:01:35 Pacific
Reply:

Hi again Uli...

Thanks for you help and time :)

I managed to solve it with a slight difference..here is my solution:
FOR /F "tokens=2,3* skip=2 delims= " %%i in ('find ">" Myfile.txt') do echo %%i %%j %%k>>line.txt

Myfile.txt contains :

this> is a line
this> is another line
this> is yet another line

line.txt contains :

is a line
is another line
is yet another line


Your first post gave me the insight :)

thanks again !

dual


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Extract part of a text line

extract parts of filename www.computing.net/answers/dos/extract-parts-of-filename/14294.html

Changing part of a file www.computing.net/answers/dos/changing-part-of-a-file/1128.html

Getting Contents of a Text File www.computing.net/answers/dos/getting-contents-of-a-text-file/13123.html