shell scripting error help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell scripting error help
# 8  
Old 05-16-2010
ok its working but its not displaying any results. just


/export/home/sieben01/itec400/homework> ./maxlines.sh
File has the maximum lines with lines.


im guessing its in this statement. the awk print statements. should the print $1 and print $2 be changed?
Code:
printf "File `echo $FILE | awk '{print $2}'` has the maximum lines with `echo $1| awk '{print $1}'` lines.\n"
exit 0

# 9  
Old 05-16-2010
more typos spotted:
Code:
wc-l

needs to be
Code:
wc -l

;
Code:
`echo $1| awk '{print $1}'` lines.\n"

needs to be
Code:
`echo $LINE| awk '{print $1}'` lines.\n"

# 10  
Old 05-16-2010
ok almost working. the first part is working just not teh line count


File printnum.sh has the maximum lines with lines.

Code:
FILE=$(wc -l `ls` 2>/dev/null | sort -bn | tail -n 2 | head -n 1)
printf "File `echo $FILE | awk '{print $2}'` has the maximum lines with `echo $LINE| awk '{print $1}'` lines.\n"
exit 0

# 11  
Old 05-16-2010
works here...I note that you provide no screenshots to support just how it's not working. You might want to step your way across the pipes to ensure each progressive leg provides what you're looking for...before handing it off to the subsequent print statement.

You might also drop the embedded `ls` and go with a globbed * approach:
Code:
wc -l * 2>/dev/null |sort -bn |tail -n 2 |head -n 1

...and switch to simply using print, instead of the printf, which expects arguments...

Good luck.
# 12  
Old 05-16-2010
got it working. thanks guys
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting syntax error in if then else

I have one bash shell script to execute table refreshment. At the bottom of script, I have one piece of code to check 'ORA-' error from log file, then send email to DBA or application people. But this piece of code didn't work. I tried different ways and also search online to find where is my... (2 Replies)
Discussion started by: duke0001
2 Replies

2. Shell Programming and Scripting

Error in tsch shell scripting..

Hi Everyone, I am using gdb-7.5 to connect to the target. When I gave the./configure --target=xyz --build=i686-pc-mingw32 --host=i686-pc-mingw32 command then checking build system type... i686-pc-mingw32 checking host system type... i686-pc-mingw32 checking target system type... xyz-mingw32... (3 Replies)
Discussion started by: Heeka
3 Replies

3. Shell Programming and Scripting

Shell Scripting Error - help

I am trying to do an upgrade on a VMWare appliance. I am getting an error, and I dug into the script that is causing the error and will post the statement that is causing the error. Basically, my software seems to want an additional partition before it will do the upgrade. So, I added a new... (1 Reply)
Discussion started by: Phoenix Askevic
1 Replies

4. Shell Programming and Scripting

ERROR in executing mysql querys in shell scripting

Hi All, Please see the below script for mysql 3 commands. Its giving me the right output for all three commands but showing some errors in first two commands , i guess there might be an issue with date. Can anyone help me . #! /bin/bash TABLE_NAME=testingddatabase USER_NAME=root... (3 Replies)
Discussion started by: aish11
3 Replies

5. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

6. Shell Programming and Scripting

Error handling in Unix shell scripting

Hello, I have written a shell script and suppose there is any error in the script. How i can do exception handling in shell script.for example i have below code sqlplus -s <<uid>>/<<pwd>>@<<$ORACLE_SID>> <<EOF > 1_pid1.log set pagesize 0 set feedback off set heading off set linesize 200... (1 Reply)
Discussion started by: rksingh003
1 Replies

7. Shell Programming and Scripting

bash shell scripting error need help urgently

#! /bin/sh abcd = "Hello world" if then echo $abcd fi i got error message that line3 : abcd: command not found line5 : [0: command not found line5 : [1: command not found i have no idea why i got this message. Can some one help me ??? (6 Replies)
Discussion started by: bonosungho
6 Replies

8. Shell Programming and Scripting

shell scripting error

i am trying to work on a simple shell script as #!/bin/bash filename = $2 if ; then echo " Displaying the Content of the file:" filename = $2 cat filename else if ; then echo "Displaying directory listing:" ls -l filename else echo " Commands not correct:" fi done it shows the... (3 Replies)
Discussion started by: phone_book
3 Replies

9. Shell Programming and Scripting

Shell Scripting Error

When i run the script firecall.sh,i am getting a weird error. root: ./var/ADMIN/bin/firecall.sh d12381 ./var/ADMIN/bin/firecall.sh: ?osrc: command not found ./var/ADMIN/bin/firecall.sh: ?osrc: command not found The script is successful,but the error interests me...Any Ideas?? The... (1 Reply)
Discussion started by: Renjesh
1 Replies

10. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies
Login or Register to Ask a Question