BASH Tricks

From CCN Wiki
Revision as of 20:00, 2 August 2017 by 172.101.108.133 (talk) (Created page with "== Make a list of directory names == We often organize subject data so that each subject gets their own directory. Freesurfer uses a '''subjects''' file when batch processing....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Make a list of directory names

We often organize subject data so that each subject gets their own directory. Freesurfer uses a subjects file when batch processing. Rather than manually type out each folder name into a text file, it can be generated in one line of code:

ls -1 -d */ | sed 's\/\\g' > subjects

This lists in 1 column all the directories (-1 -d) and uses sed to snip off the trailing forward slashes in the directory names