commands ...

wolfeking

banned
Ok, in windows under the command line i know you can use
Code:
 edit
to open the DOS notepad to create a document. Problem is, I'm on ubuntu, and edit dont work.
I already created a directory using
Code:
 touch "the project"
but I am unsure of what to do now to create the .txt in said directory.
 

wolfeking

banned
i am trying to do this via terminal only.
My assignment was to back up my claim that barring games, Ubuntu can do everything that windows can. I chose to show a simple command line .txt creation, as well as a demo of a few other commands in the terminal (my assignment within the group).
 

Vampiric Rouge

New Member
Look into the redirection commands. ">" and ">>". If you echo and text you want and redirect it with > (create/overwirte) or >> (append).


So.

Echo "This is going into my text file." > test.txt
or
ls > test.txt

it will place this in a file.txt that has what ever you said in the echo.



However you would have a strong argument if you use editors in the command line. Like Nano, Vim/vi, joe. While the command line is great all it really does is run smaller programs. Like Echo, > or | are all just programs being called by shell. While some are built into shell like 'ls' most are there own utility.


Also if you use touch you can just at the .txt to the end. In *nix EVERYTHING is a file and extensions don't matter like they do in Windows.
 

Troncoso

VIP Member
Like what he said^^.

If you are strictly using command line, I would use vi, which is just

sudo vim
or
sudo vim filename.txt

if you want to open a separate text editor you could use gedit, the linux version of notepad:

sudo gedit
or
sudo gedit filename.txt

as long as you are in the directory where you want the files placed, then the text files will automatically be stored there, otherwise, you'll need to move them where you want.
 

Troncoso

VIP Member
ok. How do I go about saving the document when using
Code:
 sudo vim "test document".txt

when you open the file in vim, you start in command mode, I guess you would call it. You press I to go into insert mode, to type whatever it is you want.
When you are done press ESC to exit insert mode and you do

w filename

or just 'w' if you specified the filename earlier. Here is a list of vi commands to help you out.
 

Vampiric Rouge

New Member
Vi/Vim has a slight learning curve.

Basics: Hit "i" to enter input mode and type to the file. Next hit <ESC> to go back to command mode. Type ":" to go to execute mode. after the ":" type "wq" (for write and quit).


You will have to do some googling to unlock it's power.

There is a command mode, input mode and execute mode.

Command Mode:
  • Program Entry Point
  • Command choice either manipulates text or changes mode
  • Equivalent to HotKeys, but required for all changes
  • Re-enter CM by <ESC>

Input Mode:
  • Standard Character Entry
  • Navigation keys remain active
  • Keyboard mapping can be inconsistent across platforms—learn standard keys for best results

Execute mode:
  • Accessible from Command Mode
  • Commands are echoed to the screen
  • Executed with <RETURN>
  • Perform Programmatic Editing
  • Interface outside vi: (read, write, save_as, quit
  • Re-enter CM by <ESC>
 
Top