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.
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'): -
7 i lineSeven
-
10 i lineTen
-
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):
The output will have new lines 7 and 10.
You may want to redirect things to a new file: -
sed -fcomm >myNewFile <myFile
-
HTH,
arne
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.
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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.
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| | |