Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 497 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cmd save " character to a file without new line

#1
Is that possible save a special character " to a string without new line?
I tried below codes ,but none of them working:

echo|set /p=""" >>C:\text.txt
echo|set /p=" >>C:\text.txt
echo|set /p=^" >>C:\text.txt
set /p=""" <nul >> C:\text.txt
set /p=" <nul >> C:\text.txt
set /p=^" <nul >> C:\text.txt
Reply

#2
Not a one-liner in the command-prompt but as a batch-file the following works for me:

>>output.txt (
echo|set/p="""
)

Or if you want to hit return to write it use the following, very similar one:

>>output.txt (
set /p=""" < nul
)

One could as well establish it to be a kind of a function to use dynamically:

>>"%~dp1" (
echo|set/p="""
)

To use this one, you pass the filename as first command-line argument as the following:

> addQuoteTo.bat "C:\my Path\toFile\file.txt"

Was an interesting thing to play around with :)
Reply

#3
You almost had it

<nul >"file.txt" set/p="""

but, as Squashman points, if you try to write to the root of your drive, you will need an elevated prompt
Reply

#4
<!-- language-all: lang-cmd -->

Here is a slightly different method which does not require the redirection to be put in front of the `set /P` command:

set /P =""^" < nul >> "C:\text.txt"

Since the last of the three quotation marks is escaped like `^"`, the remaining command line portion does not appear quoted and therefore, the redirection operators `<` and `>>` are recognised.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through