How can I copy the line of a textfile if the text meghana is in it from C:\dos\crusoe\src.txt and paste it in C:\dos\crusoe\trgt.txt

link|improve this question
feedback

migrated from stackoverflow.com Sep 14 '09 at 14:45

This question came from our site for professional and enthusiast programmers.

5 Answers

I believe on Windows you'd be looking for findstr - http://technet.microsoft.com/en-us/library/bb490907.aspx

For example:

findstr /x /c:<string> <source-file-name> > <target-file-name>
link|improve this answer
3  
Remember that > erases the target file while >> appends to it. – Sparr Dec 10 '10 at 5:40
feedback

I could write a .bat file that would do what you asked. However, what is it that you really want to do? A routine to copy the third word (space-delimited string of characters)? A routine to copy that particular word? Something more complex and/or flexible?

Also, I find doing this kind of processing in batch files to be awkward and inconvenient. I would strongly recommend looking into using a programming language (even just VB Script) to do this kind of work.

link|improve this answer
first give me the solution for this................ .......then the exact problem is on link..it was asked for unix...but know requirement is to implement in dos/windows stackoverflow.com/questions/1409565/… – Irveen Sep 14 '09 at 14:13
feedback

You might want to have look at awk. A GnuAwk version is available for DOS or Windows.

If you just want to copy every third word in each line of a file you can use a simple script:

{ print $3; }

You would then execute the script as follows:

awk "{print $3}" < C:\dos\crusoe\src.txt > C:\dos\crusoe\trgt.txt
link|improve this answer
feedback

Get mingw32 and use sed. Or, use the windows alternative: copy it out on a piece of paper and write it back...

link|improve this answer
@avir........i jst need to use dos cmds or bat files.......as per requiremnet – Irveen Sep 14 '09 at 14:07
feedback

Write a program to read your textfile data.txxt and copy the content within data1.txt

link|improve this answer
feedback

Your Answer

 
or
required, but never shown