Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How can I stack multiple (>1000) fields into one continuous field? Post 303034943 by jim mcnamara on Thursday 9th of May 2019 04:00:09 PM
Old 05-09-2019
Let me replay this a bit.
Pretend we have :
Code:
1 2 3 4 5
A B C E
X Y Q M

You want this be stacked all into single column:
Code:
1
2
3
4
5
A
B
C
E
X
Y
Q
M

Right?
Try this
Code:
awk '{ for (i=1 ; i<NF; i++) 
            {
               printf("%s\n", $(i) );
            } 
          } ' inputfilename  > outputfilename

Running the code
Code:
Owner@Owner-PC ~
$ mv infile inputfilename

Owner@Owner-PC ~
$ ./t.awk

Owner@Owner-PC ~
$ cat outputfilename
1
2
3
4
A
B
C
X
Y
Q

$ cat t.awk
Code:
awk '{ for (i=1 ; i<NF; i++)
            {
               printf("%s\n", $(i) );
            }
          } ' inputfilename  > outputfilename

Owner@Owner-PC ~
Code:
$ ls -l t.awk
$ ls -l t.awk
-rwxr-xr-x 1 Owner None 143 May  9 13:56 t.awk

You have to chmod +x t.awk to make it an executable script
This User Gave Thanks to jim mcnamara For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to split a field into two fields?

Hi, I have a comma delimited text file where character fields (as opposed to numeric and date fields) are always enclosed with double quotes. Records are separated by the newline character. In a shell script I would like to split a particular field into two separate fields (enclosed with double... (4 Replies)
Discussion started by: vbrown
4 Replies

2. Shell Programming and Scripting

Sorting on two fields time field and number field

Hi, I have a file that has data in it that says 00:01:48.233 1212 00:01:56.233 345 00:09:01.221 5678 00:12:23.321 93444 The file has more line than this but i just wanted to put in a snippet to ask how I would get the highest number with time stamp into another file. So from the above... (2 Replies)
Discussion started by: pat4519
2 Replies

3. UNIX for Dummies Questions & Answers

Formatting Multiple fields on 1 line to multiple rows

I'm trying extract a number of filename fields from a log file and copy them out as separate rows in a text file so i can load them into a table. I'm able to get the filenames but the all appear on one line. I tried using the cut command with the -d (delimiter) option but cant seem to make it... (1 Reply)
Discussion started by: Sinbad-66
1 Replies

4. Shell Programming and Scripting

compare two fields and get a third field

Hello, I'm trying to get a value based on a comparison of two fields, this is: file1 687.45 687.18 687.322 687.405 686.865 file 2 685 6.43 686 6.43 687 6.42 688 6.42 (3 Replies)
Discussion started by: Gery
3 Replies

5. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

6. Shell Programming and Scripting

UNIX append field with comparing fields from multiple column

I have a csv dump from sql server that needs to be converted so it can be feed to another program. I already sorted on field 1 but there are multiple columns with same field 1 where it needs to be compared against and if it is same then append field 5. i.e from ANG SJ,0,B,LC22,LC22(0) BAT... (2 Replies)
Discussion started by: nike27
2 Replies

7. Linux

How do I format a Date field of a .CSV file with multiple commas in a string field?

I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in... (3 Replies)
Discussion started by: dhruuv369
3 Replies

8. Shell Programming and Scripting

Single Field to multiple fields searching

I have a fileA with one column (1000 rows), and fileB with 26 columns(13000 rows). I need to search each value of fileA with fileB and return all the 26 values from FileB to a new file- File C if matches. The search value (from FileA) may present in any of the 26 values in FileB. This value is not... (7 Replies)
Discussion started by: vamsikrishna928
7 Replies

9. Shell Programming and Scripting

Inserting a field without disturbing field separator on other fields

Hi All, I have the input as below: cat input 032016002 2.891 97.109 16.605 27.172 24.017 32.207 0.233 0.021 39.810 0.077 0.026 19.644 13.882 0.131 11.646 0.102 11.449 76.265 23.735 16.991 83.009 8.840 91.160 0.020 99.980 52.102 47.898 44.004 55.996 39.963 18.625 0.121 1.126 40.189... (15 Replies)
Discussion started by: am24
15 Replies

10. UNIX for Beginners Questions & Answers

Extract a column and multiple by 1000 and replace it on same file

Hi All, I need to extract a position in the file and multiple the value by 1000 and the replace it . Original 0010001200084701217637306521200000000000010010000000 ---> 000847 * 1000 0010012700086001213437404323000000000000001001000000 ---> 000860 * 1000... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies
eucset(1)						      General Commands Manual							 eucset(1)

NAME
eucset - Sets and gets EUC code widths for the terminal SYNOPSIS
eucset [cswidth] eucset -p OPTIONS
Displays the current settings of the EUC character widths for the terminal DESCRIPTION
The eucset command sets or gets the encoding and display widths of the Extended UNIX Code (EUC) characters processed by the current input terminal. EUC is an encoding method for code sets composed of single or multiple bytes. It permits applications and the terminal hardware to use the 7-bit US ASCII code and up to three single- or multibyte code sets simultaneously. If you use the eucset command to set EUC character widths, but do not specify the cswidth argument, 7-bit U.S. ASCII is applied as a default code set. You must use the command to specify any other EUC code sets, whether they are single-byte or multibyte. EUC Code Set Classes EUC divides code sets into four classes. Each code set class has two characteristics: the number of bytes for encoding the characters in the class, and the number of display columns to display the characters in the class. All characters within a class possess the same char- acteristics. Class 0 consists of all 7-bit, single-byte ASCII characters. The most-significant bit of each of these characters is 0 (zero). Characters in class 0 require one byte for encoding, and occupy one display column. These values are fixed for class 0 (zero). The 7-bit US ASCII code is the primary EUC code set, which is available to users without direct specification. A class 1 code set is a supplementary EUC code set. Class 1 characters have an initial byte whose most-significant bit is 1. If character classes 2 or 3 are to be used, this initial byte must not be the SS2 or SS3 character, as these designate character classes 2 and 3. Char- acters in class 1 may require more than 1 byte for encoding, and may require more than 1 display column. The eucset command must be used to set the characteristics for code set class 1. Class 2 and 3 code sets are supplementary EUC code sets. Characters in these classes have an initial byte of SS2 or SS3, respectively. They require more than 1 byte for encoding, and may require more than 1 display column. The eucset command must be used to set the charac- teristics for code set classes 2 and 3. The cswidth argument in the eucset command line is a character string that describes the character widths for code set classes 1 through 3. The string is of the following format: X1[:Y1], X2[:Y2], X3[:Y3] The value X1 is the number of bytes required to encode a character in code set class 1. Y1 is the number of display columns needed to dis- play characters in this class. X2 is the number of bytes required to encode a character in code set class 2, not counting the SS2 byte, and Y2 is the number of display columns for code set class 2 characters. X3 is the number of bytes needed to encode characters in code set class 3, not counting the SS3 byte, and Y3 is the number of display columns required for these characters. The values for the column widths can be omitted if they are equal to the number of encoding bytes. If the encoding value of any of the EUC code sets is set to 0 (zero), this indicates that the code set does not exist. If no cswidth argument is supplied, the eucset command uses the value of the CSWIDTH environment variable. If this variable is not present, the default string 1:1,0:0,0:0 is substituted. This default string designates that the environment uses a single-byte EUC code set that has characters in the EUC code set class 1 format. If the environment uses a multibyte EUC code set in the code set class 1 format, single- or multibyte EUC code sets in the code set class 2 or 3 format, or both, the default setting cannot be used. DIAGNOSTICS
Your standard input is not an interactive terminal. The maximum character width of 8 was exceeded. EXAMPLES
To display the encoding and display widths for the EUC code set classes 1-3 in your environment, enter: eucset -p To change the current settings of the encoding and display widths for the EUC characters in code set classes 1 and 2 to 2 bytes each, enter: eucset 2:2,2:2,0:0 or eucset 2,2,0 SEE ALSO
Interfaces: eucioctl(7) eucset(1)
All times are GMT -4. The time now is 07:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy