Shell script programming

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ciro25
    New Member
    • Jun 2007
    • 5

    Shell script programming

    Can anybody give me an hint on how to answer this questions?



    "For the following and any subsequent exercises you ARE NOT permitted to use either SED or AWK".

    Script 1

    Pre-requisites
    Create a file with x amount of lines in it, the content of your choice.

    Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument.

    Note! The file must retain the original name
  • Motoma
    Recognized Expert Specialist
    • Jan 2007
    • 3236

    #2
    Please do not post questions in the Articles section of our site. I have moved your thread to the appropriate forum.

    Please read through out Posting Guidelines and pay close attention to our homework policy.

    If you conform to those guidelines, you should have no problem finding the help you need.

    Comment

    • ghostdog74
      Recognized Expert Contributor
      • Apr 2006
      • 511

      #3
      Originally posted by ciro25
      Can anybody give me an hint on how to answer this questions?



      "For the following and any subsequent exercises you ARE NOT permitted to use either SED or AWK".

      Script 1

      Pre-requisites
      Create a file with x amount of lines in it, the content of your choice.

      Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the first line) of the file named in your second argument.

      Note! The file must retain the original name
      to take in arguments, you can use $1, $2 etc. $1 being the first argument, $2 the second and so on. your teacher should have taught you this before he asked you to do homework. you can use echo $1 >> $2 to insert a line into $2, which is your file name.
      i believe you can start writing the script now.

      Comment

      • ciro25
        New Member
        • Jun 2007
        • 5

        #4
        if i do in this way $1>>$2 the line of text would go at the end of the file and not on the top of the file.
        how about f i use -ed- editor?

        Comment

        Working...