The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
simple sed question funksen Shell Programming and Scripting 10 04-08-2007 02:54 PM
sed - simple question scotty_123 Shell Programming and Scripting 13 03-28-2007 11:23 PM
Simple C question... Hopefully it's simple Xeed High Level Programming 6 12-15-2006 11:29 AM
Ok simple question for simple knowledge... Corrail UNIX for Dummies Questions & Answers 1 11-28-2005 10:03 AM
Simple ksh question frustrated1 Shell Programming and Scripting 1 11-05-2003 09:41 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 03-04-2008
Registered User
 

Join Date: Mar 2008
Posts: 1
Simple Question

Hi Guys,
I've been learning UNIX for the past couple of days and I came across this exercise, I can't get my head around it, so I would be ever so grateful if I could receive some sort of help or direction with this.

Create a file with x amount of lines in it, the content of your choice.
Write a script named 'firstline' 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.
Take a copy (backup) and amend the above script so that it now inserts the first argument into the middle of the file.


The problem I have is that I dont know how to edit a text using shell scripts.

Any help would be greatly appreciated

Thanks,
aforball
Reply With Quote
Forum Sponsor
  #2  
Old 03-04-2008
Registered User
 

Join Date: Dec 2006
Posts: 11
You can use ex or sed among other things. This kinda seems like homework.
Reply With Quote
  #3  
Old 03-04-2008
vbe vbe is offline
Moderator
 

Join Date: Sep 2005
Location: Switzerland
Posts: 741
I agree it looks very homework...
If you need help start by giving us the work you have done, and explain what isnt working...
>The problem I have is that I dont know how to edit a text using shell scripts.
there is no need of shell scripts yet...
What can be used to display files in unix? (that was the first question you should be able to answer!)
well : cat, more, pg-page, head tail, od...
Reply With Quote
  #4  
Old 03-04-2008
Registered User
 

Join Date: May 2005
Posts: 64
Quote:
Originally Posted by aforball View Post
Hi Guys,
I've been learning UNIX for the past couple of days and I came across this exercise, I can't get my head around it, so I would be ever so grateful if I could receive some sort of help or direction with this.

Create a file with x amount of lines in it, the content of your choice.
Write a script named 'firstline' 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.
Take a copy (backup) and amend the above script so that it now inserts the first argument into the middle of the file.


The problem I have is that I dont know how to edit a text using shell scripts.

Any help would be greatly appreciated

Thanks,
aforball
Learn how to use visual editor or vi. It would surely help you a lot in editing text in shell scripting.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0