![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simple Script | mojoman | Shell Programming and Scripting | 6 | 05-12-2008 12:55 AM |
| simple script help | ali560045 | Shell Programming and Scripting | 4 | 01-24-2008 01:24 AM |
| simple script | ali560045 | Shell Programming and Scripting | 1 | 01-22-2008 12:41 AM |
| simple awk script... | moxxx68 | Shell Programming and Scripting | 3 | 01-24-2005 12:17 AM |
| simple script | hedrict | UNIX for Dummies Questions & Answers | 4 | 02-23-2004 12:15 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Simple Script Help
Hi, First of all i would just like to say Hi to you all.
Ive just started trying to learn a bit of UNIX and am hopefully going to get on a course in the next couple of weeks to expand my knowledge of it however i have run into some problems surrounding one of the scripts i was asked to write as part of an introduction and was wondering if any of you here could possible help. Im not asking for an answer more some pointer in the right direction as i have been looking through books and over the net for quite some time now. The aim is the following. Write a script that takes two arguments. The first being a line of text, the second being a newly created file. The script should take the first argument and insert it into the very top line of the file named in the second argument. The file must retain the original name. Here is what i have done this far. Code:
var2="$HOME/script1/Lateralus" -----The address of the file to add to echo "Please Enter your Input" -----Line to ask for user input read var1 -----Read the input to a variable echo "Your Input was the following : $var1" --Echo input echo "This will be added to the top line of file : $var2" --Echo File address vi +0 $var2 ----Enter VI at Line 0 for filename in var2 O ----Start insert above current line Now im stuck however. How can i take what i have entered into $var1 and insert it into the file. Maybe i am wrong to be using VI to do this script however i am new to this and need some guidence. Eternally greatful to anyone that can help. Thanks for your time Last edited by Skunkie; 10-02-2006 at 06:50 AM. Reason: Trying to make it more friendly to read |
| Forum Sponsor | ||
|
|
|
|||
|
Later on i am going to need to adapt this to add the input to the centre of the file.
On this knowledge would u advice i start to look into sed/awk?? If so is there anywhere that you would advice starting. Got all these books but i dont know where to start looking : Thank you for your Help |
|
|||
|
Quote:
here might help you get started. Personally, i like Python to solve my problems.. |
|||
| Google UNIX.COM |
| Tags |
| regex, regular expressions |
| Thread Tools | |
| Display Modes | |
|
|