To create a text file, you can use any one of the many text editor choices that exist: gedit, pico, nano, emacs, vi, etc. If you aren't familiar with any of these options, we recommend using gedit if you are using a Linux computer, and open -e if you are using a Mac (this opens Mac's TextEdit program).
Running the command itself opens a text editor window:
Once inside the program, you can type in the information you needed to enter and save it using the File -> Save menu option. You can then open text files using the same command followed by the name of the file. If the file isn't saved inside the directory you are in, you would need to include the path to that file. For example, if you wanted to open file.txt that is located in your home directory, you would run something like:
open -e /Users/nmrclass/file.txt
cat, more, less and man
Sometimes you just want to read the contents of a plain text file without actually editing it. There are a few different options for this (available on both Linux and Mac). These include cat, more, and less.
Running this command:
will write the entire contents of file.txt to your terminal screen. This is good if you want to scroll through the entire file, and most useful for short files.
writes out as many lines of file.txt that can fit inside your terminal screen. After that, you can press Enter or the Down arrow key to see more of the contents line by line, or space to see the next screen of contents. If you find the information you were looking for, you can press Q, and you will exit more. The lines that have been displayed have been written to your terminal screen, so you can scroll up and read through the content again.
less is somewhat different, as the contents are not written to your terminal screen once you close it.This command:
opens a program inside your terminal that will let you view and scroll through files in the same way as more. When you finish reading, press Q to exit and get back to your terminal prompt. You notice that the output of the file isn't written to your terminal screen once you exit.
For more information on any command-line program that isn't a part of Freesurfer, you can use man. For example, for more options on how to use less (such as searching inside of a file), you can run this command:
man opens the user manuals for that program, which you can scroll through and exit as if it was opened using less
The extension of the file (i.e. .txt in this example), should be whatever is appropriate for your purpose in creating this file. Some examples:
If you wanted to create an FSGD file, the extension should be .fsgd
If you wanted to create a contrast matrix, you might use the extension .mtx
You might use .dat for a design or registration matrix
To keep a record of the output of a command, you might use .log
If you are creating a script, you would end it with the extension appropriate for the type of script it is:
.csh for a cshell script
.m for a matlab script
.sh for a bash script
It's not always necessary to have a file extension, but they are useful to keep track of the purpose of a file.