|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
i am writing a script in that I want to copy the files in one
directory which is created on fly : a line in the script is : cp -p config.log BASE_PATH/"log.`date '%k-%M-%F'`" i.e., I want to copy file config.log to the directory BASE_PATH/<dir name created on fly "log.`date '%k-%M-%F'`" how can cp create directories on fly ?? if no .. is there any other way i can do this ?? Thanks & regards, Onkar |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
onkar wrote:
> i am writing a script in that I want to copy the files in one > directory which is created on fly : > > a line in the script is : > > cp -p config.log BASE_PATH/"log.`date '%k-%M-%F'`" > > > i.e., I want to copy file config.log to the directory > BASE_PATH/<dir name created on fly "log.`date '%k-%M-%F'`" targetdir=BASE_PATH/DIRNAME_CREATED_ON_THE_FLY mkdir -p "$targetdir" cp -p config.log "$targetdir/log.$(date '+%k-%M-%F')" Mind that your date specifier may create filenames with blanks. Janis > > how can cp create directories on fly ?? > if no .. > is there any other way i can do this ?? > > > > Thanks & regards, > Onkar > |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
onkar wrote:
> i am writing a script in that I want to copy the files in one > directory which is created on fly : > > a line in the script is : > > cp -p config.log BASE_PATH/"log.`date '%k-%M-%F'`" > > > i.e., I want to copy file config.log to the directory > BASE_PATH/<dir name created on fly "log.`date '%k-%M-%F'`" > > how can cp create directories on fly ?? > if no .. > is there any other way i can do this ?? [GNU tar] tar c config.log | tar xv --transform="s;.*;YOURDR/&;" --show-transformed-names -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
onkar wrote:
> i am writing a script in that I want to copy the files in one > directory which is created on fly : > > a line in the script is : > > cp -p config.log BASE_PATH/"log.`date '%k-%M-%F'`" > > > i.e., I want to copy file config.log to the directory > BASE_PATH/<dir name created on fly "log.`date '%k-%M-%F'`" > > how can cp create directories on fly ?? > if no .. > is there any other way i can do this ?? [GNU tar] tar c config.log | tar xv --transform="s;.*;YOURDIR/&;" --show-transformed-names -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Cyrus Kriticos wrote:
> onkar wrote: >> i am writing a script in that I want to copy the files in one >> directory which is created on fly : >> >> a line in the script is : >> >> cp -p config.log BASE_PATH/"log.`date '%k-%M-%F'`" >> >> >> i.e., I want to copy file config.log to the directory >> BASE_PATH/<dir name created on fly "log.`date '%k-%M-%F'`" >> >> how can cp create directories on fly ?? >> if no .. >> is there any other way i can do this ?? > > [GNU tar] > > tar c config.log | tar xv --transform="s;.*;YOURDIR/&;" --show-transformed-names To preserve permissions: tar c config.log | tar xvp --transform="s;.*;YOURDIR/&;" --show-transformed-name -- Best regards | Be nice to America or they'll bring democracy to Cyrus | your country. |
|
![]() |
| Outils de la discussion | |
|
|