473,516 Members | 3,277 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to implement text, shell

19 New Member
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 1672
arne
315 Recognized Expert Contributor
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 Recognized Expert Contributor
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 New Member
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
23037
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 day to day, I need to be able to dynamically generate a batch file to concatenate these files. So far, I have looked at using...
13
2366
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 restarted. If I have a list of the servers, all with same root password, and the connection is ssh. How do I connect to the server, cat the line to...
4
3535
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 /tmp/cclWe0e4.o(.text+0x17): In function `Account::Account()': : undefined reference to `Date::Date(int, int, int)' /tmp/cclWe0e4.o(.text+0x7d): In function...
1
1399
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
7276
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7408
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7581
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7548
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5714
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3259
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.