I have a problem that I want to insert and delete some chars in the middle of a file. fopen() and fdopen() just allow to append at the end.
Is there any simple method or existing library that allow these actions? Thanks in advance.:confused: (7 Replies)
Script 1
Pre-requisites
Create a file with x amount of lines in it, the content of your choice.
Write a script that takes two arguments. The first being a line of text, the second being your newly created file. The script should take the first argument and insert it into the very top (the... (3 Replies)
I wrote a script like
#!/bin/bash
echo $1 > temp
cat $2 >> temp
mv temp $2
now I have problem appending the above script(only using bash shell) so that it now inserts the first argument into the middle of the file.
I have tried using $(('wc -l < file' / 2 ))
but invain so could any one... (4 Replies)
how to insert one file into another file not by concatenating as usual done.
file1
A B
C D
E F
G H
I J
K L
file2
23455
33444
33334
33345
Output shud be
23455
A B
C D (4 Replies)
Can anyone help me pls? I want to add a text into the middle of file.
I've writtenthe following script
text to add="$1"
file="$2"
lines=$(wc -l $2)
half_lines=$(expr $lines / 2)
head -$half_lines $2 > temp
echo "text to add" >> temp
((half_lines=$half_lines + 1))
tail -$half_lines $2... (6 Replies)
Hey guys, how do we take a line of text as an argument from a user and then insert it in the middle of a file irrespective of the number of lines in the file. I am trying to do this without SED or AWK. Inserting it in the beginning and at the end is easy, but i am trying to accomplish inserting... (6 Replies)
I have tried
sed '/6/a text_to_inserted' file > newfile
but this inserts test_to_insert at random places in file and i want it in specific location, which is line 6.
can anyone help.... (6 Replies)
Hi I am trying to write a bash script to add a line of text to the middle of a file.
The way I worked it out was to calculate the number of lines and divide by 2. The file I am using is called newfile and it just contains lines of data.
The new file I have created I have called midfile and... (7 Replies)
Hi,
So far i've made a script that takes two argument, 1st is the contents and the 2nd is the named file. At the moment i've managed to insert new contents as a new line at the top, but i want to ask how can you insert contents in the middle of the file?
Source Code
#!/bin/bash
#Write... (3 Replies)
Discussion started by: zen10
3 Replies
LEARN ABOUT HPUX
dteditorgotoline
DtEditorGoToLine(library call) DtEditorGoToLine(library call)
NAME
DtEditorGoToLine -- move the insert cursor for a DtEditor widget to a specified line
SYNOPSIS
#include <Dt/Editor.h>
void DtEditorGoToLine(
Widget widget,
int lineNumber);
DESCRIPTION
The DtEditorGoToLine function moves the insert cursor for the DtEditor widget to the beginning of the line specified by the lineNumber
argument. The cursor can be moved to the last line by specifying DtEDITOR_LAST_LINE as the line number. If the line is not currently on-
screen, the contents for the DtEditor widget are scrolled to display the new insertion position.
The lineNumber argument is the number of the line in the file, counting from 1. If the lineNumber argument is less than 1, the insert cur-
sor is placed at the beginning of the first line. If the argument is greater than the total number of lines, the cursor is placed at the
last line of text.
The insert cursor can be moved to a specific character position with DtEditorSetInsertionPosition(3). The DtNtopCharacter resource can be
used to control which line is displayed at the top of the DtEditor widget.
The widget argument specifies the DtEditor widget ID.
The lineNumber argument specifies the line number within the DtEditor widget.
For a complete definition of the DtEditor widget and its associated resources, see DtEditor(3).
RETURN VALUE
The DtEditorGoToLine function returns no value.
SEE ALSO
Dt/Editor.h - DtEditor(5), DtEditor(3), DtEditorSetInsertionPosition(3).
DtEditorGoToLine(library call)