Visit Our UNIX and Linux User Community

Combine two lines

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Combine two lines
# 8  
Old 11-15-2002
The AWK solution is of course very simple and easy to read Smilie

awkit file:
/^[0-9]/{print $1,d}

For each line starting with an alphabetic character, store it in variable d.
For each line starting with a numeric character, print it and varialble d.

awk -f awkit < test.txt


Previous Thread | Next Thread
Test Your Knowledge in Computers #770
Difficulty: Medium
IBM POWER4 (2001) had off-chip L3 caches of 32 MB per processor, shared among several processors.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to remove lines that do not start with digit and combine line or lines

I have been searching and trying to come up with an awk that will perform the following on a converted text file (original is a pdf). 1. Since the first two lines are (begin with) text they are removed 2. if $1 is a number then all text is merged (combined) into one line until the next... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. Shell Programming and Scripting

awk to combine lines if fields match in lines

In the awk below, what I am attempting to do is check each line in the tab-delimeted input, which has ~20 lines in it, for a keyword SVTYPE=Fusion. If the keyword is found I am splitting $3 using the . (dot) and reading the portion before and after the dot in an array a. If it does have that... (12 Replies)
Discussion started by: cmccabe
12 Replies

3. UNIX for Dummies Questions & Answers

Combine lines in file

Hi All, I am trying to understand if its possible to carry out the following. I have a text file which contains output from multiple commands, within the file a node will be quiered twice if there was 2 commands for example. Is it possible do combine 2 lines into 1 if the first word is the... (1 Reply)
Discussion started by: mutley2202
1 Replies

4. Shell Programming and Scripting

Combine 2 lines

All, i am new to linux script... source Filter: vlan281-BUM-5M BUM-5M 0 0 Filter: vlan282-BUM-5M BUM-5M 0 0 Filter: vlan2828-BUM-5M Filter:... (2 Replies)
Discussion started by: samoptimus
2 Replies

5. UNIX for Dummies Questions & Answers

how can I combine 2 lines into one?

Hi, I have a file like this: A 1 B 2 C 3 ... And I want to have just one line like this: A 1 B 2 C 3 ... How can I do it? Thanks! (4 Replies)
Discussion started by: elsagarcia
4 Replies

6. Shell Programming and Scripting

combine 2 lines

Hello, I want to combine 2 lines in one I have a text file example: bla123 blo31 xx:yy:zz ->bla43 bli532 00:01:02 bla1237 blo351 aa:ss:dd ->bla433 bli34332 55:10:28 I want the result to be: bla123 blo31 xx:yy:zz, ->bla43 bli532 00:01:02 bla1237 blo351 aa:ss:dd, ->bla433 bli34332... (3 Replies)
Discussion started by: Petko Meshov
3 Replies

7. Shell Programming and Scripting

How to combine lines?

Hi, I have a file like this: "","arovls","some addr ", "more stuff" "","arovls","some addr", "sss" "","arovls","some addr", "sssdfvv" "","arovls","some addr", "lsdsdgf" "","aro vls","123 Main", "lSdfv" I want to... (4 Replies)
Discussion started by: erniel
4 Replies

8. UNIX for Dummies Questions & Answers

How do I combine the last 2 lines of a file

I tried to put the history line number and the date into the file with one command, and failed. Can't figure out how to get the date variable substituted for the last space captured. history | tail -1 | sed -e 's/.\{7\}/&/g' | head -1 | sed 's/ $/$date/' Result was: 729 $date So, I... (8 Replies)
Discussion started by: jimbob75
8 Replies

9. Shell Programming and Scripting

combine 2 lines

Moderator, kindly delete this thread because I already found what I needed... thanks. (0 Replies)
Discussion started by: Deanne
0 Replies

10. UNIX for Dummies Questions & Answers

Combine two lines

Hi I have a file with the records 1 A B C D 2 E F G H 3 I J K L 4 M N O P In the ouput I want 1 A B C D 2 # F G H 3 I J K L 4 M N O P How to achieve this? (10 Replies)
Discussion started by: superprg
10 Replies
machid(1)						      General Commands Manual							 machid(1)

machid: hp9000s200, hp9000s300, hp9000s400, hp9000s500, hp9000s700, hp9000s800, hp-mc680x0, hp-pa, pdp11, u370, u3b, u3b10, u3b2, u3b5, vax - provide truth value about processor type SYNOPSIS
The following commands return a true value (exit code 0) if the a processor type matches the command name. Otherwise a false value (exit code nonzero) is returned. These commands are commonly used within makefiles and shell procedures to improve portability of applications (see make(1)). +-----------+-------------------------++--------+--------------------------+ |Command | True for ||Command | True for | +-----------+-------------------------++--------+--------------------------+ |hp9000s200 | Series 200 ||pdp11 | PDP-11/45 or PDP-11/70 | |hp9000s300 | Series 300 ||u3b | 3B20 computer | |hp9000s400 | Series 400 ||u3b2 | 3B2 computer | |hp9000s500 | Series 500 ||u3b5 | 3B5 computer | |hp9000s700 | Series 700 ||u3b10 | 3B10 computer | |hp9000s800 | Series 800 or 700 ||u370 | IBM System/370 computer | |hp-mc680x0 | Series 200, 300, or 400 ||vax | VAX-11/750 or VAX-11/780 | |hp-pa | Series 700 or 800 || | | +-----------+-------------------------++--------+--------------------------+ EXAMPLES
Given a shell script that must behave differently when run on an HP 9000 Series 700 or 800 system, select the correct code segment to be executed: WARNINGS
always returns true on both Series 800 and Series 700 systems. Therefore, when using this command in scripts to determine hardware type, always use both and in the appropriate sequence to ensure correct results (see machid(1) will no longer provide support for future machines beyond the Series 800 and Series 700 systems. Decisions should be based on the hardware and software configuration information returned by getconf(1). SEE ALSO
getconf(1), make(1), sh(1), test(1), true(1). machid(1)

Featured Tech Videos