LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   hot to al line before last 2 lines (https://www.linuxquestions.org/questions/linux-newbie-8/hot-to-al-line-before-last-2-lines-823639/)

ahmenty 08-02-2010 03:44 PM

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!

onebuck 08-02-2010 04:39 PM

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

:hattip:
The above links and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!

ahmenty 08-04-2010 12:08 AM

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


All times are GMT -5. The time now is 08:14 AM.