7 ms·
Another way to touch a file: cp /dev/null file Test if a port is listening without telnet: echo > /dev/tcp/address/port && echo Yes || echo No That's not ac
by cferr 5y ago
Another way to touch a file:
cp /dev/null file
Test if a port is listening without telnet:
echo > /dev/tcp/address/port && echo Yes || echo No
That's not actually a file. It's just a path Bash recognizes and is the interface to socket functionality. udp works too.
- IncRnd 5y ago> Another way to touch a file: cp /dev/null file That destroys a file, making it 0 bytes. It doesn't touch a file, not at all.
- _kst_ 5y agoAnd if "file" is the name of an existing directory, it creates an empty file called "file/null". "touch" exists for a reason.
- cferr 5y agoIf the file does not exist, it creates an empty file. That is what most people use touch for.
- deleted 5y ago[deleted]
- IncRnd 5y agoThat's one use case. The actual use case touch was designed for was to update the timestamp of a file. This is a huge case for developers, since timestamps are used in dependency resolution of partial compilation. [1] [1] https://man7.org/linux/man-pages/man1/touch.1.html https://man7.org/linux/man-pages/man1/touch.1.html NAME touch - change file timestamps DESCRIPTION Update the access and modification times of each FILE to the current time.