473,394 Members | 1,944 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to implement text, shell

19
I need to implement some text, date, into another text file. For instance, first line in 7 line and second line in 10 line of another text file?
Thanks in advance.
Aug 30 '07 #1
3 1670
arne
315 Expert 100+
I need to implement some text, date, into another text file. For instance, first line in 7 line and second line in 10 line of another text file?
Thanks in advance.
You could use sed for this, see also 'man sed'.

For your example you could prepare a command file (stored in file 'comm'):

Expand|Select|Wrap|Line Numbers
  1. 7 i lineSeven
  2. 10 i lineTen
  3.  
The first column is the line number, the second the command ('i' for insert) and the third the new line.

If you then invoke sed on your file to be changed (name: myFile):

Expand|Select|Wrap|Line Numbers
  1. sed -fcomm <myFile
  2.  
The output will have new lines 7 and 10.

You may want to redirect things to a new file:

Expand|Select|Wrap|Line Numbers
  1. sed -fcomm >myNewFile <myFile
  2.  
HTH,
arne
Aug 30 '07 #2
ghostdog74
511 Expert 256MB
I need to implement some text, date, into another text file. For instance, first line in 7 line and second line in 10 line of another text file?
Thanks in advance.
its better to show an input file, an output format that is desired and also any code that you have written so far.
Aug 31 '07 #3
quartz
19
I will try your advice, bur in meantime I founded this command

sed -e '1h;7G;1d' text > text1

it is doing what I need.

I have one more question.

for new date I am using
#!bin/bash
date=`date+"%Y%m%d"`
echo date$ > textfile
.....

I wont to have new date in text file in column e.g. 12?

Thanks in advance
Aug 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: gwarning! | last post by:
Goal: Have multiple text files, each of various lengths, be concatenated together into one final consolidated text file. Problem: Since the names of the files to be concatenated can change from...
13
by: gavino | last post by:
This seems easy but I have been asking tcl and python IRC chat all day and no one gave an answer. I have 100 servers which need a new backup server added to a text file, and then the backup agent...
4
by: Rajen | last post by:
I have an Account class in which Date object is a member of it. When I created an account class: These errors are coming up: //////// :!g++ Account.cpp Account_main.cpp...
1
by: quartz | last post by:
I need to implement some text, date, into another text file. For instance, one line in line 7 another text, and second line to 12 line another text file? Thanks in advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.