Synching Scripts: Difference between revisions
(Created page with "The ubfs lab folder contains a growing collection of scripts that have been written to simplify a number of mundane, tedious or possibly error-prone tasks in different environ...") |
|||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
The ubfs lab folder contains a growing collection of scripts that have been written to simplify a number of mundane, tedious or possibly error-prone tasks in different environments. | The ubfs lab folder contains a growing collection of scripts that have been written to simplify a number of mundane, tedious or possibly error-prone tasks in different environments. | ||
After you have mounted the ubfs folder | After you have mounted the [[UBFS]] folder, you can navigate to the scripts folder in the computer browser window, or in the terminal window: | ||
cd ~/ubfs/Scripts | |||
Scripts are organized into several subdirectories, generally grouped by programming environment. | |||
== Updating your shell scripts == | |||
Your Linux $PATH environment variable includes your $HOME/bin directory. This is where useful Linux shell scripts should go. To ensure that you have the latest collection of shell scripts, you can copy the contents of the ubfs/Scripts/Shell directory to your $HOME/bin directory: | |||
cp ~/ubfs/cpmcnorg/Scripts/Shell/* ~/bin/ | |||
This will overwrite any files with the same name with the version stored on the remote server. | |||
== Updating your MATLAB scripts == | |||
For a .m function or script file to run in MATLAB, it has to be found in your MATLAB path variable. Unless you went out of your way to change it, your MATLAB path will include your $HOME/Documents/MATLAB/ directory. You can include any custom MATLAB scripts from the ubfs server in MATLAB by copying (from a Linux terminal window) these files from the ubfs folder in a similar manner to how the shell scripts are updated: | |||
cp ~/ubfs/cpmcnorg/Scripts/Matlab/*.* ~/Documents/MATLAB/ | |||
This will overwrite any files with the same name with the version stored on the remote server. | |||
==Command-Line Synchronizing Files Using File Pattern Filters With rsync== | |||
<code>rsync</code> is a pretty powerful file copying utility with loads of options. I find it useful for preserving directory structure while copying files. If there is a set of files with a particular file pattern that you want to copy from one source to another, try using the --include and --exclude options. | |||
Here is an example where I copied a set of .mat files from an external drive to a folder on UBFS. This command copied only those files and their parent/grandparent directories, and omitted all other files and irrelevant directories by also using the --prune-empty-dirs option: | |||
rsync -avz --include='timeseries.mat' --include='*/' --exclude='*' --prune-empty-dirs /Volumes/Samsung_T3/fmri/ /Volumes/cpmcnorg/Modeling/TS/ | |||
This command included all instances of the file ''timeseries.mat'' (<code>--include='timeseries.mat'</code>) in any subdirectory of the source directory (<code>--include='*/'</code>). Any file that didn't match was excluded (<code>--exclude='*'</code>) and any empty directories that would have been created were omitted (<code>--prune-empty-dirs</code>). The files were copied from the Samsung_T3/fmri directory to the ubfs/cpmcnorg/Modeling/TS directory. After the copy completed, the TS directory contained a folder hierarchy where each branch contained a timeseries.mat file. | |||
This is a handy way to transfer a bunch of fMRI data: | |||
#Assume that DISK_IMG is the name of a mounted USB thumb drive, and that you have already created the destination NEWDIR directory | |||
TARGET_DIR=DISK_IMG/NEWDIR | |||
rsync -avz --include='f.nii' --include='*/' --exclude='*' --prune-empty-dirs ./ /media/${USER}/${TARGET_DIR} | |||
#Copies all the f.nii files in the directory tree under the current working directory |
Latest revision as of 13:02, 27 June 2017
The ubfs lab folder contains a growing collection of scripts that have been written to simplify a number of mundane, tedious or possibly error-prone tasks in different environments.
After you have mounted the UBFS folder, you can navigate to the scripts folder in the computer browser window, or in the terminal window:
cd ~/ubfs/Scripts
Scripts are organized into several subdirectories, generally grouped by programming environment.
Updating your shell scripts
Your Linux $PATH environment variable includes your $HOME/bin directory. This is where useful Linux shell scripts should go. To ensure that you have the latest collection of shell scripts, you can copy the contents of the ubfs/Scripts/Shell directory to your $HOME/bin directory:
cp ~/ubfs/cpmcnorg/Scripts/Shell/* ~/bin/
This will overwrite any files with the same name with the version stored on the remote server.
Updating your MATLAB scripts
For a .m function or script file to run in MATLAB, it has to be found in your MATLAB path variable. Unless you went out of your way to change it, your MATLAB path will include your $HOME/Documents/MATLAB/ directory. You can include any custom MATLAB scripts from the ubfs server in MATLAB by copying (from a Linux terminal window) these files from the ubfs folder in a similar manner to how the shell scripts are updated:
cp ~/ubfs/cpmcnorg/Scripts/Matlab/*.* ~/Documents/MATLAB/
This will overwrite any files with the same name with the version stored on the remote server.
Command-Line Synchronizing Files Using File Pattern Filters With rsync
rsync
is a pretty powerful file copying utility with loads of options. I find it useful for preserving directory structure while copying files. If there is a set of files with a particular file pattern that you want to copy from one source to another, try using the --include and --exclude options.
Here is an example where I copied a set of .mat files from an external drive to a folder on UBFS. This command copied only those files and their parent/grandparent directories, and omitted all other files and irrelevant directories by also using the --prune-empty-dirs option:
rsync -avz --include='timeseries.mat' --include='*/' --exclude='*' --prune-empty-dirs /Volumes/Samsung_T3/fmri/ /Volumes/cpmcnorg/Modeling/TS/
This command included all instances of the file timeseries.mat (--include='timeseries.mat'
) in any subdirectory of the source directory (--include='*/'
). Any file that didn't match was excluded (--exclude='*'
) and any empty directories that would have been created were omitted (--prune-empty-dirs
). The files were copied from the Samsung_T3/fmri directory to the ubfs/cpmcnorg/Modeling/TS directory. After the copy completed, the TS directory contained a folder hierarchy where each branch contained a timeseries.mat file.
This is a handy way to transfer a bunch of fMRI data:
#Assume that DISK_IMG is the name of a mounted USB thumb drive, and that you have already created the destination NEWDIR directory TARGET_DIR=DISK_IMG/NEWDIR rsync -avz --include='f.nii' --include='*/' --exclude='*' --prune-empty-dirs ./ /media/${USER}/${TARGET_DIR} #Copies all the f.nii files in the directory tree under the current working directory