Computing.Net > Forums > Solaris > how to insert text into a file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

how to insert text into a file

Reply to Message Icon

Name: Linda_1
Date: October 6, 2005 at 07:40:33 Pacific
OS: win2k, xp, win98
CPU/Ram: 850MHz/200Meg
Comment:

Hello everyone,
I have a file (tapes to be ejected from library) and need to insert a blank line and the statement eject 0,1,0 after every 14 lines.
I'm going crazy trying to find a sed command but its not working.
using ksh

Thank you guys
Linda



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: October 6, 2005 at 14:11:24 Pacific
Reply:

Linda:

You'll get more timely answers for unix scripting over in the unix forum, but ...

Here's a sed solution:

sed 'x
s/$/#/
/#\{14\}/{
a\
eject 0,1,0
s/.*//
}
x' data.file

I borrowed this so don't even ask me to explain it. Go here for that: http://main.rtfiber.com.tw/~changyj/sed/html/p.20010222a.html

If it were me, I'd set up a ksh while loop and read the file a line at a time.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: how to insert text into a file

how to connect and use a tape drive www.computing.net/answers/solaris/how-to-connect-and-use-a-tape-drive/444.html

How to call an URL from a shell scr www.computing.net/answers/solaris/how-to-call-an-url-from-a-shell-scr/3998.html

how to count lines in binary files? www.computing.net/answers/solaris/how-to-count-lines-in-binary-files/3163.html