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:
  • 477 Vote(s) - 3.52 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Create an empty file on the commandline in windows (like the linux touch command)

#1
On a windows machine I get this error

> 'touch' is not recognized as an internal or external command, operable program or batch file.

I was following these [instructions][1] which seem to be linux specific, but on a standard windows commandline it does not work like this:

touch index.html app.js style.css

Is there a windows equivalent of the 'touch' command from the linux / mac os / unix world ? Do I need to create these files by hand (and modify them to change the timestamp) in order to implement this sort of command? I am working with node and that doesn't seem very ... node-ish...

[1]:

[To see links please register here]

Reply

#2
Use the following command on the your command line:

fsutil file createnew filename requiredSize

The parameters info as followed:

fsutil - File system utility ( the executable you are running )

file - triggers a file action

createnew - the action to perform (create a new file)

filename - would be literally the name of the file

requiredSize - would allocate a file size in bytes in the created file


Reply

#3
Windows does not natively include a `touch` command.

You can use any of the available public versions or you can use your own version. Save this code as `touch.cmd` and place it somewhere in your path

<!-- language: lang-dos -->

@echo off
setlocal enableextensions disabledelayedexpansion

(for %%a in (%*) do if exist "%%~a" (
pushd "%%~dpa" && ( copy /b "%%~nxa"+,, & popd )
) else (
type nul > "%%~fa"
)) >nul 2>&1

It will iterate over it argument list, and for each element if it exists, update the file timestamp, else, create it.
Reply

#4
You can also use [copy con \[filename\]][1] in a Windows command window (cmd.exe):

C:\copy con yourfile.txt [enter]
C:\CTRL + Z [enter] //hold CTRL key & press "Z" then press Enter key.
^Z
1 Files Copied.

This will create a file named `yourfile.txt` in the local directory.


[1]:

[To see links please register here]

Reply

#5
You can replicate the functionality of touch with the following command:

$>>filename

What this does is attempts to execute a program called `$`, but if `$` does not exist (or is not an executable that produces output) then no output is produced by it. It is essentially a hack on the functionality, however you will get the following error message:

> '$' is not recognized as an internal or external command,
operable program or batch file.

If you don't want the error message then you can do one of two things:

type nul >> filename

Or:

$>>filename 2>nul

The `type` command tries to display the contents of nul, which does nothing but returns an EOF (end of file) when read.

`2>nul` sends error-output (output 2) to nul (which ignores all input when written to). Obviously the second command (with `2>nul`) is made redundant by the `type` command since it is quicker to type. But at least you now have the option and the knowledge.
Reply

#6
No command – neither `type`nor `echo`– is necessary to emulate Unix's/Mac OS X's 'touch' command in a Windows Powershell terminal. Simply use the following shorthand:

$null > filename

This will create an empty file named 'filename' at your current location. Use any filename extension that you might need, e.g. '.txt'.

Source:

[To see links please register here]

(see comments)
Reply

#7


You can use this command: ECHO >> filename.txt

it will create a file with the given extension in the current folder.

**UPDATE:**

for an empty file use: **copy NUL filename.txt**
Reply

#8
Easy, example with txt file

echo $null >> filename.txt
Reply

#9
The answer is wrong, it only works when the file does not exist. If the file exists, using the first does nothing, the second adds a line at the end of the file.

The correct answer is:

copy /b filename.ext +,,

I found it here:

[To see links please register here]

Reply

#10
Yes you can use Node for Touch I just use that and its working all fine in windows Cmd or gitbash

[![enter image description here][1]][1]


[1]:
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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