Error in the o/p says bad file descriptor... | Unix Linux Forums | Shell Programming and Scripting

  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.

Error in the o/p says bad file descriptor...

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 02-15-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 24 June 2013, 8:52 AM EDT
Location: Bangalore
Posts: 98
Thanks: 24
Thanked 2 Times in 2 Posts
Error in the o/p says bad file descriptor...


Code:
Code:
grt=`sort -nr line_count.txt|head -1`
while read $dline
do
if [ "$grt" -eq "`wc -l combo_operncount.$dline|awk '{print $1}'`" ]
then
awk -F, '{print $1}' combo_operncount.$dline > FULLD7
else
echo combo_operncount.$dline >> filecoll.txt
fname=`cat filecoll.txt|tr -s "\n" " "`
echo $fname
#paste FULLD7 combo_operncount.$dline
fi
done

Error is thrown where it is highlighted
Sponsored Links
    #2  
Old 02-15-2013
busyboy busyboy is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 19 March 2014, 3:51 AM EDT
Posts: 191
Thanks: 2
Thanked 9 Times in 9 Posts
try assinging the value of the
Code:
wc -l

to a variable before going to test.

Also enclose the variable $dline inside ""


Code:
~# grt=`sort -nr filename|head -1`
~# JJ=`wc -l filename."$KK"| awk '{ print $1 }'`
~# if [ "$grt" ==  "$JJ" ]; then echo $JJ; else echo "Not true"; fi
Not true

Sponsored Links
    #3  
Old 02-15-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 24 June 2013, 8:52 AM EDT
Location: Bangalore
Posts: 98
Thanks: 24
Thanked 2 Times in 2 Posts
I dint get wat u aiming to explain....
    #4  
Old 02-15-2013
busyboy busyboy is offline
Registered User
 
Join Date: Jan 2010
Last Activity: 19 March 2014, 3:51 AM EDT
Posts: 191
Thanks: 2
Thanked 9 Times in 9 Posts
comparing two numbers should be done via
Code:
 ==

rather than
Code:
-eq

, as well. rest is for your understanding .
Sponsored Links
    #5  
Old 02-15-2013
elixir_sinari's Avatar
elixir_sinari elixir_sinari is offline Forum Advisor  
Gotham Knight
 
Join Date: Mar 2012
Last Activity: 16 July 2014, 3:22 PM EDT
Location: India
Posts: 1,412
Thanks: 100
Thanked 495 Times in 472 Posts
Quote:
Originally Posted by busyboy View Post
comparing two numbers should be done via
Code:
 ==

rather than
Code:
-eq

, as well. rest is for your understanding .
Wrong.
== is for string comparison and -eq is for numeric comparison.
Sponsored Links
    #6  
Old 02-16-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 22 July 2014, 4:01 PM EDT
Location: Aachen, Germany
Posts: 3,869
Thanks: 62
Thanked 918 Times in 871 Posts
I can't see where the while loop in your script in post #1 reads from; as is it would read from stdin which might be your terminal. Are you sure the variable dline holds a valid file name?
Sponsored Links
    #7  
Old 02-16-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 973 Times in 789 Posts
Quote:
Originally Posted by nikhil jain View Post
Code:
wc -l combo_operncount.$dline|awk '{print $1}'

If you don't want wc to print a filename, don't provide one as an argument. Instead, redirect the command's standard input:

Code:
wc -l < filename

Regards,
Alister
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
18-Mar-2012 14:25:03.209 general: error: socket: file descriptor exceeds limit (4096/4096) sandeep.tk Solaris 1 03-18-2012 12:21 PM
ufsdump from Solaris to ubuntu fails with bad file descriptor in2deep Ubuntu 1 06-27-2011 03:58 AM
utime returning -1 BAD File DEscriptor parusasi Programming 15 02-04-2011 04:59 PM
Script to search a bad record in a file then put the record in the bad file shilendrajadon Shell Programming and Scripting 2 12-28-2007 09:02 AM
bad file descriptor? ftb UNIX for Dummies Questions & Answers 1 02-20-2002 06:19 PM



All times are GMT -4. The time now is 11:42 PM.