1

In /Home/Templates directory, we can put template file. So we can create new file by right clicking. Is there any way we can create new file which have current Date and Time. Something like log file. Which have date and Time as very first line. Or in the name of file.

  • This is slightly similar (at least the second part — having the date in the name of the file). – aplaice Jan 21 at 17:46
  • Creating a file having date in name is can be done by touch command. But here I want it as Template. – Deepak Gautama Jan 31 at 12:24
0

This is not the solution for which I am looking for. But certainly good one.

  1. Step-I

    • Create a file and put following command

      #!/bin/bash
      
      touch $(date +"%Y-%b-%d_%H:%M:%S")
      
    • Mark file for execution

      chmod +x file
      

      Or Right click on file and select properties. Under Permission tab, tick Allow executing file as program

  2. Step-II

    • Install dconf-editor and run it.
    • Move to org/gnome/nautilus/preferences.
    • Right click on executable-text-activation.
    • Select launch from drop down menu.
  3. Step-III

    • Put that file in Templates folder.
  4. Step-IV

    • At any location (e.g. Desktop or Documents etc.), just right click and create that file there.
    • Now double click it, it will create file with Date&Time as name.

Bash command for creating file with Name as DateTime and also as first line

#!/bin/bash

echo $(date +"%Y-%b-%d_%H:%M:%S") > $(date +"%Y-%b-%d_%H:%M:%S")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.