Options

Linux CLI basic commands

DerekAustin26DerekAustin26 Member Posts: 275
I need to make a file called "auto_insurance" as apart of my Linux assignment

i've read about several utilities... who, cal, ls, wc , etc..

which utility do I use to make this particular file?

utility > filename

or do I use another one that I am not aware of?

Comments

  • Options
    Met44Met44 Member Posts: 194
    What you want contained in the file will determine the manner in which you create it. If you want to store the output of a command in the file, then you would use redirection, like you did here:
    utility > filename
    

    Realize that this form of redirection (using a single greater than sign) will overwrite any existing file named "filename". So if you wish to store the output of multiple commands, you will overwrite the file each time, thus only saving the output of the last command you entered -- not what you wanted to do! You instead want to "append" to the end of the file. There is a slight difference in the syntax of "redirecting" versus "redirecting and appending" which should be well-explained in the Linux book for your course under the redirection section.

    If you want to create a file to write in it yourself, you will want to use a text editor such as nano, vim, or emacs (or gedit, which is similar to Microsoft's Notepad, if you have access to a graphical desktop environment). Nano is probably the most beginner-friendly of the terminal-based text editors. To start editing a file in nano, type nano <FILENAME> from the command line, and you will begin editing a file called <FILENAME>, which will be written to the disk once you save it.

    If you simply want to create an empty file which does not already exist and do nothing at all with it, you can use the "touch" command in the form of: touch <FILENAME>.
  • Options
    eMeSeMeS Member Posts: 1,875 ■■■■■■■■■□
    If you simply want to create an empty file, use touch

    e.g., touch auto_insurance

    MS

    EDIT: read the last line above of the first post after I posted this....

    if you want to learn more about any of these commands that you've listed, try: man <command_name> | page
  • Options
    DerekAustin26DerekAustin26 Member Posts: 275
    Met44 wrote: »
    What you want contained in the file will determine the manner in which you create it. If you want to store the output of a command in the file, then you would use redirection, like you did here:[/I].

    That makes sense.

    The book has the "filename" which is "auto_insurance" which it wants me to make and to the right of it says "Content of filename" and depending on that content determines what utility I use.
    (fill free to correct me if i am wrong)

    Thanks alot! :)
Sign In or Register to comment.