In a 1965 paper, Intel co-founder Gordon Moore described the observed trend that the density of transistors on a computer chip had been doubling every two years. Since then, this notion that every two years, technological advances will double the density of transistors on a chip, became known as Moore's Law. It was always acknowledged that quantum mechanics would eventually provide a limit to these technological advances, but as it turns out, the cost of manufacturing may bring a halt to Moore's law before technical limitations. Michael Feldman, over at HPCWire, predicts that we may see the effective end to Moore's law in the next five years.
Moore observed that the cost per transistor decreased in concert with the shrinking geometries.
... it has been apparent for some time that the Moore's Law curve is running counter to the escalating costs of semiconductor manufacturing, which are rising exponentially as process technology shrinks. This is the result of the increased cost of R&D, testing, and the construction of semiconductor fabrication facilities.
And it is really this aspect of the model that is breaking. Eventually you will be unable to sell enough chips to recoup even the capital expenditures.
The shell and many Unix commands take their input from standard input (stdin), write output to standard output (stdout), and write error output to standard error (stderr). By default, standard input is connected to the terminal keyboard and standard output and error to the terminal screen.
The redirection of I/O, for example to a file, is accomplished by specifying the destination on the command line using a redirection metacharacter followed by the desired destination.
Character
Action
>
Redirect standard output
>&
Redirect standard output and standard error
<
Redirect standard input
>!
Redirect standard output; overwrite file if it exists
>&!
Redirect standard output and standard error; overwrite file if it exists
|
Redirect standard output to another command (pipe)
>>
Append standard output
>>&
Append standard output and standard error
The general form of a command with standard input and output redirection is:
% command -[options] [arguments] <> output file
If you are using CSH/TCSH and do not have the noclobber environment variable set, using > and >& to redirect output will overwrite any existing file of that name. Setting noclobber prevents this. Using >! and >&! always forces the file to be overwritten. Use >> and >>& to append output to existing files.
Redirection may fail under some circumstances: 1) if you have the variable noclobber set and you attempt to redirect output to an existing file without forcing an overwrite, 2) if you redirect output to a file you don't have write access to, and 3) if you redirect output to a directory.
Lastly, have you ever wanted to capture the output of a command to a file, but also send it to the screen? The command tee can do just that.
./compile |& tee filename
redirects both stdout and stderr to the file filename. Its further discussed in this post
Additional Example:
% who > names
Redirects standard output to a file named names.
% (pwd; ls -l) > out
Redirects output of both commands to a file named out.
% pwd; ls -l > out
Redirects output of ls command only to a file named out
Input redirection can be useful, for example, if you have written a FORTRAN program which expects input from the terminal but you want it to read from a file. In the following example, myprog, which was written to read standard input and write standard output, is redirected to read myin and write myout:
% myprog <> myout
You can suppress redirected output and/or errors by sending it to the null device, /dev/null. The example shows redirection of both output and errors:
% who >& /dev/null
To redirect standard error and output to different files, you can use grouping:
% (cat myfile > myout) >& myerror
For the original article on redirection, on which this article is heavily based, and more information about how it differs for the Bourne Shell Family, see this link.
Have you ever wanted to capture the output of a command to a file, but also send it to the screen? The command tee can do just that. Suppose you have a script that builds your application called compile and it sends pages of output to your screen, so you want to capture it to a file so that can employ UNIX's ability to search for patterns. You can achieve this using the UNIX commands
./compile >& filename
where the redirection symbols >& direct both the standard output (stdout) and write error output to standard error (stderr) to the file named filename. Sometimes you also want to see the output on the screen at the same time. This is where the Unix command tee comes in. For example the Unix commands
./compile |& tee filename
redirects both stdout and stderr to the file filename.
R is a statistical computing scripting language not dissimilar to Matlab or Python. R is a GNU project implementation of the S programming language with lexical scoping semantics inspired by Scheme. The R language has become a de facto standard among statisticians for the development of statistical software.
Unix uses the concept of permissions and ownership to determine who can access a file or directory. Each file or folder is considered to be owned by a user and a group (typically group to which the user belongs). There are a set of permissions associated with each file or folder that determines what actions on that file or folder are allowed for a particular user. There are three types of permissions:
r - read, allows you to read the contents of a file
w - write, allows you to write to a file or delete it
x - execute, allows you to run a file as a script, or cd to a directory.
and three groups to set permissions on:
User or Owner is the person who created the file
Group is the group that the owner belongs to
Other is everyone else in the world.
You can see the ownership and permissions for a file or folder by using the ls command with the -l option. For example, if readme is a file in the current folder:
ls -l readme
might give the results:
-rw-r--r-- 1 bob staff 0 Jun 17 23:30 readme
This shows that the file readme is owned by user bob and group staff. The permissions are shown by the sequence of ten characters at the start of that line: -rw-r--r--. The first character is a - for a file. Alternatively if it were a d it would indicate a directory. The next three characters (rw-) indicate the permissions for the owner of the file (bob). The next three characters (r--) indicate the permissions for a user who is not the owner of the file, but who is in the group (staff) that owns the file. The last three characters (r--) indicate the permissions for everyone else.
You can remove a read-only file from a directory only if you have write permission for that folder (-rw-r--r--). Typically directories must have execute permission if you want people to have read permission.
Changing permissions
To change the permissions on a file or folder, use the chmod command. For details, see man chmod. The easiest way to change permissions is to use the symbolic modes where the permission changes are specified by add +, remove -, or set = permissions. Use u to indicate that the change applies to the user permissions, g to indicate that it applies to the group permissions, and o for anyone else.
To change the permissions on the file readme to allow the world to have write permission:
chmod o+w readme
If the file isn't owned by the user, preface the command with sudo and supply a superuser password:
sudo chmod g+w readme
To add executable permission to the file (e.g. because it is a script) for the owner of the file and for users in the group that owns the file use:
chmod ug+x readme
To remove the read and write permissions for the group and the world:
chmod go-rw readme
Use the the set = operation to set the permissions to an exact configuration - without regard to what the permissions are currently. To set the file to be readable and writable by the owner, but only readable by group and "other":
chmod u=rw,go=r readme
Things work similarly for directory permissions. Often you want to change the permissions of a directory and all its contents. Do this with the -R option to chmod.
To change a directory and all its contents to be writable by the owner and group use:
chmod -R ug+w Folder
Likewise, the flag X (uppercase) can be combined with the -R option to ensure that a folder and all of its sub-folders have execute permission, but not the files. Typically execute permission is not desirable for files unless they are applications or scripts.
Overview of the Apple OS X BSD UNIX implementation
Opening a terminal
To access the UNIX subsystems in OS X you need to open the terminal application. The terminal is located in the Utilities folder under applications.
Navigating in the terminal
The horizontal arrow ←→ keys move the cursor left and right
The vertical arrow ↑↓ keys page through the command history.
Use the mouse to select text (by highlighting) and ⌘c and ⌘v to cut and paste text
Delete deletes text behind the cursor the ⌦ key deletes text after the cursor.
Nomenclature
There are numerous concise ways to specify directory information.
. indicates your current directory
.. indicates the directory right above you on the tree, or parent to the current directory.
~ indicates the users own home directory
~smith indicates the user Smith's own home directory
/ the root directory, or top of the tree.
Basic Unix Commands
CP: cp copies a file from a source name to a target name.
cp [modifiers] /<filename> /<filename>
Some common modifiers for copy are: -r for recursive (used to copy whole directories) -f force (don’t ask me if I want to do it just do it) -P preserve permissions
For example
cp /usr/share/tcsh/examples/login ~/login
copies the default login file for the tcsh shell located in the /usr/share/tcsh/examples to your home directory. See the article on shells for more information on the login file.
MV: mv moves a file from one directory to another, or from one name to another, or a combination of both. It often confuses new users that renaming in Unix is the same as moving.
mv [modifiers] /<filename> /<file>
Some common modifiers for move are: -r for recursive (used to copy whole directories) -f force (don’t ask me if I want to do it just do it) -P preserve permissions
For example
mv login .login
just renames the file login to .login.
RM: rm removes a file or with the -r modifier, a directory.
rm [modifiers] /<filename/directory>
Some common modifiers for move are: -r for recursive (used to delete whole directories) -f suppresses confirmation prompts asking if you really want to delete read-only files.
For example
rm -rf /usr/local/bin
removes the directory bin, in /usr/local, if you have permission to do so. Note this is NOT something that is a good idea to try.
CD: cd changes the current working directory.
cd
PWD: pwd displays the current working directory.
MKDIR: mkdir creates a new directory. Some common modifiers for mkdir are: -p used to create a whole hierarchy of folders in one step.
For example
mkdir -p work/version1/code
creates the directory code inside of the directory version1, which is inside a directory work. And work is created in the current working directory.
LS: ls displays the contents of a specified directory. By default it displays the current directory.
ls [modifiers]
or
ls[modifiers] /<filename/directory>
Some common modifiers for ls are: -l provides a long listing of the file information. -lt provides a long listing but now sorted in chronological order -a lists all files, including hidden dot files. -d lists the directory itself (the default behavior lists the contents of the directory instead).
For example
ls -t /usr/share/tcsh/examples
lists the contents of the directory /usr/share/tcsh/examples in the chronological order in which they were created.
Last of all, is the command that helps you find out more about any command. This is the man command.
MAN: man accesses the built in manual pages. For example to find all the modifier options for ls, type:
man ls
to find the name of a command which does something specific use the -k modifier.
man -k password
lists all the commands which deal with passwords. Alternatively use the command apropos which searches through the header lines of the man pages for whatever keyword you supply, and lists the man pages containing it. For example,
apropos copy
produces a list of all the man pages that contain copy in their header lines.
This is just the begining, there is more Unix to come, but this will get you started.