The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Need help in scripting nicknihal Shell Programming and Scripting 10 01-16-2008 10:56 AM
need help scripting tar over ssh rm -r * Shell Programming and Scripting 6 10-25-2007 04:42 PM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 09:12 AM
scripting guru's pls help me with scripting on AIX thatiprashant Shell Programming and Scripting 1 01-20-2006 07:58 PM
New to scripting sdrtaz Shell Programming and Scripting 2 03-18-2005 03:22 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-25-2008
itsmehihihi itsmehihihi is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
Need help in scripting ...

****************************************************
grep -l $Timestamp `ll|grep "$1 $2 $3"|awk '{print $NF}'` >Files.txt

#The indentified files were written to Files.txt

for i in `cat Files.txt`

do
#Copies indentified files as Lin_filename

cp -p $i $Lin\_$i

#Moves Lin_filename files to MQ retry directory

mv $Lin\_$i /merccesar/data/router/inMqR/retry/
done
******************************************************

If you see here I am writting the result of grep -l $Timestamp `ll|grep "$1 $2 $3"|awk '{print $NF}'` into a file.

and then copying and moving the files in the Files.txt.

Instead of loop I want to store the value of *** grep -l $Timestamp `ll|grep "$1 $2 $3"|awk '{print $NF}'` *** into a variable and then copy and move ...

But when I tried the below command

Var=`grep -l $Timestamp `ll|grep "$1 $2 $3"|awk '{print $NF}'``

It is not getting executed
Please help me !!!

Thank You
Subbu
  #2 (permalink)  
Old 08-25-2008
wempy's Avatar
wempy wempy is offline
Registered User
  
 

Join Date: Jun 2006
Location: Harpenden, UK
Posts: 208
This maybe because you are nesting backquotes.

try (in Bash anyway):

Var=$(grep -l $Timestamp $(ll|grep "$1 $2 $3"|awk '{print $NF}'))

Though that method may introduce other problems because I think the $(..) syntax executes the commands in a subshell.
  #3 (permalink)  
Old 08-25-2008
itsmehihihi itsmehihihi is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
*********************************************************
Var=`ll|grep "$1 $2 $3"|awk '{print $NF}'`

Var1=`grep -l $Timestamp $Var`


#Copies indentified files as Lin_filename

cp -p $Var1 $Lin\_$Var1

#Moves Lin_filename files to MQ retry directory

mv $Lin\_$Var1 /merccesar/data/router/inMqR/retry/
*******************************************************
This worked out

Thank You
Subbu
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0