![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum 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 |
| script question | ace2000 | Shell Programming and Scripting | 7 | 04-18-2008 12:39 PM |
| cgi script question | zilla30066 | Shell Programming and Scripting | 1 | 05-03-2007 11:56 AM |
| script question | fusionjd | Shell Programming and Scripting | 1 | 02-05-2006 03:38 PM |
| script question | shad0w75 | UNIX for Dummies Questions & Answers | 2 | 06-19-2003 01:53 PM |
| Script Question | merlin | UNIX for Dummies Questions & Answers | 2 | 11-20-2001 07:57 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Script question
Can anyone help with these scripts? Im new to this and struggling. Thank you for your help.
Pre-requisites Create a file with x amount of lines in it, the content of your choice. (Have already done this) Script 1 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 Once complete save the script. Script 2 Take a copy and amend the above script so that it now inserts the first argument into the middle of the file. Note! Again the original file must retain it original name |
| Forum Sponsor | ||
|
|
|
#3
|
|||
|
|||
|
Help!
I have a script that takes two arguments.
The first argument is a string and the second argument is the name of a file. The script inserts the string into the first line of the file and then saves it. The problem im having is that it is saving the wrong message to the file. e.g. File1 has the following data: Line1 Line2 I invoke the script as follows. ./Script1 Hello File1 Script1 contains the following data: cat $2 > tempFile MESSAGE=$1 awk ' NR==1 { printf "%s\n", $MESSAGE } { printf $0 "\n" } ' tempFile > $2 rm tempFile The result should be: Hello Line1 Line2 But I am getting the following result: Line1 Line1 Line2 Any ideas on what i am doing wrong? Thank you. |
|
#4
|
||||
|
||||
|
Threads merged and closed.
|
||||
| Google The UNIX and Linux Forums |