Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

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

Shell Programming and Scripting


Closed    
 
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: 6 December 2016, 9:12 AM EST
Location: Bangalore
Posts: 163
Thanks: 35
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: 23 November 2016, 10:12 AM EST
Posts: 199
Thanks: 3
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: 6 December 2016, 9:12 AM EST
Location: Bangalore
Posts: 163
Thanks: 35
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: 23 November 2016, 10:12 AM EST
Posts: 199
Thanks: 3
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: 6 December 2016, 6:10 AM EST
Location: India
Posts: 1,413
Thanks: 101
Thanked 497 Times in 474 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 Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 10 December 2016, 1:24 PM EST
Location: Aachen, Germany
Posts: 9,955
Thanks: 201
Thanked 2,966 Times in 2,765 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 976 Times in 790 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 Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 01:21 PM
ufsdump from Solaris to ubuntu fails with bad file descriptor in2deep Ubuntu 1 06-27-2011 04:58 AM
utime returning -1 BAD File DEscriptor parusasi Programming 15 02-04-2011 05: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 10:02 AM
bad file descriptor? ftb UNIX for Dummies Questions & Answers 1 02-20-2002 07:19 PM



All times are GMT -4. The time now is 06:18 PM.