Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

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

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-15-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 19 February 2015, 9:04 PM EST
Location: Bangalore
Posts: 119
Thanks: 26
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 Unix and Linux 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 Unix and Linux 02-15-2013
nikhil jain nikhil jain is offline
Registered User
 
Join Date: Apr 2011
Last Activity: 19 February 2015, 9:04 PM EST
Location: Bangalore
Posts: 119
Thanks: 26
Thanked 2 Times in 2 Posts
I dint get wat u aiming to explain....
    #4  
Old Unix and Linux 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 Unix and Linux 02-15-2013
elixir_sinari's Unix or Linux Image
elixir_sinari elixir_sinari is offline Forum Advisor  
Registered User
 
Join Date: Mar 2012
Last Activity: 16 March 2015, 7:53 AM EDT
Location: India
Posts: 1,412
Thanks: 101
Thanked 496 Times in 473 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 Unix and Linux 02-16-2013
RudiC RudiC is offline Forum Advisor  
Registered User
 
Join Date: Jul 2012
Last Activity: 26 April 2015, 2:05 PM EDT
Location: Aachen, Germany
Posts: 5,757
Thanks: 101
Thanked 1,520 Times in 1,429 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 Unix and Linux 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 974 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 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
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 03:07 AM.