By means of the Terminal, you can pretty much run things without using your mouse. Likewise, it could also feel disorienting. Here I present you some tips to get rapidly back on your feet and save you some time when scripting.
A good way to know where you are is by simply typing
pwd. This will print the current working directory. On a similar note, the
~key works as a surrogate of your home directory. If you’re feeling homesick, just type that down and hit Enter. This will take you to square one.
Some commands allow, and many others require, a second argument. This is, an “object” (i.e., file, folder, or text) that the former will use to perform a certain operation. An example of this is
echowill print whatever you write next in the Terminal. Hence, you need to specify what you would like to print.
If you type
echo hello world!, the Terminal will hello you back. I know this may seem useless at the time but, as a matter of fact,
echois heavily used in scripting.
Another useful commentary. The
.key refers directly to the current directory. Let’s imagine you want to copy something from your Desktop to the folder you’re working at.
cp ~/Desktop/subj0001.nii.gz .will copy the file “subj0001.nii.gz” from your Desktop to your current location.
The last tip. Usage of wildcards. A wildcard becomes handy when you need to massively perform operations on files that you don’t feel like working separately. To use this feature, the first rule is that files must have something in common. In the case of MRI images, most of them are usually in NiFTI format, or “.nii.gz”. There you have it.
If you run
<command> *.nii.gz, you’ll do the same operation to all the files with that closing in one go. In short, it will ignore anything before the “.nii.gz”.
In further posts, I will address the basic Linux commands (e.g.,
rm). Keep an eye on the blog!