The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script needed vpandey Shell Programming and Scripting 3 03-04-2008 09:45 AM
Script Needed!!!!!!!! Urgent aajan Shell Programming and Scripting 3 09-07-2007 12:38 PM
Urgent Script Needed skyineyes UNIX for Dummies Questions & Answers 1 06-20-2007 04:36 AM
Script Needed Dastard SUN Solaris 1 03-20-2007 10:54 AM
sftp script needed ravi.sadani19 Shell Programming and Scripting 1 05-02-2006 05:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-04-2007
fcbarcelona1984 fcbarcelona1984 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 3
help needed! my first script

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.
any help!
i just don't know where to start!
  #2 (permalink)  
Old 11-04-2007
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
Ok, this looks like homework, so i won't solve that for you, but will give you some hints on how you can find the answer. Note however, that asking questions regarding homework assignments is generally forbidden here so you are already on a very narrow path with your question:

Consider you have you file, the content could look like

Quote:
abc first
abc second
123 third
you have probably created it using vi or some other text editor, but which UNIX command do you use to display a file?

How you get parameters from the command line into your script is part of every shell manpage, so i won't tell you here how this is done. Consider, your line is

Quote:
this is my command line
your desired result would then be

Quote:
this is my command line
abc first
abc second
123 third
You sure have heard about output redirection, yes? If not, study your book again. You'll find your answer there along with everything you need to create your script.

bakunin
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:00 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0