BASH Tricks
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