09-15-2006
Inserting New Line in File using Sed ??
Dear All,
I have a file called football where i have a list of 11 players each on different lines.
I wish to add a name of another player on the first line.
I have created a file called footballscript in vi writing the following sed command to achieve this ...
cat football | sed -e '1 i\ zidane' > newfootball
with newfootball the new output file
On the command line in UNIX i type sh footballscript to run the script but get the following error message;
sed: -e expression #1, char 5:Extra characters after command
Can ne1 point out my mistake or suggest an alternative sed code for this please?
Major thanks in advance
Mary
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm sure you guys have answered this elsewhere but I can't seem to find where so here goes.
#!/bin/bash
n=120
a=$(sed '120q;d' energy.xvg)
while ;do
a=$(sed $n'q;d' energy.xvg)
echo "$a \n" > newfile
n=$(($n+100))
done
exit 0
that script should read the file energy.xvg, start at... (1 Reply)
Discussion started by: gelitini
1 Replies
2. Shell Programming and Scripting
I need a perl script to find and replace a specific pattern in a file to a new line.
BAsically I have a single line data in a file with 10 mb to 200 MB. I want to put a new line based on a specific pattern to open the file in Excel / Access.
Following is the sample data in a file
... (1 Reply)
Discussion started by: portalfaq
1 Replies
3. Shell Programming and Scripting
I have posted it previously but somehow could not delete the previous post.I felt i could not explain the problem statement well.
Here t goes.I have a file say File1. Now i need a specific pattern from the lines to be added to the other line.
File:
red blue green ABC.txt@ABC END
black... (1 Reply)
Discussion started by: ngupta
1 Replies
4. Shell Programming and Scripting
Hi,
I have this line:
ip=111.222.133.144,mac=00:16:3E:2A:08:3C,vifname=veth360','ip=10.2.3.4,vifname=veth360a'
^
|
-------
I want to insert this IP 144.133.222.111 between "144"... (4 Replies)
Discussion started by: iga3725
4 Replies
5. Shell Programming and Scripting
Friends ,
I have a large file and i need to insert a line after every line.I am actually unaware how to do it.Any help appreciated.
My File
control station *ATM* , qread $OSS.Jul13A.FI01 interval 1 intcount 1
control station *ATM* , qread $OSS.Jul13A.FI02 interval 1 intcount... (4 Replies)
Discussion started by: appu2176
4 Replies
6. Shell Programming and Scripting
Could anyone tell me how to insert a line at a particular line number using sed.
sed '2i\newtext' filename
I have tried the above command .But it is not working. I am using tcsh shell .Please help.
Double post, continued here (0 Replies)
Discussion started by: maitree
0 Replies
7. Shell Programming and Scripting
hello ..
I am new to perl scripting, I have a text file, and would like to insert 3 new lines into the same file at different line numbers using perl scripting. Any Help regarding this will be very useful.
say the file is sample.txt, contents are
aaaaa
bbbb
ccccc
dddd
eeeee
ffffffff... (4 Replies)
Discussion started by: hemalathak10
4 Replies
8. Shell Programming and Scripting
I need to insert text from one file into another file after specific term. I guess sed is the best method of doing this and I can insert a specified text string using this script but I am not sure how to modify it to insert text from another file:
#!/bin/sh
sed 's/\<VirtualHost... (17 Replies)
Discussion started by: barrydocks
17 Replies
9. UNIX for Dummies Questions & Answers
Hello,
I've been trying to get a script working that fetches weather-data and converts it into an .ics file. The script works so far put I'm stuck at the point where I need to add specific static data. A thorough search through the forum did not point me into the right direction.
#!/bin/bash... (3 Replies)
Discussion started by: Schubi
3 Replies
10. Shell Programming and Scripting
Hi,
consider a file called mobile.txt as follows:
For type lovers, add a new line at the end of it by copying its previous line and add a +1 to the field1, field2
Additionally, there are only 3 plans available to lovers type, so it should not work for lovers type already having 3 lines under... (11 Replies)
Discussion started by: Gautham
11 Replies
LEARN ABOUT DEBIAN
xchain
xchain(6) Games Manual xchain(6)
NAME
xchain - Chain Reaction, Strategy game for 2-4 players
SYNOPSIS
xchain [-v] [--version] [-h] [--help] [path to wish]
DESCRIPTION
Rules of the game
Chain Reaction is played on an 8 by 8 board. Players take turns to move. On each move, the player may select an empty square, or one they
already own. Squares belonging to other players may not be chosen. If the square was unowned, it becomes the property of the player, and
is given a value of 1. If the square was owned by the player, the value is incremented.
If the value of a square ever exceeds the maximum permitted of that square, it explodes. Squares in the corner have a maximum of 1, squares
touching an edge, but not on a corner have a maximum of 2, and squares in the interior have a maximum of 3.
When a square explodes, it becomes unowned, and it's value is reset to 0. The 4 squares touching it become owned by the owner of the
exploding square, and their values are incremented. If any of these are above their maximum, they explode, giving rise to the chain reac-
tion.
If, at the end of a move, any of the players have no squares, they are dead, and get no more turns. When there is only one person left,
they are the winner.
Game options
On loading the game, a 2 player game with a blank board is loaded. To change this, edit the settings to suit, and click on "New Game".
Clicking on this in the middle of a game will abandon it, and start a new one.
To select the number of players, click on the numbered radio buttons. To the right of these are entry boxes to fill in player names, if
desired. The background to these shows the colour of the players' squares. Names and colours are only updated when "New Game" is clicked
on. To the right of these, are counters of the number of squares belonging to each player.
If a shorter game is desired, squares can be set for the players before the game starts. This can be up to 4 rows and columns, or a random
placement. For 2 players, up to 32 squares each may be chosen. For 3 players, up to 21 each, and for 4 players, up to 16 each.
Whoever goes first has quite an advantage. To offset this, a random first person can be chosen. On clicking "New game", the status bar
below the board shows who this will be.
OPTIONS
-h, --help
Show summary of options.
-v, --version
Show version of program.
path to wish
Chain Reaction requires the wish tcl/tk interpreter. By default it uses /usr/bin/wish (The default for Debian GNU/Linux, and most
other Unix-like systems). Use this option to force a different location.
FILES
/usr/bin/wish
Default location of wish tcl/tk interpreter.
BUGS
Not guaranteed to be free of potential buffer overflows. Do not use setuid, or with greater privilege than the players using it.
WISH LIST
Network support.
A way to save game settings - either environment variables, or a settings file.
HISTORY
First seen many years ago on the (as it was then) Acorn Archimedes. Original author unknown. Written for Unix by Alistair Cunningham
<ac212@cam.ac.uk>
http://thor.cam.ac.uk/~ac212/xchain/
xchain(6)