Copying files after result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Copying files after result
# 1  
Old 11-22-2011
Copying files after result

Hi,

I have a shell script
Code:
#!/bin/sh
date
echo 'HI PROD'
echo $Please ENTER THE INPUT 1 for old files 2 for new file
read i
if [ "$i" -eq 1 ];
then
   cd /apps/acetp3_logs/prod3/O*
  pwd
  echo $PLEASE ENTER THE STRING TO SEARCH (PLEASE ENTER THE STRING INSIDE QUOTES ' ')
   read j
  echo $PLEASE ENTER THE FILE STRING TO SEARCH
  read k
  while [ "$j" != " " ] || [ "$k" != " "]
  do
     zgrep -l $j $k
   done
else
   if [ "$i" -eq 2 ];
  then
    cd /apps/acetp3_logs/prod3
    pwd
    echo $PLEASE ENTER THE STRING TO SEARCH
    read j
    echo $PLEASE ENTER THE FILE STRING TO SEARCH
    read k
    while [ "$j" != " " ] || [ "$k" != " "]
    do
      grep -l '$j'$k
    done
   fi
 fi
exit

in the above script the zgrep will find the result of files and i need to cp those files to a specific folder

Thanks for the help

Last edited by Scott; 11-22-2011 at 07:32 AM.. Reason: Code tags
# 2  
Old 11-22-2011
Code:
zgrep -l $j $k | xargs -I {} cp {} /dest/folder

HTH
--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 11-23-2011
Hi
i'm using the belwo script to search my string it's working but its taking
much time to reach the goal any suggestion to cut it off
Code:
echo 'HI PROD'
#echo $Please ENTER THE INPUT 1 for old files 2 for new file
#read i
#if [ "$i" -eq 1 ];
#then
#cd /apps/acetp3_logs/prod3/O*
#pwd
echo $PLEASE ENTER THE STRING INSIDE QUOTES TO SEARCH
read j
echo $PLEASE ENTER THE FILE STRING TO SEARCH
read k
while [ "$j" != " " ] || [ "$k" != " "]
do
zgrep -l $j /apps/acetp3_logs/prod3/O*/$k | xargs -I {} cp {} /home/l828117/weblogic
done
fi

Thanks for the help


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 11-23-2011 at 03:28 AM..
# 4  
Old 11-23-2011
If the gzip files are huge, it will take time. Otherwise the script is pretty straight forward. I dont know if unzipping and a normal grep will help!

--ahamed
# 5  
Old 11-23-2011
thanks for the help
# 6  
Old 11-24-2011
i'm having the following script
Code:
#!/bin/sh
clear
tput cup  1  2 ;echo "HI PROD!!"
tput cup 5  2 ;echo $PLEASE ENTER THE STRING INSIDE QUOTES TO SEARCH
read j
tput cup 9 2 ;echo $PLEASE ENTER THE FILE STRING TO SEARCH
read k
while [ "$j" != " " ] || [ "$k" != " "]
do
zgrep -l  $j /apps/acetp3_logs/prod3/O*/$k|xargs -I {} cp {} /home/l828117/weblogic 2> /dev/null
done
exit

After the input given it throws the below error
Code:
gzip: is.gz: No such file or directory
gzip: started'.gz: No such file or directory
gzip: BAU.gz: No such file or directory
gzip: task.gz: No such file or directory
gzip: named.gz: No such file or directory
gzip: Inbound.gz: No such file or directory
gzip: msg.gz: No such file or directory
gzip: not.gz: No such file or directory
gzip: processed.gz: No such file or directory
gzip: is.gz: No such file or directory
gzip: started'.gz: No such file or directory

i dont want see this error in the screen.thanks for help

Last edited by Scott; 11-24-2011 at 05:27 AM.. Reason: Code tags
# 7  
Old 11-24-2011
Code:
zgrep -l  $j /apps/acetp3_logs/prod3/O*/$k 2>/dev/null | xargs -I {} cp {} /home/l828117/weblogic 2> /dev/null

Google Search Results for how to suppress error | The UNIX and Linux Forums

--ahamed
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying files

I'm trying to do this exact same thing, so far I have created this to move files i've named my script CP.sh #!/bin/bash cd /root/my-documents/NewDir/ for f in *.doc do cp -v $f root/my-documents/NewDir $f{%.doc} done When i go to run this in the console i type, bin/sh/ CP.sh but it... (7 Replies)
Discussion started by: MKTM_93_SIMP
7 Replies

2. Shell Programming and Scripting

Copying files

All, I need to grab and rename common files from several unique directory structures. For example, the directory structures looks like: /unique_dir/common/common/common/person_name_dir/common_file.txt There are over 90,000 of these text files that I'd like to put in a single directory as... (5 Replies)
Discussion started by: hburnswell
5 Replies

3. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

4. Shell Programming and Scripting

Copying Files

Hi All, I'm trying to list some files from my log directory and files are like this log.20110302_20.gz log.20110302_21.gz log.20110302_22.gz log.20110302_23.gz log.20110303_00.gz log.20110303_01.gz log.20110303_02.gz ............ log.20110311_22.gz log.20110311_23.gz... (2 Replies)
Discussion started by: thelakbe
2 Replies

5. Shell Programming and Scripting

compare two files, diff the result

Hi Everyone, 1.txt 00:01:01 asdf 00:33:33 1234 00:33:33 0987 00:33:33 12 00:33:33 444 2.txt vvvv|ee 444|dd33|ee dddd|ee 12|ee 3ciur|fdd the output should be: (6 Replies)
Discussion started by: jimmy_y
6 Replies

6. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

7. Solaris

Copying Files

Hi, I understand that to copy files across server, the feasible way will be using scp command. Am I right? What if the two servers are not connected to a network? If by using a cross cable to link up both the server, what will be the best (fastest) way to copy files across? scp as well? ... (3 Replies)
Discussion started by: user50210
3 Replies

8. Shell Programming and Scripting

copying files

hi I want to copy all files from the current directory and move to .archive file. Moreover,I want to add .bak to each file name, that will be copied. How can I do that? (4 Replies)
Discussion started by: tjay83
4 Replies

9. Solaris

Copying Files and

I am new user to solaris and installed solaris operating system on full Harddisk 120Gb. I am unable to copy music files to desktop and /home directory. One thing happened while registering is- i entered login-root and its password. The message prompted your system is crashed. Is it because of... (1 Reply)
Discussion started by: patilmukundraj
1 Replies

10. UNIX for Dummies Questions & Answers

Copying files

I like to know the command structure of copying files/directories from a unix box using telnet session to a windows box. (4 Replies)
Discussion started by: alpheusm
4 Replies
Login or Register to Ask a Question