Junior — Middle
Kuidas luua uus fail Linuxi operatsioonisüsteemis?
sobes.tech AI
Vastus AI-lt
In Linux, there are several ways to create a new file:
-
Using the
touchcommand:touch filename.txtThis command creates an empty file if it does not exist, or updates the last access time if it already exists.
-
Using the
echocommand:echo "" > filename.txtCreates an empty file or overwrites an existing one.
-
Through text editors, for example
nano filename.txtorvim filename.txt. -
Programmatically, for example in C, you can use the system call
openwith theO_CREATflag:int fd = open("filename.txt", O_CREAT | O_WRONLY, 0644); if (fd == -1) { // error handling } close(fd);