Last active
September 23, 2015 19:41
-
-
Save stevekm/995700181050fb1297ec to your computer and use it in GitHub Desktop.
Create an index log that lists the names of desired directories and ID values pulled from .csv file within each directory. This version of the script is depricated and has been replaced by dir_name_indexLogger2.sh, but I still like some of the code from this so I wll keep it around
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# save directory names and their associated ID's into an index log | |
# set the proper permissions for all files created by this script | |
umask 007 | |
# make sure that the log file exists | |
LOG=/filepath/PARENT_DIR/logs/index_log.tsv | |
touch $LOG | |
# find the desired directories, they always have ~PATTERN~ in name | |
FILES=$(find /filepath/PARENT_DIR/ -maxdepth 1 -type d -name PATTERN) | |
# append the list of all desired directory names into the log | |
# also add the ID value, found in the directory's Information_sheet.csv | |
for i in $FILES; do | |
echo -e "$(basename $i)\t$(grep "ID" $i/Information_sheet.csv | cut -f 2 -d ,)">> $LOG; | |
done | |
# remove the duplicate entries | |
sort -u $LOG -o $LOG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment