generate a script that will do the following


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting generate a script that will do the following
# 1  
Old 02-07-2012
generate a script that will do the following

I need to write a shell script that will do all this:
  1. Go to server directory, for example (/xyz/outbound)
  2. In the outbound folder, get the list of the (old) directories created or modified at least two days before the date when script is run.
  3. The list will have the names of directories, some with, some without the .retry extension.
  4. For each directory without the .retry extension, go into the directory.
  5. In these directories, check whether any folder exists inside or not.
  6. If a folder exists, go into that folder and check whether only 2 .txt files are there or not.
  7. If only 2 .txt files are there then do nothing.
  8. If the folder inside the directory does not exist, go to each directory and take 3 types of files: .pdf, .retry.xml, .retry.trg
  9. Copy these files to /local/inbound folder.
  10. Then, for directories with the .retry extension, check whether only 2 .txt files are there or not.
  11. If only 2 .txt files are there, then do nothing.
Smilie

Last edited by chako_3; 02-07-2012 at 04:34 AM..
# 2  
Old 02-07-2012
Welcome to the forum.

Please show what you have tried and where you stuck.
We are here to help.
# 3  
Old 02-07-2012
Code:
#Go to outbound
cd /xyz/Outbound
 
#In the outbound folder, get the list of the (old) directories created or modified at least two days before the date when script runs
mydirs=$(find . -type d -maxdepth 0 ! -mtime -2)
 
#The list will have the names of directories, some with, some without the .retry extension.Process the list
for file in ${mydirs}; 
do 
#directory with .retry extension
  if [[ ${file:(-6)} == ".retry" ]] ; then 
    cd /xyz/Outbound/${file}
    numfiles=$(ls -1 *.txt | wc -l) 
    if [[ $numfiles -eq 2 ]] ; then 
      echo There were exactly two text files 
    else 
      echo There were ${numfiles} text files 
    fi
fi 
done

i did this for the directories with .retry extension. now can anybody help me how to implement for the direcoties without .retry extension ?

Last edited by Franklin52; 02-08-2012 at 06:07 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How do I generate a script with an inverse action?

I have an interactive script which sorts and processes a variety of filetypes from an unsorted folder into newly created directories. The script works great, But I was wondering how I could generate a script with an inverse action so that I could unwind / undo the executed script and its sorting... (3 Replies)
Discussion started by: Braveheart
3 Replies

2. Shell Programming and Scripting

Script to generate .csv file

Dears,I need your help in this, I have to create a report based on the output file generated by another program. I want to write a shell script for this. The output file generated every 15 minutes but i can’t open it until the end of day so the script will get the file as an input the file will be... (8 Replies)
Discussion started by: abdul2020
8 Replies

3. Shell Programming and Scripting

Script to generate csv file

Dears, I am new in shell world and I need your help in this, I have to create a report based on the output file generated by another program. I want to write a shell script for this. The output file generated every 15 minutes but i can’t open it until the end of day so the script will get the... (3 Replies)
Discussion started by: abdul2020
3 Replies

4. Shell Programming and Scripting

Script to generate sequence of numbers

I need awk script to generate part number sequencing based on data in multiple columns like below Input File --------- Col A|Col B|Col C| 1|a|x| 2|b|y| |c|z| | |m| | |n| And out put should be like 1ax 1ay 1az 1am 1an 1bx 1by (6 Replies)
Discussion started by: aramacha
6 Replies

5. UNIX for Dummies Questions & Answers

Need script to generate file.

Hi I have a file "test" with data as below 1,APRIL,NEW,"New market,delhi,pune,India",RECENT, 254664 2,MARCH,OLD,"New Area,Mumbai,UP,India",CURRENT, 152483 So I want a script which provides output as below 1,APRIL,RECENT,254664 2,MARCH,CURRENT,152483 I am aware we can use awk/sed... (9 Replies)
Discussion started by: sv0081493
9 Replies

6. Shell Programming and Scripting

Script To Generate HTML output

Hello All, I need help here with a script. I have a script here which generates a html output with set of commands and is working fine. Now i want to add a new command/function which would run on all the remote blades and output should be included in this html file. Here is the script ... (2 Replies)
Discussion started by: Siddheshk
2 Replies

7. Shell Programming and Scripting

generate logfile in a shell script

Unix Gurus, I have a shell script which has few "echo" statements. I am trying to create a logfile where all the outputs of the echo statement sare stored. I will have to add this as the final step in the existing script so that everytime the script runs, a logfile is generated with all the... (1 Reply)
Discussion started by: shankar1dada
1 Replies

8. Shell Programming and Scripting

How to generate cntl+c interrupt through script?

Hi all, can anyone tell me how to generate control+c interrupt through shell script. (2 Replies)
Discussion started by: rohitmahambre
2 Replies

9. Shell Programming and Scripting

help....generate command script

Please help..... if i have a file list below : 1233743158.log 1233743410.log 1233744186.log 1233744462.log "1233743158" is a unix time format it's require to a script "convertime.sh" to convert unix time format to readable time format like 20090204183010 -- YYYYMMDDHHMMSS ... (10 Replies)
Discussion started by: bleach8578
10 Replies

10. Shell Programming and Scripting

To generate the FTP Script file

Hi, I am new to the shell programming., My requirement is , I have an shell file, which call internally the sql file, which generates 4 files on the directory., and then shell has to create the file which contains all the ftp commands to extract the files to different server for later... (1 Reply)
Discussion started by: konankir
1 Replies
Login or Register to Ask a Question