0

I need a little help here,

How can i remove all the " from the first line without touching the second line and then join the two lines as one? This is in a txt file and i need the change to be made in it.

line1->

curl "https://localhost:1234/wle//505?action=god&params=" 

line 2-> with more than 9000 characters

{"some text to join after params= that contains" and {}[]/,:"}

Hope someone can help. Thanks

razstec
  • 21
  • 4
  • without double quoting the URL you've to escape chars otherwise being interpreted by cmd.exe when executing the lines `&` -> `^&` A `"` in a string enclosed in double quotes can be escaped with a backslash. Otherwise your question is unclear to me. –  May 04 '17 at 15:32
  • Please ignore line1-> and line2->, they are just to explain how its presented in text file. An yes, second line starts with { – razstec May 04 '17 at 16:36
  • 1
    AS [SO] is aa programmers site, you should edit the question to show the code you have and the expected result. –  May 04 '17 at 16:39

2 Answers2

0

edited to match comment 9000 characters, and cmd cant hold that many characters (simple: write first line without line feed, add second line): (if there still are too many characters, jrepl.bat can help)

@echo off
setlocal enabledelayedexpansion
<c.txt (
  set /p "line1="
  set /p "line2="
)
<nul >c.txt set /p "=!line1:"=!"
>>c.txt echo %line2%

read the two lines into two variables, write both back to file, removing the quotes from the first one.

Note: Delayed expansion might/might not be needed for each of the variables (maybe separately), depending on present characters. (here the & in the first line needs delayed expansion).

another edit to match only the second line. Process the first line as above. For the second line, just use more +1. This will work regardless of the line length. Contra: you have to use a secondary file. Pro: no problems with special chars (in the second line).

@echo off
setlocal enabledelayedexpansion
<c.txt set /p "line1="
<nul >c.out set /p "=!line1:"=!"
more +1 c.txt >>c.out
move /y c.out c.txt
Community
  • 1
  • 1
Stephan
  • 53,940
  • 10
  • 58
  • 91
0
@echo off
setlocal EnableDelayedExpansion

< input.txt (
   set /P "line="
   < NUL set /P "=!line:"=!"
   findstr "^"
) > output.txt
move /Y output.txt input.txt
Aacini
  • 65,180
  • 12
  • 72
  • 108