Creating a file in Linux
We can create a file in Linux in many ways.
- cat > myfile.txt : This command will accept the data from standard input and put it in “myfile.txt”. Note that you will have to press the ctrl+c hot key to mark the end of input.
- touch “myfile” : This command will create file if it does not exist.
- printf “This will go in file ” > “myfile”
- echo “This will go in file ” > “myfile”
- You can create a file using output redirection operator ( > ). Output of any command is sent to new file.
- nano/vi – You can also use any of the editors to create a new file