Sponsored Content
Full Discussion: Need small help
Top Forums Shell Programming and Scripting Need small help Post 302408233 by kirankumar on Monday 29th of March 2010 01:48:59 AM
Old 03-29-2010
I have a requirement to move the client files into a separate folders.file names comes as
q1_20100327.txt
gf_20100327.txt
ac_20100327.txt
hi_20100327.txt
based on the filenames we need to move those files into folders.folder names are
q1,gf,globalac,globalhi. For above i have done the coding and executing successfully.

Code:
#!/bin/ksh
src_dir=/home/global/source
tgt_dir=/home/global
file_dir=/home/global/import-file-move-to-instances
error_dir=/home/global/error_folder
now=`date +%Y%m%d`

if [[ -e $file_dir/file_move_import_serv.log ]];
then
rm -f $file_dir/file_move_import_serv.log
fi

cat $file_dir/ClientName_file.txt | awk '{ print $1 }' | while read q_dirs

do
echo $q_dirs

if [[ $q_dirs == 'q1' || $q_dirs == 'gf' ]];
then
cp $src_dir/import-serv/$q_dirs*.txt  $tgt_dir/$q_dirs/import-serv/
else
cdsgq_dir=`echo $q_dirs | sed 's/global//' | awk '{print}'|tr '[A-Z]' '[a-z]'`
echo $cdsgq_dir 
cp $src_dir/import-serv/$cdsgq_dir*.txt  $tgt_dir/$q_dirs/import-serv/

if [[ $? -ne 0 ]];
then
echo "file copying failed,due to file not available"  >> $file_dir/file_move_import_serv.log
else
echo "file copied sucessfully into $q_dirs/import-serv directory"  >> $file_dir/file_move_import_serv.log
fi
fi
done


rm -f $src_dir/import-serv/*.txt

In ClientName_file.txt having the folder names as

Code:
q1
gf
globalac
globalhi
globalbg

But,Now the client want to say is if the filename comes as capitals Q1_20100327.txt/GF_20100327.txt
AC_20100327.txt/HI_20100327.txt then we need to move those files into error folder.

Any help is much appreciated.

Thanks in advance

Last edited by pludi; 03-29-2010 at 03:52 AM.. Reason: code tags, please...
kirankumar
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

small script help

here is a small script: if ; then echo please enter an argument fi if [ "$1" = "tom"; then a=$1 echo $a fi here is my question. if the script name is j.sh and I run it : j.sh from shell prompt: without a parameter: it prints please enter an argument but if I go with . j.sh (current... (1 Reply)
Discussion started by: rkl1
1 Replies

2. Shell Programming and Scripting

Small Help on SED

Hi All, I have come across a command echo "123 abc" | sed 's/*/& &/' output is 123 123 abc then i tried in different ways to get 123 abc abc as output. Can u please explain me the importance of & in the above command. Thank you - Chanakya (7 Replies)
Discussion started by: Chanakya.m
7 Replies

3. IP Networking

Small problem...

Nice pictures, really free from virtual swingers club !!!! Anal sex Body art Gay Hardcore Lesbian Oral sex Cum XXX Models Private Image Galleries Private XXX photo Free!!! Say no to Spamers!!! Auto forum spam msg replacer by Swinguru © (1 Reply)
Discussion started by: Green_Monkey23
1 Replies

4. Shell Programming and Scripting

small script help

#!/bin/ksh for i in *.log* do ls $i|sed 's/\.log$//g' | while read file do echo "file $file is Running" >> lls.txt echo "***************">> lls.txt done done ------------------------------------------------------------------ the output is : file AdapterCCProvisioningInterface... (9 Replies)
Discussion started by: ali560045
9 Replies

5. Shell Programming and Scripting

need a small script

Hello all, i have a batmail process running on my machine(java process). i just need a script we should detect whether the batchnail is running or not.If not it should restart it. Can anyone assist me on this? (1 Reply)
Discussion started by: Rayzone
1 Replies

6. Shell Programming and Scripting

Missing something small....

I have a feeling my eyes are burned and I am just missing something small here but can somebody tell me why this is not working.... #!/bin/ksh Trunk_Path=/lcl/sit/apps/Tivoli types="-name '*.sh' -o -name '*.conf' -o -name '*.rules' -o -name '*.dat' -o -name '*.props' -o -name '*.sql' -o -name... (10 Replies)
Discussion started by: LRoberts
10 Replies

7. Shell Programming and Scripting

Need small help

Hi all, I have two files in my folder 1.index.jsp 2.maintenance.jsp Once hit the URL in IE,It will call the index.jsp file than application working fine. I want to some maintenance in my application, during the application maintenance than it will... (1 Reply)
Discussion started by: lkeswar
1 Replies

8. UNIX for Dummies Questions & Answers

need help with small script

Hi I have the below file Name=abc Yr=2011 Mon=05 My script should be in such a way that whenever I run it then Month should increment by 1 and if the month is 12 then when I run the script then year should incremented by 1 and month Should become 01(I.e jan) Thanks for the help in... (6 Replies)
Discussion started by: kishu
6 Replies

9. Shell Programming and Scripting

need a small help

Hi, sorry for inconvenience..wrong query posted. Thanks for your help. Thanks (1 Reply)
Discussion started by: kirankumar
1 Replies

10. Shell Programming and Scripting

Small automation

Frequently we need to stop or start services on Linux systems. For exmaple : To start or stop vsftpd daemon # /etc/init.d/vsftpd start or # /etc/init.d/vsftpd stop Following script will check the vsftpd service and if it is running, it will be stopped or vice-versa. # cat... (5 Replies)
Discussion started by: snjksh
5 Replies
rmf(1)							      General Commands Manual							    rmf(1)

NAME
rmf - remove folder (only available within the message handling system, mh) SYNOPSIS
rmf [+folder] [-help] [-[no]interactive] OPTIONS
Prints a list of the valid options to this command. Asks for confirmation before deleting a folder. By default, rmf deletes a folder and its messages without asking for confirmation. If you specify the -interactive option, rmf asks if you are sure before deleting the folder. You are advised to use this option, since when rmf deletes a folder its contents are lost irretrievably. DESCRIPTION
The rmf command removes all of the messages within the current folder, and then removes the folder itself. If there are any files within the folder which are not part of MH, they are not removed, and an error message is displayed. You can specify a folder other than the current folder by using the +folder argument. If you do not specify a folder, and rmf cannot find the current folder,rmf asks you whether you want to delete +inbox instead. If the current folder is removed, it makes +inbox current. Note that the rmf command irreversibly deletes messages that do not have other links, so use it with caution. If the folder being removed is a sub-folder, the parent folder becomes the new current folder, and rmf tells you that this has happened. This provides an easy mechanism for selecting a set of messages, operating on the list, then removing the list and returning to the current folder from which the list was extracted. Using rmf to delete a read-only folder deletes the private sequence and current message information from the file, without affecting the folder itself. If you have sub-folders within a folder, you must delete all the sub-folders before you can delete the folder itself. PROFILE COMPONENTS
Path: To determine the user's Mail directory EXAMPLES
This example shows how rmf asks for confirmation when the -interactive option is used: % rmf -interactive +test Remove folder "test"? y FILES
The user profile. SEE ALSO
rmm(1) rmf(1)
All times are GMT -4. The time now is 05:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy