Scripting question | Unix Linux Forums | Shell Programming and Scripting

  Unix/Linux Go Back    


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

Scripting question

Shell Programming and Scripting


Tags
unix;

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-04-2013
Ravindra Swan Ravindra Swan is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 1 January 2015, 1:04 PM EST
Posts: 50
Thanks: 19
Thanked 0 Times in 0 Posts
Scripting question

Hi
I am trying to write a small script which takes one by one file name from a txt file and do a 'll' and need to check if equal to the given month, otherwise it should return back the file name.
Note: the file name contains parameter.
My code is given below: It is not working .. giving error as no ll command found.


Code:
while read line
do

export File_Name=`eval echo $(echo $line)`

Month="(ll $File_Name | cut -d ' ' -f6)"

 if [ "$Month" = "Jun" ]
 then 
	echo "Correct"
 else
 	echo "$File_Name"
 fi

done<filecheck.dat

Sponsored Links
    #2  
Old Unix and Linux 02-04-2013
pamu pamu is offline
Registered User
 
Join Date: Mar 2012
Last Activity: 7 November 2014, 10:50 AM EST
Posts: 1,650
Thanks: 58
Thanked 478 Times in 474 Posts
Quote:
Originally Posted by Ravindra Swan View Post
Code:
while read line
do
 
export File_Name=`eval echo $(echo $line)`
 
Month="(ll $File_Name | cut -d ' ' -f6)"
 
 if [ "$Month" = "Jun" ]
 then 
    echo "Correct"
 else
     echo "$File_Name"
 fi
 
done<filecheck.dat

Try using...


Code:
Month=$(ll $File_Name | cut -d ' ' -f6)

Sponsored Links
    #3  
Old Unix and Linux 02-04-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 4 March 2015, 3:53 PM EST
Location: Amsterdam
Posts: 9,961
Thanks: 321
Thanked 2,586 Times in 2,312 Posts
Why do you use the eval echo construction, is it to condense spacing? Why not:


Code:
while read File_Name
do
  ...
done<filecheck.dat

    #4  
Old Unix and Linux 02-04-2013
Ravindra Swan Ravindra Swan is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 1 January 2015, 1:04 PM EST
Posts: 50
Thanks: 19
Thanked 0 Times in 0 Posts
same error

No It is not working same error.


Code:
month.ksh: line 6: ll: command not found

Sponsored Links
    #5  
Old Unix and Linux 02-04-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 4 March 2015, 3:53 PM EST
Location: Amsterdam
Posts: 9,961
Thanks: 321
Thanked 2,586 Times in 2,312 Posts
use ls -l instead of ll
Sponsored Links
    #6  
Old Unix and Linux 02-04-2013
Ravindra Swan Ravindra Swan is offline
Registered User
 
Join Date: Oct 2012
Last Activity: 1 January 2015, 1:04 PM EST
Posts: 50
Thanks: 19
Thanked 0 Times in 0 Posts
same error

Again i am getting same error

Code:
month.ksh: line 6: ls-l: command not found

---------- Post updated at 03:35 PM ---------- Previous update was at 03:32 PM ----------

Thanks got it
Sponsored Links
    #7  
Old Unix and Linux 02-04-2013
Jotne's Unix or Linux Image
Jotne Jotne is offline
Registered User
 
Join Date: Dec 2010
Last Activity: 20 September 2014, 2:08 AM EDT
Posts: 1,040
Thanks: 62
Thanked 216 Times in 204 Posts
You miss a space
wrong

Code:
ls-l

correct

Code:
ls -l

Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Scripting question moe2266 Shell Programming and Scripting 1 08-02-2007 02:21 AM
scripting question carlvernon Shell Programming and Scripting 10 04-21-2006 07:42 AM
scripting question? justinburbridge Shell Programming and Scripting 2 04-19-2006 12:58 PM
another scripting question jigarlakhani Shell Programming and Scripting 3 02-27-2002 05:43 PM
another scripting question kristy UNIX for Dummies Questions & Answers 1 05-07-2001 01:02 PM



All times are GMT -4. The time now is 08:13 PM.