How to copy/paste text in the UNIX terminal

From NMR Wiki

(Difference between revisions)
Jump to: navigation, search
Current revision (19:15, 19 March 2010) (edit) (undo)
 
Line 7: Line 7:
* type in "end of file" command - usually Ctrl-D
* type in "end of file" command - usually Ctrl-D
-
Unix pipes gives extra flexibility.
+
Unix pipes give you extra flexibility.
For example you can append '''sorted''' copied contents to the file this way:
For example you can append '''sorted''' copied contents to the file this way:

Current revision

To copy - select range of text with the mouse (on some systems you may have to hit Ctrl-C or Apple-C to copy; on Linux selected text is automatically placed onto the system clipboard).

To paste into a file in the Unix command line there are three steps:

  • type either "cat > file_name" or "cat >> file_name". In the first case file will be overwritten, in the second case pasted text will be appended to the file.
  • actually paste - the action depends on the type of your terminal. In most cases clicking middle mouse button over the terminal screen will work. In Windows-based PUTTY ssh terminal it's right-click
  • type in "end of file" command - usually Ctrl-D

Unix pipes give you extra flexibility.

For example you can append sorted copied contents to the file this way:

cat | sort >> file

or even just unique lines from the copied content:

cat | sort | uniq >> file

The pipeline can be built to your specific needs.

Personal tools