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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in the o/p says bad file descriptor...
# 1  
Old 02-15-2013
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
# 2  
Old 02-15-2013
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

# 3  
Old 02-15-2013
I dint get wat u aiming to explain....
# 4  
Old 02-15-2013
comparing two numbers should be done via
Code:
 ==

rather than
Code:
-eq

, as well. rest is for your understanding .
# 5  
Old 02-15-2013
Quote:
Originally Posted by busyboy
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.
# 6  
Old 02-16-2013
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?
# 7  
Old 02-16-2013
Quote:
Originally Posted by nikhil jain
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bad file descriptor - error with sed

I'm learning SED command. And while doing that i got to this place where i'm taking a copy of my existing file. The code i used is - sed -n '/Storm/ w Storm.txt' books.txt As expected, the file 'books.txt' is read , and lines with 'Storm' is put in to the new file 'Storm.txt'. However, it also... (4 Replies)
Discussion started by: justo
4 Replies

2. Solaris

File System Error: BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DIRECTORIES OUT OF RANGE

Hi All, we are having a file system error in one of our servers. The server failed to boot in usual user mode. Instead boot with single user mode and requesting to run a FSCK manually to repair the corrupted. see the below output. Netra T2000, No Keyboard Copyright 2008 Sun Microsystems,... (5 Replies)
Discussion started by: Buddhike G
5 Replies

3. Solaris

Bad exchange descriptor : not able to remove files under zpool

Hi , One of my zone went down and when i booted it up i could see the pool in degraded state with some check sum errors . we have brought the pool online after scrubbing. But few files are showing this error Bad exchange descriptor Please let me know how to remove these files (2 Replies)
Discussion started by: chidori
2 Replies

4. Solaris

18-Mar-2012 14:25:03.209 general: error: socket: file descriptor exceeds limit (4096/4096)

I have BIND 9.8.1-P1 cache only DNS server running in Solaris 10. I have upgraded the same from 9.6.1 to 9.8.1-P1. Now i am facing "file descriptor exceeds limit (4096/4096)" error frequently on the server. Please help me on this issue! (1 Reply)
Discussion started by: sandeep.tk
1 Replies

5. Ubuntu

ufsdump from Solaris to ubuntu fails with bad file descriptor

Hi All I have a dedicated backup server running ubuntu 10.04, which has recently been rebuilt (same OS, just different h/w) This is used to receive ufsdump output from a number of Solaris servers, using the following syntax: ufsdump 1uf :/path/to/backup/file /fs/to/be/backed/up This has... (1 Reply)
Discussion started by: in2deep
1 Replies

6. Programming

utime returning -1 BAD File DEscriptor

Hi All, First of all thanks for reading this post. In my application, I am trying to create a new message queue . I am attaching the code below. mqd_t mqopen2(const char * pName, unsigned long Flags, long maxMsg, long msgSz) {... (15 Replies)
Discussion started by: parusasi
15 Replies

7. UNIX for Dummies Questions & Answers

File Descriptor

Hi What the below path contains? /proc/<pid>/fd (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

8. Shell Programming and Scripting

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (2 Replies)
Discussion started by: shilendrajadon
2 Replies

9. UNIX for Advanced & Expert Users

Script to search a bad record in a file then put the record in the bad file

I need to write a script that can find a bad record (for example: there is date field colom but value provided in the file for this field is N/A) then script shoud searches this pattern and then insert the whole record into the bad file. Example: File1 Name designation dateOfJoining... (1 Reply)
Discussion started by: shilendrajadon
1 Replies

10. UNIX for Dummies Questions & Answers

bad file descriptor?

Ok, I'm sure this is a total newbie question, but I think I'm in the right place, no? I'm trying to call a perl module from a cgi script - Mail::Sendmail - and my web host installed the module in a directory that doesn't seem to be accessible, at least not the way I'm trying. But I thought you... (1 Reply)
Discussion started by: ftb
1 Replies
Login or Register to Ask a Question