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 > 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
Modifying file from outside Sreejith_VK Shell Programming and Scripting 9 08-21-2008 01:57 AM
Help need in modifying the text of .txt file vinna Shell Programming and Scripting 2 07-17-2008 03:21 PM
can someone help me with modifying this file eamani_sun Shell Programming and Scripting 2 05-22-2008 01:15 PM
Modifying a csv file from Shell Script not4google Shell Programming and Scripting 2 11-21-2006 06:47 AM
Modifying the final output file charbel Shell Programming and Scripting 5 10-10-2006 01:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-12-2009
corbusier corbusier is offline
Registered User
  
 

Join Date: Mar 2009
Location: Région Lac Léman
Posts: 3
Modifying a .ksh file

Hi,

i have created a simple .ksh file in the following manner

Code:
cat <<EOF >mfile
#!/bin/ksh
echo "hello world"
EOF
I have 2 questions

1. now i would like to add a second line after the first echo command
e.g. echo "this is line 2"

how can i do that ?

2. I would then like to delete the first line
Code:
echo "hello world"
how can i perform this operation.

Thanks in advance,
C

Last edited by Yogesh Sawant; 03-31-2009 at 01:45 PM.. Reason: added code tags
  #2 (permalink)  
Old 03-14-2009
palanisvr palanisvr is offline
Registered User
  
 

Join Date: Mar 2007
Location: India
Posts: 16
cat <<EOF >mfile
#!/bin/ksh
echo "hello world"
EOF

I have 2 questions

1. now i would like to add a second line after the first echo command
e.g. echo "this is line 2"

how can i do that ?

Solution :

append the new line to the exist data in the file by using :
Code:
$ echo "this is line 2" >>mfile
This will append the "this is line 2" to the existing data in the file .

2. I would then like to delete the first line
echo "hello world"

Solution :

open the file using vi

$vi mfile

step 1 : now go to ex mode by clicking ":"

then type 1d

this will delete the first line from the script
or else
u can use standard commands to achieve the same

Last edited by Yogesh Sawant; 03-31-2009 at 01:46 PM..
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 07:44 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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