Modifying a .ksh script

Hi users,

I am on a beginner level and just joined this site.

I have created a simple .ksh file in the following manner

cat <<EOF >mfile
#!/bin/ksh
echo "hello world"
EOF

Request for some help with 2 cases

  1. now i would like to add a second line after the first echo command
    e.g.
echo "this is line 2"

how can i do that ?

  1. I would then like to delete the first line
echo "hello world"

how can i perform this operation.

Thanks in advance,
C

Maybe use the editor of your choice and write a shell script, ie. write it into a file, like this example with the editor "vi":
(press i to insert text)

$> vi myscript.ksh
#!/bin/ksh

echo this is line 2

exit 0

(press : then write wq and hit ENTER)
$> chmod 750 myscript.ksh
$> ./myscript.ksh
this is line 2

vi might seem difficult at first but after some weeks of use you will accidentally use things like :wq in editors like Open Office Writer accidentally :slight_smile:
There are plenty of references on vi commands/shortcuts on the web.

Addendum to that: press Escape once before you enter ':wq'

Pludi is right - if your terminal is beeping often, better press once more ESC to be sure you are in the control and not in the editing mode of vi :wink:

Super !

I found some text on vi editor on the net. This works for me.

thanks for your quick replies.