Sponsored Content
Top Forums Shell Programming and Scripting Copy specific file (different but same name) as folder name Post 302932204 by RavinderSingh13 on Tuesday 20th of January 2015 01:46:38 AM
Old 01-20-2015
Hello wappor,

Could you please try following and let me know if this helps.

Code:
cat test19.ksh
SOURCE=$1
DESTINATION=$2
awk  -vsource=`echo $SOURCE` -vdestination=`echo $DESTINATION` --re-interval 'BEGIN{match(source,/\/[0-9]{4}\//);A=substr(source,RSTART+1,RLENGTH-2);match(source,/\/[0-9]+\./);B=substr(source,RSTART+1,RLENGTH-2);match(source,/\..*/);C=substr(source,RSTART,RLENGTH);match(destination,/\/[a-zA-Z]+\//);D=substr(destination,RSTART,RLENGTH);print "cp " source " " D B"_" A C}'

We can run it as follows by providing 2 arguments first as source file path and second is destination file path as follows.
Code:
./test19.ksh /005_0/1000/005.xxx  /copy/
cp /005_0/1000/005.xxx /copy/005_1000.xxx

If you are happy with results above you can run following script then which will copy the files as follows.
Code:
cat test19.ksh
SOURCE=$1
DESTINATION=$2
awk  -vsource=`echo $SOURCE` -vdestination=`echo $DESTINATION` --re-interval 'BEGIN{match(source,/\/[0-9]{4}\//);A=substr(source,RSTART+1,RLENGTH-2);match(source,/\/[0-9]+\./);B=substr(source,RSTART+1,RLENGTH-2);match(source,/\..*/);C=substr(source,RSTART,RLENGTH);match(destination,/\/[a-zA-Z]+\//);D=substr(destination,RSTART,RLENGTH);print "cp " source " " D B"_" A C}' | sh

NOTE: Also if you are happy with results then you can read all the files which you want to copy to a destination directory and pass it to script then.


Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy file and locate in new folder?

Hi All, Please advise me how to make a copy of file from a list and store in one particular location? For example , I have aaa.txt which contains as below, But, those *usg files might be randomly store in different location.... > cat aaa.txt adc.usg dfdjkf.usg ugjfk.usg And I want... (3 Replies)
Discussion started by: cedrichiu
3 Replies

2. UNIX for Dummies Questions & Answers

Copy the latest file from a folder

Hi, I have a problem. I have some text files in a folder. The names can be like: emp_20080307053015.dat emp_20080306053015.dat emp_20080305053015.dat emp_20080304053015.dat The date format appended is like yyyymmdd and timestamp. What i need is i have to copy the latest file every... (3 Replies)
Discussion started by: Aswarth
3 Replies

3. UNIX for Advanced & Expert Users

Auto copy for files from folder to folder upon instant writing

Hello all, I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written. I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Discussion started by: Bashar
2 Replies

4. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

5. Shell Programming and Scripting

How to copy specific file.txt in specific folder?

hye there... i have a problem to copy file in specific folder that will change the name according to host,time(%m%s) and date(%Y%M%D) example folder name: host_20100531.154101801 this folder name will always change... but i just want to copy the AAA.txt and BBB.txt file.. really need... (17 Replies)
Discussion started by: annetote
17 Replies

6. UNIX for Dummies Questions & Answers

Copy the latest (last file) in given folder

#!/bin/bash for i in {1..1536..1} do #find /home/test/Desktop/up111/workplace/Malware/$i/logs for a in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do #max=a for b in /home/test/Desktop/up111/workplace/Malware/$i/logs/* do ... (4 Replies)
Discussion started by: upvan111
4 Replies

7. UNIX for Dummies Questions & Answers

copy files grabbing destination folder from file name

Hi all... Below is what I am trying to do: 1. Having the following folder with the files... /source_folder/dodiddone.tar.gz /source_folder/gowentgone.tar.gz /source_folder/gowentgone.log 2. I need to copy and chown files with extension .tar.gz to another folder copy... (1 Reply)
Discussion started by: pedroz
1 Replies

8. Programming

how to copy downloaded file into my source file folder (putty/unix)

I need to "Ensure that when you download libchat.a from the VLE you have copied it to the same folder on ius as your source files. You then refer to the library (and the libraries it needs) with: gcc -o outputfile sourcefile.c -L. -lchat -lsocket -lnsl" But I have no idea what this means! (I... (2 Replies)
Discussion started by: fakuse
2 Replies

9. Shell Programming and Scripting

Need help in writitng a script to rename file name and copy to other folder

Hi All, My requirement is as follows: A file (say abc) will be having list of the .txt file names. I need to read this abc file line by line and rename the .txt file names inside it and move them to other folder/path. Eg: abc ------- file1.txt file2.txt file3.txt Output (should... (1 Reply)
Discussion started by: pavan.yadalla
1 Replies

10. Shell Programming and Scripting

Copy one file from a server to a local folder

Hi, Is there a way I can copy a file from a server to a local folder (i.e. My Documents)? can it be done by scp? I tried this but it just rename the file as the folder it has to be transferred at. scp -r name@some_server:/home/user/file.txt 'somehere\home\home_dir' Thanks. (4 Replies)
Discussion started by: erin00
4 Replies
CAIROOPERATOR(3)							 1							  CAIROOPERATOR(3)

The CairoOperator class

INTRODUCTION
This is used to set the compositing operator for all cairo drawing operations. The default operator is CairoOperator::OVER The operators marked as unbounded modify their destination even outside of the mask layer (that is, their effect is not bound by the mask layer). However, their effect can still be limited by way of clipping. To keep things simple, the operator descriptions here document the behavior for when both source and destination are either fully trans- parent or fully opaque. The actual implementation works for translucent layers too. For a more detailed explanation of the effects of each operator, including the mathematical definitions, see http://cairographics.org/operators/. CLASS SYNOPSIS
CairoOperator CairoOperator Constants o const integer$CairoOperator::CLEAR0 o const integer$CairoOperator::SOURCE1 o const integer$CairoOperator::OVER2 o const integer$CairoOperator::IN3 o const integer$CairoOperator::OUT4 o const integer$CairoOperator::ATOP5 o const integer$CairoOperator::DEST6 o const integer$CairoOperator::DEST_OVER7 o const integer$CairoOperator::DEST_IN8 o const integer$CairoOperator::DEST_OUT9 o const integer$CairoOperator::DEST_ATOP10 o const integer$CairoOperator::XOR11 o const integer$CairoOperator::ADD12 o const integer$CairoOperator::SATURATE13 PREDEFINED CONSTANTS
o CairoOperator::CLEAR -Clear destination layer (bounded) o CairoOperator::SOURCE -Replace destination layer (bounded) o CairoOperator::OVER -Draw source layer on top of destination layer (bounded) o CairoOperator::IN -Draw source where there was destination content (unbounded) o CairoOperator::OUT -Draw source where there was no destination content (unbounded) o CairoOperator::ATOP -Draw source on top of destination content and only there o CairoOperator::DEST -Ignore the source o CairoOperator::DEST_OVER -Draw destination on top of source o CairoOperator::DEST_IN -Leave destination only where there was source content (unbounded) o CairoOperator::DEST_OUT -Leave destination only where there was no source content o CairoOperator::DEST_ATOP -Leave destination on top of source content and only there (unbounded) o CairoOperator::XOR -Source and destination are shown where there is only one of them o CairoOperator::ADD -Source and destination layers are accumulated o CairoOperator::SATURATE -Like CairoOperator::OVER, but assuming source and dest are disjoint geometries PHP Documentation Group CAIROOPERATOR(3)
All times are GMT -4. The time now is 03:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy