Best way to create a file in Bash?
What the title says, what is the best and recommended way to create a file in the terminal?
|
I don't know about best or recommended, but if you just want to create a file with no content, you can use:
touch filename |
I don't think there is a best way to do it, maybe you mean creative way?
Also create empty file or file with specified size? |
create file then add to it.
Code:
$ cat > hello Code:
$ cat > readMySelf |
Quote:
|
Best? There IS no "Best" under Linux. As in the Perl world, there is always more than one way to do "it" for almost any given "it" that can be done.
What is your purpose? |
Less is the best way, except it won't create files.
|
As per the above comments, we really need more info.
Exactly what kind of file do you want and why? |
I usually do
Code:
$ > myfilename This is pretty much the same as "touch filename" that was suggested above, just less typing. But files I have to create by hand are usually text files, humans don't deal often with binary files. So I rather write some content in the text editor, then save it into a file. |
Quote:
LQ members are happy to help. Meanwhile you should consider asking a question where you've done some basic research. You should update your fellow members to indicate if you feel their suggestions were of any help to you. |
This thread has been closed. Please review LQ guidelines about how to ask effective questions for your next question.
|
All times are GMT -5. The time now is 02:08 AM. |