![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with dd command or maybe AFS problem | Anta | Shell Programming and Scripting | 0 | 08-25-2006 11:10 AM |
| SSH Problem auth problem | budrito | UNIX for Advanced & Expert Users | 1 | 03-17-2004 10:12 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Problem with Maths
Heres a script i wrote as a bit of practise. What it does is insert a line in the middle of a file. The line being $1 and the file being $2
#!/bin/bash rm tempfile touch tempfile count=1 linenum= `wc -l < $2` if [ "$linenum" -eq 0 ] then echo $1 >> $2 else even=`expr "$linenum" % 2` if [ "$even" -eq 0 ] then midline=`expr "$linenum" / 2` else midline=`expr "$linenum" / 2` midline=`expr "$midline" + 0.5` fi while [ "$linenum" -gt 0 ] do sed -n '$count p' $2 >> tempfile if [ "$linenum" -eq "$midline" ] then echo $1 >> tempfile fi count=`expr "$count" + 1` linenum=`expr "$linenum" - 1` done fi cat tempfile > $2 However when I run this I get the following errors: testscript: 0: command not found testscript: [: : integer expression expected expr: non-numeric argument testscript: [: : integer expression expected expr: non-numeric argument expr: non-numeric argument testscript: [: : integer expression expected This would suggest that the expr argument does not have numbers in it. I know I have the variables in double quotes but this should not matter should it. Can anyone help me with any of these errors. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|