Linux / UNIX Tech Support Forum
This is a discussion on script for automation within the Shell scripting forums, part of the Development/Scripting category; I have a list of files for creating a package.But before going ahead with package i have to check for ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
I have a list of files for creating a package.But before going ahead with package i have to check for the file paths
for eg:after running find command on prompt i get cd acebill find . -name CR09041494_final.xls ./promo/data/CR09041494_final.xls find . -name CR09041495_final.xls ./promo/data/CR09041495_final.xls find . -name ITC0904216703.sql ./promo/sql/swb/ITC0904216703.sql find . -name Execution_Instructions_RLSE04222009.doc ./promo/doc/Execution_Instructions_RLSE04222009.doc After getting the path under acebill i have to create a directory named current with same directory structure as found out from find command for the files. for eg: like from above find commands mkdir -p current/promo/data mkdir -p current/promo/doc mkdir -p current/promo/sql/swb after creation of this directory structure i have to copy these files from their previous directories to their corresponding new location for eg: $ cd acebill $ cp promo/data/CR09041494_final.xls current/promo/data $ cp promo/data/CR09041495_final.xls current/promo/data $ cp promo/doc/Execution_Instructions_RLSE04222009.doc current/promo/doc please suggest me a script which can automate this process for number of a large number of files |
| Sponsored Links | ||
|
|
|
||||
|
Use dirname to get directory names:
Code:
dirname /promo/doc/Execution_Instructions_RLSE04222009.doc Next, use variable to store it and create a dir: Code:
BASE=/home/test D=$(dirname /promo/doc/Execution_Instructions_RLSE04222009.doc) mkdir -p $BASE/$D cp /promo/doc/Execution_Instructions_RLSE04222009.doc $BASE/$D
__________________
Vivek Gite Linux Evangelist |
|
|||
|
[QUOTE=nixcraft;18814]Use dirname to get directory names:
Code:
dirname /promo/doc/Execution_Instructions_RLSE04222009.doc
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|