How to search and get the values from the file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
somu_june
Posts: 30
Joined: 19 Jun 2013 20:26

Re: How to search and get the values from the file

#16 Post by somu_june » 21 Jun 2013 11:53

Hi dbenham/Squashman

Yes the code is working for the sample data that I provided, but the actual file has binary and ascii characters too. I'm trying to post the content of the file in the post but I'm getting an error message saying 649524 characters. The maximum number of allowed characters is 60000. I tried to post in code tab but no success. Is there a way I can paste the content of the file.


Thanks,
Raju

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to search and get the values from the file

#17 Post by foxidrive » 21 Jun 2013 12:44

Upload it to your web space and post a link.

somu_june
Posts: 30
Joined: 19 Jun 2013 20:26

Re: batch variable progress bar string manipulation

#18 Post by somu_june » 21 Jun 2013 16:35

Thank you all for your support . I uploaded file to below link and you can download the actual file that I'm talking about.

http://www.filehosting.org/file/details ... t_jobs.txt


Regards,
Somaraju

Squashman
Expert
Posts: 4488
Joined: 23 Dec 2011 13:59

Re: batch variable progress bar string manipulation

#19 Post by Squashman » 21 Jun 2013 17:01

somu_june wrote:Thank you all for your support . I uploaded file to below link and you can download the actual file that I'm talking about.

http://www.filehosting.org/file/details ... t_jobs.txt


Regards,
Somaraju

Put it on a different site. I am not giving them my email address to request the download.

somu_june
Posts: 30
Joined: 19 Jun 2013 20:26

Re: How to search and get the values from the file

#20 Post by somu_june » 22 Jun 2013 06:44

Here we go

https://www.box.com/s/81us5wjvnp5nfuxz17jm

I uploaded to box and sharing the link. Please let me know if this is ok.


Thanks,
Raju

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to search and get the values from the file

#21 Post by foxidrive » 22 Jun 2013 07:44

This works with your sample data here if you download GNUsed

Code: Select all

@echo off
sed -e "/BEGIN DSJOB/,/Identifier/!d" -e  "/BEGIN DSJOB/d" -e "s/^ *Identifier *//"  -e "s/\x22//g" Test_jobs.txt >found.txt



Load_all_search_file_into_WRK_table_MedMgmt
Seq_Find_What_jobs_use_attributes_MedMgmt

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to search and get the values from the file

#22 Post by foxidrive » 22 Jun 2013 07:55

This works using Dave's repl.bat

Code: Select all

type Test_Jobs.txt | repl "^(BEGIN DSJOB)\r?\n" "$1" m | findstr /r c:"BEGIN DSJOB.*Identifier " | repl ".*\x22(.*)\x22.*" $1 >found.txt

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: How to search and get the values from the file

#23 Post by dbenham » 22 Jun 2013 13:26

@foxidrive - You almost got it. Your FINDSTR command is missing a / before the c: option. ( or else remove the space so the option becomes /rc: ) The command as you gave it happens to work with the provided input, but I think it is fortuitous.

I would probably use " *" instead of ".*"

Code: Select all

type Test_Jobs.txt | repl "^(BEGIN DSJOB)\r?\n" "$1" m | findstr /brc:"BEGIN DSJOB *Identifier " | repl ".*\x22(.*)\x22.*" $1 >found.txt


Dave Benham

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to search and get the values from the file

#24 Post by foxidrive » 22 Jun 2013 22:54

Oops. It's funny that it worked with that syntax.

I would probably use " *" instead of ".*"


I wasn't sure if the whitespace was TABs and was too lazy to check. :) I just fiddled until it worked and wham!

somu_june
Posts: 30
Joined: 19 Jun 2013 20:26

Re: How to search and get the values from the file

#25 Post by somu_june » 23 Jun 2013 19:18

Thank you so much for the help. It's working now.

somu_june
Posts: 30
Joined: 19 Jun 2013 20:26

Re: How to search and get the values from the file

#26 Post by somu_june » 27 Jun 2013 09:31

Hi foxidrive,

I'm testing your command

Code: Select all

@echo off
sed -e "/BEGIN DSJOB/,/Identifier/!d" -e  "/BEGIN DSJOB/d" -e "s/^ *Identifier *//"  -e "s/\x22//g" Test_jobs.txt >found.txt


I'm getting output in double quotes like below

"CopyOfpxHmkEciPrcssDtExtr"
"CopyOfpxHmkEciReturnCdcData"
"CopyOfSeq_Eci_Return_Interface"
"CopyOfSeq_MstSeq_ECI_Return"
"CopyOfpxIBCPhpOutboundCount"
"CopyOfpxIBCPhpOutboundExtract"
"CopyOfSeq_MstSeq_Php"
"CopyOfSeq_Php_Interface"

is there a way to remove the double quotes beofre loading in to a file.


Thanks,
Raju

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to search and get the values from the file

#27 Post by foxidrive » 27 Jun 2013 20:55

The last command in the sed line removes double quotes. Are you sure you tested this code?

Try it again in an empty folder.

Post Reply