Print list to row using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print list to row using awk
# 8  
Old 04-06-2013
Not sure I understand that post; maybe it's too late at night. You're right that additional whitespace will "insert" (better: break lines into) additional records, but setting FS="\n" will help with the whitespace, regardsless of RS= or RS=§.
# 9  
Old 04-06-2013
BTW, what is that "funny character" after the equals sign?
Code:
RS=§

I tried copy/paste/od and could not decipher.
# 10  
Old 04-07-2013
Quote:
Originally Posted by hanson44
BTW, what is that "funny character" after the equals sign?
Code:
RS=§

I tried copy/paste/od and could not decipher.
In UTF-8, it is the section sign character. It is the two-byte octal sequence 302 247.

Last edited by Don Cragun; 04-07-2013 at 12:58 AM..
# 11  
Old 04-07-2013
@RudiC. Indeed you can use FS='\n' avoids problems with other white space, but it still breaks the input into multiple records if there are empty lines. If such empty lines need to turn into separated fields and may not be compressed into one, then you cannot use RS= . But using a different RS ( that does not occur in the text ) does introduce an extra character after the last record. In both cases this may lead to record length problems in some versions of awk. These are all extra considerations that are not there when paste -sd, file is used.

Last edited by Scrutinizer; 04-07-2013 at 03:32 AM..
# 12  
Old 04-07-2013
@Hanson44: Actually, it's the paragraph sign (=section separator!), located at <shift>3, replacing the # there, so common on german keyboards that I never spent a thought on it. In ISO-8859-1, it is 0xA7, translating to 0xC2A7 in UTF-8.
Support your local locale!

@Scrutinizer: I think I got you now. Looks like you could make any control char (^B) the record separator to achive the same result.

Last edited by RudiC; 04-07-2013 at 03:39 AM..
# 13  
Old 04-07-2013
@RudiC, exactly it could be any character, as long as it will not occur in the input file, so that the entire input file is one record....
# 14  
Old 04-07-2013
Quote:
Originally Posted by RudiC
@Hanson44: Actually, it's the paragraph sign (=section separator!), located at <shift>3, replacing the # there, so common on german keyboards that I never spent a thought on it. In ISO-8859-1, it is 0xA7, translating to 0xC2A7 in UTF-8.
Support your local locale!

@Scrutinizer: I think I got you now. Looks like you could make any control char (^B) the record separator to achive the same result.
RudiC,
Interesting. In English, the paragraph sign (AKA "paragraph mark" or "pilcrow") is denoted by the character ¶ (UTF-8 octal 302 266 or hex C2 B6) and is very different from the section sign (AKA "double S" and "sectional symbol") which is denoted by the character § which as you said is UTF-8 hex C2 A7 or as I said is UTF-8 octal 302 247.

Scrutinizer,
Yes, any non-null character not otherwise present in the input file could be used as long as it is a valid character in the current locale.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Print all lines in a row except the last one with awk

Hi again, is it possible to do the following using awk? input file is 4.465E+17 5.423E+16 1.218E+17 2.600E+16 9.135E+15 1.238E+14 ... 6.238E+14 desired output 4.465E+17 & 5.423E+16 & 1.218E+17 & 2.600E+16 & 9.135E+15 & 1.238E+14 & ... & (3 Replies)
Discussion started by: f_o_555
3 Replies

2. Shell Programming and Scripting

Print row on 4th column to all row

Dear All, I have input : SEG901 5173 9005 5740 SEG902 5227 5284 SEG903 5284 5346 SEG904 5346 9010 SEG905 5400 5456 SEG906 5456 5511 SEG907 5511 9011 SEG908 5572 9015 SEG909 5622 9020 SEG910 5678 5739 SEG911 5739 5796 SEG912 5796 9025 ... (3 Replies)
Discussion started by: attila
3 Replies

3. Shell Programming and Scripting

Get row number from file1 and print that row of file2

Hi. How can we print those rows of file2 which are mentioned in file1. first character of file1 is a row number.. for eg file1 1:abc 3:ghi 6:pqr file2 a abc b def c ghi d jkl e mno f pqr ... (6 Replies)
Discussion started by: Abhiraj Singh
6 Replies

4. UNIX for Dummies Questions & Answers

awk to print first row with forth column and last row with fifth column in each file

file with this content awk 'NR==1 {print $4} && NR==2 {print $5}' file The error is shown with syntax error; what can be done (4 Replies)
Discussion started by: cdfd123
4 Replies

5. Shell Programming and Scripting

Print unique names in each row of a specific column using awk

Is it possible to remove redundant names in the 4th column? input cqWE 100 200 singapore;singapore AZO 300 400 brazil;america;germany;ireland;germany .... .... output cqWE 100 200 singapore AZO 300 400 brazil;america;germany;ireland (4 Replies)
Discussion started by: quincyjones
4 Replies

6. Shell Programming and Scripting

print the whole row in awk based on matched pattern

Hi, I need some help on how to print the whole data for unmatched pattern. i have 2 different files that need to be checked and print out the unmatched patterns into a new file. My sample data as follows:- File1.txt Id Num Activity Class Type 309 1.1 ... (5 Replies)
Discussion started by: redse171
5 Replies

7. Shell Programming and Scripting

AWK Script - Print a column - within a Row Range

Hi, Please read the whole thread. I have been working on this script below. It works fine, feel free to copy and test with the INPUT File below as well. example: PACKET DATA PROTOCOL CONTEXT DATA APNID PDPADD EQOSID VPAA PDPCH PDPTY PDPID 10 ... (6 Replies)
Discussion started by: panapty
6 Replies

8. Shell Programming and Scripting

awk print specific columns one row at a time

Hello, I have the following piece of code: roleName =`cat $inputFile | awk -F';' '{ print $1 }'` roleDescription =`cat $inputFile | awk -F';' '{ print $2 }'` roleAuthProfile =`cat $inputFile | awk -F';' '{ print $3 }'` mappedUserID (5 Replies)
Discussion started by: pr0tocoldan
5 Replies

9. Shell Programming and Scripting

awk to print all row to one line

HI , My unix command output look like below , bste-ngh-bt9.hecen.com EA1981, 09/01/2010 17:56:56 03/31/2011 00:00:00 I want this output changed to , all i need in one line with space ! bste-ngh-bt9.hecen.com EA1981 09/01/2010 17:56:56 03/31/2011 00:00:00 need to get all in... (17 Replies)
Discussion started by: gnanasekar_beem
17 Replies

10. Shell Programming and Scripting

shell script(Preferably awk or sed) to print selected number of columns from each row

Hi Experts, The question may look very silly by seeing the title, but please have a look at it clearly. I have a text file where the first 5 columns in each row were supposed to be attributes of a sample(like sample name, number, status etc) and the next 25 columns are parameters on which... (3 Replies)
Discussion started by: ks_reddy
3 Replies
Login or Register to Ask a Question