Help with using sed

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

  1. The problem statement, all variables and given/known data:

Use sed command to add the contents of variable my1stname to the beginning of file myinfo and show the results on the screen.

  1. Relevant commands, code, scripts, algorithms:

sed

  1. The attempts at a solution (include all code and scripts):
    These might be terrible but here is my attempt:

cohenb@atlas:~$ cat myinfo | sed `/cat myinfo`/ i\$my1stname
bash: /cat: No such file or directory
sed: -e expression #1, char 1: unterminated address regex
cohenb@atlas:~$ cat myinfo | sed `/cat myinfo`/ i\` $my1stname`
> ^C
bash: :s^C: substitution failed
>
cohenb@atlas:~$ cat myinfo | sed/cat myinfo/ i\cat temp1
bash: sed/cat: No such file or directory

  1. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
    Sheridan College, Brampton, Canada, Roy Hasanizadeh, SYST 13416 Linux/Unix Operating Systems

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Why sed .. Why not in this way ..

$ echo $my1stname ; cat myinfo
sed "1s/^/$my1stname -> /" myinfo 
1 Like
sed "1 i $my1stname" input_file

1 => first line
i => insert
$my1stname => insert this

If you want to make the changes inline, use -i option

sed -i "1 i $my1stname" input_file

HTH
--ahamed

Hi friends,

I am new to Unix.. I tried to ftp a file using the PASSWORD "7Vk84i&87E". I have assign this password to a variable and using it in ftp step and it is not working..

Need your help.......

note: If give the password directly instead of using a parameter I am able to login to the server

THANK YOU SO MUCH !!!!

balajesuri
and Ahmed101