![]() |
|
|
|
|
|||||||
| 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 takes params | keromotti | Shell Programming and Scripting | 2 | 06-06-2008 04:15 AM |
| NFS write failed for server.....error 11 (RPC: Server can't decode arguments) | sap4ever | SUN Solaris | 3 | 05-08-2008 05:20 AM |
| To Write a Shell script that takes two arguments. | bobby36 | Shell Programming and Scripting | 3 | 04-05-2007 05:44 PM |
| shell script takes long time to complete | ozzman | Shell Programming and Scripting | 12 | 02-05-2007 08:25 PM |
| Passing arguments to a script | Kevin Pryke | Shell Programming and Scripting | 3 | 06-14-2002 06:06 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Write a script that takes 2 arguments
hi
i would be grateful for some help on the following q. "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 thanks a million i have a feeling its involving sed |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Give this a try:
Code:
#!/usr/bin/sh touch $2 echo $1 > $2 Code:
# ./your_script HELLO myfile |
|
#3
|
|||
|
|||
|
I need to add text on top of an original file, this method deleted my file and just left HELLO on top..
Any suggestions |
|
#4
|
|||
|
|||
|
Sounds like you tested this on an important file...don't do that.
">" will overwrite your file, ">>" will add to your file. |
|
#5
|
|||
|
|||
|
that worked fine to append to end of line, how do you append on top of file, or in the middle say 5 lines down. Thanks for the quick response
|
|
#6
|
|||
|
|||
|
Now you are asking questions beyond parameters and simple redirection. This kind of question comes up alot, try searching the forums for examples using "sed". Once you have searched a few times, you'll find your own answers very quickly. If you get really stuck, post your question again, there is alot of help here.
|
|
#7
|
|||
|
|||
|
thanks tmarikle
|
|||
| Google The UNIX and Linux Forums |