LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-02-2010, 04:44 PM   #1
ahmenty
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Rep: Reputation: 0
hot to al line before last 2 lines


I need to add a line in a file before the last two lines using a script using standard linux editors like sed but i can't figure it out.
Any suggestions?
Thank you!
 
Old 08-02-2010, 05:39 PM   #2
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,549
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Welcome to LQ!

So you've shown us your need! What's your deed?

We will aid you when you help yourself to a solution. Provide us with what you have attempted and then maybe someone will be able to assist.

'How to Ask Questions the Smart Way' would be one link you should look at to help us to help you in the future.

Smells like homework?

Just a few more links to aid you;

Linux Documentation Project
Rute Tutorial & Exposition
Linux Command Guide
Utimate Linux Newbie Guide
LinuxSelfHelp
Getting Started with Linux
Bash Reference Manual
Advanced Bash-Scripting Guide
Linux Home Networking
Virtualiation- Top 10


The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
Old 08-04-2010, 01:08 AM   #3
ahmenty
LQ Newbie
 
Registered: Aug 2010
Posts: 4

Original Poster
Rep: Reputation: 0
how to add line before last 2 lines

It's a script that ads a line at a specific line number
This file is changed almost every day except the last 2 lines.
I need a way to add a line always before the last two lines
This is my script...But this one ads a new line at linenumber 400.

#!/bin/bash
k="kbit"
read a b c
sed -i "400i\ 2 rate $a$k src $b # $c" eth0.cfg
sed -i "400i\ 2 rate $a$k dst $b # $c" eth1.cfg

Thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GREP: how to specify a line or lines where to search carolflb Linux - Newbie 7 11-23-2009 09:45 AM
How to grep lines containing a certain string PLUS the line following that line? kmkocot Linux - Newbie 5 09-01-2009 04:54 PM
Announcing Artha ~ An off-line English thesaurus with hot key look up & notifications legends2k Linux - News 0 02-16-2009 05:46 AM
Replace line in file with two lines?! Possible? eur0dad Linux - General 2 09-07-2006 03:15 PM


All times are GMT -5. The time now is 07:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration