02-10-2009
sed: appending alternate line after previous line
Hi all,
I have to append every alternate line after its previous line. For example if my file has following contents
line 1: unix is an OS
line 2: it is open source
line 3: it supports shell programming
line 4: we can write shell scripts
Required output should be
line1: unix is an OS it is open source
line 2: it supports shell programming we can write shell scripts
I think this could be done using sed, but how could i do this please help?
If it cant be done using sed then please suggest other methods
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi folks,
I need to append line or bulk of lines into a file.
For example,I have the following section in opmn.xml file:
<process-type id="OC4J_RTEadmin_NIR" module-id="OC4J">
<module-data>
<category id="start-parameters">
<data... (28 Replies)
Discussion started by: nir_s
28 Replies
2. Shell Programming and Scripting
Hi,
I searched the forum for this but couldn't find the answer. Basically I have a line of code I want to insert into a file using sed. The line of code is basically something like "address=1.1.1.1" where 1.1.1.1 is an IP Address that will vary depending on what the user enters. I'll just refer... (4 Replies)
Discussion started by: eltinator
4 Replies
3. Shell Programming and Scripting
I've been trying to merge a previous line when I find a pattern using sed with no luck. Maybe someone can help me.
I am trying to find </Endtag>. Once I find that, I want to merge the previous line with the current line. I can do it with the next line with using N in sed but not previous.... (6 Replies)
Discussion started by: quixoticking11
6 Replies
4. Shell Programming and Scripting
Hi,
how can i print the previous, current and next line using sed?
current line is the matching line.
The following prints all lines containing 'Failure' and also the immediate next line
cat $file | sed -n -e '/Failure/{N;p;}'
Now, i also want to print the previous line too.
Thanks,... (8 Replies)
Discussion started by: ysrinu
8 Replies
5. Shell Programming and Scripting
Hi,
How can I remove the line beak in the following case if the line begin with the special char “;”?
TEXT
Text;text
;text
Text;text;text
I want to convert the text to:
Text;text;text
Text;text;text
I have already tried to use... (31 Replies)
Discussion started by: research3
31 Replies
6. Shell Programming and Scripting
I know this has been asked before but I just can't parse the syntax as explained. I have a set of files that has user information spread out over two lines that I wish to merge into one:
User1NameLast User1NameFirst User1Address
E-Mail:User1email
User2NameLast User2NameFirst User2Address... (11 Replies)
Discussion started by: walkerwheeler
11 Replies
7. Shell Programming and Scripting
Hello everyone,
I am working with some train time tables, and i have hit a bit of a road block.
Using grep/sed i have done a reasonable job of parsing the html into comma delimited format, but NJ transit prints The Track number and status on a new line, and I would much prefer it all on a... (6 Replies)
Discussion started by: mussen
6 Replies
8. 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
9. Shell Programming and Scripting
I am trying to delete lines in archived Apache httpd logs
Each line has the pattern:
<ip-address> - - <date-time> <document-request-URL> <http-response> <size-of-req'd-doc> <referring-document-URL>
This pattern is shown in the example of 6 lines from the log in the code box below. These 6... (1 Reply)
Discussion started by: Proteomist
1 Replies
10. Shell Programming and Scripting
Hi All,
I'm appending a line before a pattern and after another pattern(;) but omitting the first pattern - same as if comes duplicates before the second pattern.
Also, I'm adding a word before the first pattern -
Here is my file
select blah blah
hello
select blah blah
;
select... (6 Replies)
Discussion started by: Mannu2525
6 Replies
QUIZ(6) Games Manual QUIZ(6)
NAME
quiz - test your knowledge
SYNOPSIS
/usr/games/quiz [ -i file ] [ -t ] [ category1 category2 ]
DESCRIPTION
Quiz gives associative knowledge tests on various subjects. It asks items chosen from category1 and expects answers from category2. If no
categories are specified, quiz gives instructions and lists the available categories.
Quiz tells a correct answer whenever you type a bare newline. At the end of input, upon interrupt, or when questions run out, quiz reports
a score and terminates.
The -t flag specifies `tutorial' mode, where missed questions are repeated later, and material is gradually introduced as you learn.
The -i flag causes the named file to be substituted for the default index file. The lines of these files have the syntax:
line = category newline | category `:' line
category = alternate | category `|' alternate
alternate = empty | alternate primary
primary = character | `[' category `]' | option
option = `{' category `}'
The first category on each line of an index file names an information file. The remaining categories specify the order and contents of the
data in each line of the information file. Information files have the same syntax. Backslash `' is used as with sh(1) to quote syntacti-
cally significant characters or to insert transparent newlines into a line. When either a question or its answer is empty, quiz will
refrain from asking it.
FILES
/usr/games/quiz.k/*
BUGS
The construct `a|ab' doesn't work in an information file. Use `a{b}'.
QUIZ(6)