Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to fix :[too many arguments error in code Post 302196522 by Brewer27 on Sunday 18th of May 2008 08:17:54 PM
Old 05-18-2008
How to fix :[too many arguments error in code

I am getting a :[ too many arguments error on line 28 if I do not specify a directory or file when running my code. Any suggestions as I am stuck here.

if [ $# -gt 1 ]; then
echo "Enter zero or one file"
echo "You must use a valid directory"
echo "Current directory is:" pwd
exit 0
fi
#Flag Variable
flag=1
#Code for no arguments
if [ $# -eq 0 ]; then
for filename in *
do
if [ -f $filename ]; then
linetest1='wc -l < $filename'
# Execution
if [ $flag -eq 1 ]; then
startline=$linetest1
startfile=$filename
flag=2
fi

#End Code Execution
if [ $startline -lt $linetest1 ]; then
startline=$linetest1
startfile=$filename
fi
fi
done
echo "File $startfile has the maximum number lines ($startline)."
exit 0
fi

#If only one Variable
if [ $# -eq 1 ]; then
cd $1
for filename in *
do
if [ -f $filename ]; then
linetest1='wc -l < $filename'
if [ $flag -eq 1 ]; then
startline=$linetest1
startfile=$filename
flag=2
fi
if [ $startline -lt $linetest1 ]; then
startline=$linetest1
startfile=$filename
fi
fi
done
echo "File $startfile has the maximum number lines ($startline)."
exit 0
fi



Thanks.
 

3 More Discussions You Might Find Interesting

1. Programming

why ORA-00600: internal error code, arguments: [17059]?

I have code to update some records in MyTable1 in sql which I am calling from ksh file (unix script). I am getting below error - MyTable1 TABLE UPDATE FAILED : UPDATE MyTable1 SET ph_nr = '+44 (0)20 8960 1233' , update_dts = sysdate WHERE ID = 499037 ORA-00600: internal error code,... (2 Replies)
Discussion started by: rshivarkar
2 Replies

2. Shell Programming and Scripting

How to fix my code in Perl?

Hi Perl users, Could you help me how to fix my code so I can get the expected output as seen below? is there missing in my program? Thank You #!/usr/bin/perl -w use strict; open (FH, "< file1.log") or die $!; open (FL, "< file2.log") or die $!; my $file = "result.log"; my... (1 Reply)
Discussion started by: askari
1 Replies

3. Shell Programming and Scripting

Help me please to fix my error

Can you help me to fix my error please?! I checked the code and I think there is no mistake, but when I run it gives me error such line 1: /Users/Manu/trials/hosts: is a directory sort: open failed: /Users/Manu/trials/hosts/*: No such file or directory Help me please... mycode NAME value.... (9 Replies)
Discussion started by: Manu1234567
9 Replies
IS_EXECUTABLE(3)							 1							  IS_EXECUTABLE(3)

is_executable - Tells whether the filename is executable

SYNOPSIS
bool is_executable (string $filename) DESCRIPTION
Tells whether the filename is executable. PARAMETERS
o $filename - Path to the file. RETURN VALUES
Returns TRUE if the filename exists and is executable, or FALSE on error. EXAMPLES
Example #1 is_executable(3) example <?php $file = '/home/vincent/somefile.sh'; if (is_executable($file)) { echo $file.' is executable'; } else { echo $file.' is not executable'; } ?> ERRORS
/EXCEPTIONS Upon failure, an E_WARNING is emitted. NOTES
Note The results of this function are cached. See clearstatcache(3) for more details. Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine which wrappers support stat(3) family of functionality. SEE ALSO
is_file(3), is_link(3). PHP Documentation Group IS_EXECUTABLE(3)
All times are GMT -4. The time now is 07:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy