Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I have a directory called /data In this directory I have some files like abc ejb .jar,12_ab_ ejb .jar, sh ejb .jar, test I need a shell script ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    6

    Shell script

    Hi all,

    I have a directory called /data
    In this directory I have some files like abcejb.jar,12_ab_ejb.jar, shejb.jar, test
    I need a shell script like...
    1st I want to check if there is any ejb file exists in the directory using some condition
    If ejb files exists I want to redirect the ejb files list to a file called list.
    Now I want to copy all the files in the list file to some remote system.

    Could any one help me on this. I am poor in scripting.

    Regards
    Kalyan Kumar Pasupuleti

  2. #2
    Just Joined! cfajohnson's Avatar
    Join Date
    May 2007
    Location
    Toronto, Canada
    Posts
    52
    Quote Originally Posted by kalyankumarp View Post
    Hi all,

    I have a directory called /data
    In this directory I have some files like abcejb.jar,12_ab_ejb.jar, shejb.jar, test
    I need a shell script like...
    1st I want to check if there is any ejb file exists in the directory using some condition
    If ejb files exists I want to redirect the ejb files list to a file called list.
    Now I want to copy all the files in the list file to some remote system.

    Code:
    for file in /data/*ejb*
     do
       if [ -f "$file" ]
       then
          printf "%s\n" "$file" >> list
          scp "$file" remote_system:
       fi
     done
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...