next up previous contents
Next: Listing names in the Up: Basic operations for managing Previous: Basic operations for managing

Managing directories

      

md Create a new subdirectory
<dirname> name of subdirectory to be created
mkdir Create a new subdirectory
<dirname> name of subdirectory to be created
rd Remove a subdirectory
<dirname> name of subdirectory to be removed
rmdir Remove a subdirectory
<dirname> name of subdirectory to be removed
cd Change the current directory
<dirname> name of subdirectory to move to
pwd Print current working directory

This set of commands is meant for managing subdirectories. The directory system has the same principle as file systems. Directories can be created with md (or mkdir) and they can be removed with rd (or rmdir). The NDA kernel keeps track of the current working directory, which can be changed with cd command.

Subdirectories should always be created with md (or mkdir), but items can be referred to by giving the whole (absolute) or relative path of the name entry, for instance, /tmp/first/data or ../first/data (if the current working directory is /tmp/second, for instance). A subdirectory needs to be empty before it can be deleted with rd (or rmdir).

Example: Boston data set contains information about appartments sold in Boston, MA during a certain time period. There are lots of properties, which can be used for truly thorough analyses. If one would want to perform a similar analysis for certain parts of the original data set, it can be easily performed with directories and selrec (see section 4.3.3).

NDA> load boston.dat
...
# Split boston data into two parts
NDA> md part1
NDA> md part2
NDA> selrec -d boston -expr 'boston.rate' < 40; -dout part1/data
NDA> selrec -d boston -expr 'boston.rate' >= 40; -dout part2/data
NDA> cd part1
NDA> runcmd analysis
# Data analysis for low-priced appartments
...
NDA> cd ../part2
# Could perform data analysis for more expensive appartments
...

References to name entries in different directories can be made using absolute or relative paths. This example also shows that only an empty directory can be removed.

...
# Referencing name entries in different directories
NDA> ls ../part1 -fr *
 data
 data.crim
 data.zn
...
NDA> cd ..
NDA> somtr -d part1/prep -sout som2 -l 4
...
NDA> rd part2
 Returned error -134: Try to remove a directory that is not empty
# Error caused by the deletion of a non-empty subdirectory.
# Thus let's remove items under it first
NDA> rm part2/data
NDA> rd part2


next up previous contents
Next: Listing names in the Up: Basic operations for managing Previous: Basic operations for managing

Anssi Lensu
Thu May 17 15:00:44 EET DST 2001