Touch command in Linux will create an empty file in Linux
command line. If no other parameters is specified whether a line will be
inserted to the newly created file.
Cat command is for reading files via command line but it can
also be used to create a file in Linux terminal window command line.
Cat command below will create a file called “test_comment.txt”
and with the content or the line of “Hello World of Touch and Create File” on
the file created.
Here’s the shell command:
cat <( echo “Hello
World of Touch and Create File”) > test_comment.txt
Note that there is no space between “<(“, if there is a
space then the command will not work as expected.
Touch command to create a new file and also insert a new
line or insert a string on the newly created file.
Here’s the shell command:
touch touch_file_comment.txt; echo “Hello World of Touch,
insert this line.” > touch_file_comment.txt
Basically, the command executes two commands separated by “;”
semi-colon. The first part is to create a file and the second command is the
echo command to insert the line to the newly created file by touch.
man touch has a lot of other usage, it can be used to modify
timestamp as well.
Above commands works fine; just an illustration on how to
learn basic commands on Linux terminal line but on a production environment,
I am not sure what scenario it would suit best.
Cheers. Enjoy Linux!!!
================================
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Comments
Post a Comment