to make 2 lines into 1 line using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to make 2 lines into 1 line using awk
# 1  
Old 10-03-2007
Java to make 2 lines into 1 line using awk

suppose i have a file
AAAHHHHAHH
AJJJJAAAAAA
AJJJJJAAJJAK
AJJAJJAJKKK
the output suhd be
AAAHHHHAHHAJJJJAAAAAAAJJJJJAAJJAKAJJAJJAJKKK
# 2  
Old 10-03-2007
Code:
tr -d '\n' < file > newfile

# 3  
Old 10-03-2007
Code:
awk 'BEGIN{ORS=""}1' "file" > newfile

Login or Register to Ask a Question

Previous Thread | Next Thread

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 from line with pattern match to a line that ends in a pattern

I am trying to combine lines with these conditions: 1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text. 2. If condition1 is met then continue to combine lines through a line that ends with a semicolon. 3. Ignore case when matching patterns and remove any... (5 Replies)
Discussion started by: Wes Kem
5 Replies

3. Shell Programming and Scripting

awk - make new line

Hi, I would like to make a new line example like below: "When you post an item you can just delete the files." every 3 words of the above sentence I would like to make a new line like below: " When you post an item you can just delete the files " and after the last line "the... (6 Replies)
Discussion started by: khchong
6 Replies

4. Shell Programming and Scripting

Display all the matches lines in one line using awk

Please can you let me know how to print all the matching lines from a file in one single line using awk. Thanks I have the following data in the input file data1 voice2 voice1 speech1 data2 data3 ... ... voice4 speech2 data4 and the output should be as follows data1 data2... (4 Replies)
Discussion started by: Sudhakar333
4 Replies

5. Shell Programming and Scripting

awk problem two lines in the same line

Hi guy, I have an output command like this: Policy Name: NBU.POL.ORA.PROD Policy Type: Oracle Active: yes HW/OS/Client: Linux RedHat2.6 node1 Iclude: /usr/openv/netbackup/scripts/backup_ora1.bash I would like to parse the... (1 Reply)
Discussion started by: luca72m
1 Replies

6. Shell Programming and Scripting

(awk?) print multiple lines on one line

I have a log file something like ------- report 1 ------- date 27/01/13 time 08:00 records 1234 ------- report 2------- date 27/01/13 time 08:00 records 1239 ... I'd like output to show as report 1,date 27/01/13,time 08:00,records 1234 report 2,date 27/01/13,time... (6 Replies)
Discussion started by: gefa
6 Replies

7. Shell Programming and Scripting

How to calculate mean in AWK? line by line several files, thousands of lines

I'm kinda stuck on this one, I have 7 files with 30.000 lines/file like this 050 0.023 0.504336 050 0.024 0.529521 050 0.025 0.538908 050 0.026 0.537035 I want to find the mean line by line of the third column from the files named like this: Stat-f-1.dat .... Stat-f-7.dat Stat-s-1.dat... (8 Replies)
Discussion started by: AriasFco
8 Replies

8. Shell Programming and Scripting

Break one line to many lines using awk

Break one line to many lines using awk The below code works but i want to implement without combining field 2 and 3 and then splitting i would like to do this in one command instead of writing multiple commands and creating multiple lines. nawk -F"|" '{print $1,$2SUBSEP$3}' OFS="|" file >... (16 Replies)
Discussion started by: pinnacle
16 Replies

9. Shell Programming and Scripting

Awk 2 lines to 1 line

Input File: Required Result: I have tried the following code: nawk '{for(i=1; i<=NR; i+2) {print NR,$0; getline ;print \n $0; NR=NR+2}}' temp But doesnt gives the right result. Help is appreciated (7 Replies)
Discussion started by: pinnacle
7 Replies

10. UNIX for Dummies Questions & Answers

How to make all lines into 1 line?

I have a file listing IP addresses, 1 per line, such as: 1.2.3.4 3.4.5.6 12.13.14.15 7.8.9.6 I want all of the entries to be on the same line, and quoted, such as: "1.2.3.4" "3.4.5.6" "12.13.14.15" "7.8.9.6" I got the quotes on there in vi with ":%s/^/"/g" and "%s/$/"/g" ... is there... (8 Replies)
Discussion started by: earnstaf
8 Replies
Login or Register to Ask a Question