how to crate date folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to crate date folder
# 1  
Old 09-26-2008
how to crate date folder

Dear all,

could youplease help me with the issue below.
I am trying to archive a file into a folder ( which should be current year and month, `date +%Y%m%/d`).

eg: cp aaa.txt /archive/(datefolder)/aaa.txt

datefolder=this has to be the current year and month
# 2  
Old 09-26-2008
Code:
cp aaa.txt /archive/$(date +%Y%m)/aaa.txt

# 3  
Old 09-26-2008
Which part is the problem? You apparently already know how to use backticks.

Code:
cp aaa.txt /archive/`date +%Y%m%/d`/aaa.txt

The directory has to exist, of course.
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

UNIX script to replace old date with current date dynamically in multiple files present in a folder

I am trying to work on a script where it is a *(star) delimited file has a multiple lines starts with RTG and 3rd column=TD8 I want to substring the date part and I want to replace with currentdate minus 15 days. Here is an example. iam using AIX server $ cat temp.txt RTG*888*TD8*20180201~... (1 Reply)
Discussion started by: Shankar455
1 Replies

2. Shell Programming and Scripting

Delete oldest folder based on folder named as date

Hi, I have a script doing backup to synology server, the script create new folder each day with the date as being folder name i.e. 2018-07-30. Just before creating the new folder I want the script to find the oldest folder from the list and delete it including its content. for example... (3 Replies)
Discussion started by: humble_learner
3 Replies

3. Shell Programming and Scripting

Find latest date in folder

HI I have folder in home dir. /home/kpp/07222013 /home/kpp/07212013 /home/kpp/07202013 Output :-- /home/kpp/07222013 Just find latest date (5 Replies)
Discussion started by: pareshkp
5 Replies

4. UNIX for Dummies Questions & Answers

Deleting folder with Date format

Hi, I have number of directories being created under a main directory on daily basis with the sysdate as below $ pwd /hello/TEST $ ls 20111103 20111102 20111101 20111031 20111030 20111029 20111028 20111027 20111026 20111025 20111024 20111023 20111022 20111021 (3 Replies)
Discussion started by: spari2
3 Replies

5. Programming

unable to use a function to crate a joinable thread

In my program, threads may be created when some events trigger. So I can't create threads on initialization. Theremore,I write a createThread() function to create thread. However, it is blocking at first call and don't run anymore? why? #include <pthread.h> #include <stdio.h> #include... (4 Replies)
Discussion started by: sehang
4 Replies

6. Shell Programming and Scripting

Want to mv files form one folder to another by date

Hi All Looking for some help here I want to query a file and mv all files that are older than seven days to an archive folder. the archive folder already exists but I am having trouble with the date comparison. list file is as follows eg dd2302071334.txt dd2302071358.txt... (7 Replies)
Discussion started by: SummitElse
7 Replies
Login or Register to Ask a Question