osx - How to write a bash script using Mac to take files with the same date and put them in a folder with that date -


i have hundreds of datalogger files in directory , want write bash script take files same date in filename (an example file name "2016-06-15t170000_smartflux.data", 2016-06-15 date) , store them in folder date name. using mac terminal window, believe linux (i apologize ignorance in computer terminology)

so far have:

#type of file (extension) process: files=*.data  #get date string file name use newly created file date=`ls $files|head -n 1|cut -c 1-10` 

any appreciated. have modified bash script combines these types of files text, , have not created folders or moved files.

assuming script in same dir data files:

#!/bin/bash  filename in *.data;     target_dir=${filename:0:10}     if [[ ! -d $target_dir ]];         mkdir $target_dir     fi     mv $filename $target_dir done 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -