how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell..

#!/bin/ksh
home=c:/..../
input=$1
sed '1,3d' $input > $1.out

line=""
cat $1.out | while read a
do
line="$line $a"
done

echo $line > $1

rm $1.out

however...now i want it just in normal sh mode..how to convert this? any help? thanks!

could you define what you mean by 'normal' sh, pls?

and if you had run it under your 'normal' sh, what kind of issue you encountered?

oh its bourne shell as in #!/bin/sh

ok, so. when you run it under '/bin/sh' ... what's taking place?

well....its this part i guess...or maybe other part of the lines...as im a newbie..what i think was this line that cause the error....
cat $1.out | while read a
do
line="$line $a"
done

the line will not combine...as in the code here "$line Sa" will not execute

what do you get as the output?

could you post the content of your '$1' file, pls?

ok..my output was something similar to this..
abc

abc

abc

and when i run this ...i will get
abc abc abc...

i can get this in korn shell ..but not in bourne..dun know why,,

what was your input [$1 file content] to this script?

it is a txt file. abc.txt
the text file contains this:
abc

abc

abc

ok....... what's the content of abc.txt?

if abc.txt contains the following:

abc
def
123
456
789

and runnning the script under '/bin/ksh' I get the following output in abc.txt:

456 789

which is exactly what the script is supposed to do.

yes..you are right...but now i do not want it to be done in korn shell..i want it in bourne shell....when i run it in bourne shell..it doesnt works..which i hope you guys can help me out... :slight_smile:

a shell independent script:

#!/bin/sh
home=c:/..../
input=$1

nawk 'FNR > 3 {printf("%s%c", $0, OFS)}END{print ""}' "$1"  > "$1".out && mv "$1".out "$1"

hi thanks however..why i get my output like this? in sliding manner.. i only want a space after each abc...
abc
...................abc
............................................... abc

please ingore the dots...

strange.......

given input [ $1 ]:

1
2
3
4
123
123456

and the script above ..... I get:

4 123 123456

well i do get the sliding abc...
my text files is actually spooled out from the database table which is like this

Text_abc

--------------------------------------------------

abc

abc

abc

thats why i want to delete away the first 3 lines...and only want the abc.
i not sure or maybe i guess it is because there is an empty line after each abc..thats why i have the sliding manner...can you help me?

ok, how about this:

#!/bin/sh
home=c:/..../
input=$1

nawk 'FNR > 3 && NF {printf("%s%c", $0, OFS)}END{print ""}' "$1"  > "$1".out &&
mv "$1".out "$1"

i still get the sliding manner............signed...:frowning:

hi..i have upload my textfile...
hope you guys can help...thanks...

I don't know what to tell you.... I get the desired result [undet Solaris 8].

Maybesomeone else will have better ideas... sorry.

well its ok......thanks for your help! vgersh99...thanks for spending time helping me do all this.........it is very much appreciated...

well.... that's quite a different file....... doesn't jive with your original description. Everything appears on the SAME line/record....

#!/bin/sh
home=c:/..../
input=$1
#sed '1,3d' $input > $1.out

nawk 'FNR > 3 && NF {for (i=1; i<= NF; i++) printf("%s%c", $i, (i==NF) ? "\n" : OFS' "$1"  > "$1".out && mv "$1".out "$1"