Chris (
nonethefewer) wrote2009-06-16 09:44 am
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Entry tags:
(no subject)
This is scripting stuff for work. I don't script in Linux that often, sooo.
--
This directory has a series of folders with this naming convention:
It's wicked simple. Basically, I need to:
- get the most recent folder name for [name]
- make a new folder for today's date
- copy from most-recent to new-folder
- cd new-folder
Fucked if I know, though.
--
This directory has a series of folders with this naming convention:
update_[name][date]/
It's wicked simple. Basically, I need to:
- get the most recent folder name for [name]
- make a new folder for today's date
- copy from most-recent to new-folder
- cd new-folder
Fucked if I know, though.
no subject
Assuming bash, this may be useful to get you going in the right direction:
#!/bin/bash
BASEDIR=[path]
NAME="[...]"
DATE=$( date +[format stuff here] )
# this is a "minus 1, not a minus lower-case L"
MOSTRECENT=$( ls -1 -t ${BASEDIR}/update_${NAME}* | head -1 )
# if the date is regularly formatted, maybe use cut to strip out the date
DATELESS=$( echo ${MOSTRECENT} | cut [cut args here] )
NEWFOLDER="${DATELESS}${DATE}"
mkdir ${NEWFOLDER}
cp -rp ${MOSTRECENT}/* ${NEWFOLDER}
cd ${NEWFOLDER}
Something like that. Hope that helps.
no subject
no subject
no subject