Hi,
I have a shell script
#!/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
zgrep -l $j $k | xargs -I {} cp {} /dest/folder
HTH
--ahamed
1 Like
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
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
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
i'm having the following script
#!/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
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
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