Sponsored Content
Top Forums UNIX for Advanced & Expert Users Converting rows to a single row Post 302422028 by methyl on Monday 17th of May 2010 09:39:27 AM
Old 05-17-2010
This script assumes your shell has normal "echo" syntax which interprets \c as meaning don't output a linefeed. (i.e. not the "echo -n" variant).

We output the first name surrounded by quotes and the second and subsequent lines prefixed by a comma then surrounded by quotes. The backslash before the quotes stops the shell from interpreting them.

Code:
first_time="Y"
while read line
do
    if [ "${first_time}" = "Y" ]
    then
        echo "\"${line}\"\c"
        first_time="N"
    else
        echo ",\"${line}\"\c"
    fi
done < filename.txt
echo ""   # Terminate record

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Converting Column values to comma delimted single Row

I have a requirement in which i have to read a file which has multiple columns seperated by a pipe "|" from this i have to read each column values seperately and create a comma seperated row for the column and write to another file. eg: Input file: ColA ColB 1 2 2 x 3 y... (5 Replies)
Discussion started by: nvuradi
5 Replies

2. Shell Programming and Scripting

Converting Single Column into Multiple rows

i have single column which is starting with same string(many number of rows) i have to convert each into a single row.how can i do that? laknar std mes 23 55 laknar isd phone no address amount 99 I have to convert above like below. laknar|std|mes|23|55 laknar|isd|phone... (3 Replies)
Discussion started by: laknar
3 Replies

3. UNIX for Advanced & Expert Users

convert rows to single row

Hi I want to convert multiple rows ro single row ,I have tried with below one but I am not getting what I am expecting.Please any idea a.txt conn1=stg conn2=dev path=\xxx\a1.txt fre=a conn1=stg conn2=dev path=\xxx\a2.txt freq=a awk '/a/{ORS=" "}{print}END{print "\n"}'... (5 Replies)
Discussion started by: akil
5 Replies

4. Shell Programming and Scripting

Combining multiple rows in single row based on certain condition using awk or sed

Hi, I'm using AIX(ksh shell). > cat temp.txt "a","b",0 "c",bc",0 "a1","b1",0 "cc","cb",1 "cc","b2",1 "bb","bc",2 I want the output as: "a","b","c","bc","a1","b1" "cc","cb","cc","b2" "bb","bc" I want to combine multiple lines into single line where third column is same. Is... (1 Reply)
Discussion started by: samuelray
1 Replies

5. Shell Programming and Scripting

Converting Multiple rows to Single Row using unix commands

Can somebody help me in solving this.. Input data is like 0 A 1 B 2 C 3 D 0 A1 1 B1 2 C1 3 D1 0 A2 1 B2 2 C2 3 D2 Output should be like A B C D A1 B1 C1 D1 A2 B2 C2 D2 (7 Replies)
Discussion started by: Mahantesh Patil
7 Replies

6. Shell Programming and Scripting

How to merge multiple rows into single row if first column matches ?

Hi, Can anyone suggest quick way to get desired output? Sample input file content: A 12 9 A -0.3 2.3 B 1.0 -4 C 34 1000 C -111 900 C 99 0.09 Output required: A 12 9 -0.3 2.3 B 1.0 -4 C 34 1000 -111 900 99 0.09 Thanks (3 Replies)
Discussion started by: cbm_000
3 Replies

7. Shell Programming and Scripting

Shell Code required -Output in Multiple Rows to be in single row separated by Commas -

Hola Greetings Experts , I have records spreaded across multiple lines. in attached log.txt i want output to be in 1 line like this below Atached as Output.txt. In brief Output related to 1 line is spreaded across multiple row I wanted it to be in 1 row . Please opem the file in notepad... (4 Replies)
Discussion started by: manishK
4 Replies

8. Shell Programming and Scripting

Converting a single row to multiple rows

Hi, I want to convert a single row values to multiple rows, but the no. of rows are not fixed. For example, I have a row as below abc-def-lmn-mno-xyz out put should be get abc get def get lmn get xyz (4 Replies)
Discussion started by: Suneel Mekala
4 Replies

9. Shell Programming and Scripting

Converting Single Column into Multiple rows

Hi .. anyone can you help me ? i need to convert text below into multiple columns interface; GigabitEthernet0/0/0/0 description; TRUNK_PE-D2-JT2-VPN_Gi0/0/0/0_TO_ME4-A-JKT-JT_4/1/1_1G mtu 9212 negotiation auto interface; GigabitEthernet0/0/0/0.11 description; tes encapsulation;... (1 Reply)
Discussion started by: mad3linux
1 Replies

10. Shell Programming and Scripting

Splitting single row into multiple rows based on for every 10 digits of last field of the row

Hi ALL, We have requirement in a file, i have multiple rows. Example below: Input file rows 01,1,102319,0,0,70,26,U,1,331,000000113200000011920000001212 01,1,102319,0,1,80,20,U,1,241,00000059420000006021 I need my output file should be as mentioned below. Last field should split for... (4 Replies)
Discussion started by: kotra
4 Replies
deckanji(5)							File Formats Manual						       deckanji(5)

NAME
deckanji - A character encoding system (codeset) for Japanese DESCRIPTION
The DEC Kanji codeset consists of the following characters: ASCII or JIS X0201 Roman letters Katakana characters specified by JIS X0201 JIS X0208 characters User-defined characters (UDC) DEC Kanji uses a combination of single-byte data and two-byte data to represent these characters. JIS X0201 is a single-byte character set and consists of Roman letters and Katakana characters, which are Japanese phonetic symbols. The Roman letters defined in the JIS X0201-1976 standard are the same as ASCII letters. (For information on the ASCII character set, refer to ascii(5).) However, JIS X0201 replaces the ASCII tilde (~) character with a horizontal bar (located at the upper part of a character cell), and replaces the backslash () with the Japanese currency sign (Yen). The JIS XO208 standard specifies two-byte character values that represent a variety of characters, including ideographic symbols. DEC Kanji Encoding All ASCII characters are represented by single-byte 7-bit values in DEC Kanji. That is, the most significant bit (MSB) is always set off in the byte that represents an ASCII character. The Roman letters and the Katakana characters specified by JIS X0201 are also single-byte val- ues in which the most significant bit (MSB) is set off and on, respectively. The code table for JIS X0208 characters is divided into 94 rows, numbered from 1 to 94. Each row has 94 columns, also numbered from 1 to 94. JIS X0208 defines a total of 6877 characters which include: Special symbols, in rows 1 and 2 Numerals and Roman letters, in row 3 Hira- gana characters, in row 4 Katakana characters, in row 5 Greek letters, in row 6 Russian letters, in row 7 Symbols for drawing graphs, dia- grams, and lines, in row 8 First level Kanji characters, in rows 16 to 47 Second level Kanji characters, in rows 48 to 84 To comply with the JIS X0208 standard, each JIS X0208 character is a two-byte value in the DEC Kanji codeset. The MSB of both the first and second bytes is always set on to distinguish JIS X0208 characters from ASCII/JIS Roman or user-defined characters. For each JIS X0208 character, The first byte of the two-byte value determines the row number and the second determines the column number in the JIS X0208 code table. The following formula shows the code value for a JIS X0208 character in relation to its row and column numbers: 1st byte = A0 + Row number 2nd byte = A0 + Column number For example, if a character is positioned at the first column of the 36th row, its code value is C4A1, which is calculated as follows: 1st byte = A0 (hex) + 36 = C4 (hex) 2nd byte = A0 (hex) + 01 = A1 (hex) For user-defined character (UDC) definitions, DEC Kanji provides an area of 2914 positions (from row 1 to row 31). Each UDC is represented by a two-byte value, just like a JIS X0208 character value. However, the MSB of the second byte of a UDC is set off to distinguish it from a JIS X0208 character. The code range of the UDC area is A121 to BF7E. The following formula calculates the code of a UDC in relation to its row and column numbers: 1st byte = A0 + Row number 2nd byte = 20 + Column number For example, if a UDC is positioned at the first column of the 16th row, its code value is B021, which is calculated as follows: 1st byte = A0 (hex) + 16 = B0 (hex) 2nd byte = 20 (hex) + 01 = 21 (hex) Codeset Conversion The following codeset converter pairs are available for converting Japanese characters between deckanji and other encoding formats. Refer to iconv_intro(5) for an introduction to codeset conversion. For more information about the other codeset for which deckanji is the input or output, see the reference page specified in the list item. eucJP_deckanji, deckanji_eucJP Converting from and to Japanese Extended UNIX Code: eucJP(5). iso-2022-jp_deckanji, deckanji_iso-2022-jp Converting from and to the ISO 2022-JP codeset: iso2022jp(5). iso-2022-jpext_deckanji, deckanji_iso-2022-jpext Converting from and to the ISO 2022-JPexp codeset: iso2022jp(5). JIS7_deckanji, deckanji_JIS7 Converting from and to the JIS7 codeset: jiskanji(5). sdeckanji_deckanji, deckanji_sdeckanji Converting from and to the Super DEC Kanji codeset: sdeckanji(5). SJIS_deckanji, deckanji_SJIS Converting from and to the Shift JIS codeset: shiftjis(5). Note that Shift JIS encoding is equivalent to the Microsoft code-page format used on PCs for Japanese. Therefore, you can use these converters to convert data between DEC Kanji and PC code-page format. For information on PC code pages, see code_page(5) UCS-2_deck- anji, deckanji_UCS-2 Converting from and to UCS-2 format: Unicode(5). UCS-4_deckanji, deckanji_UCS-4 Converting from and to UCS-4 format: Unicode(5). UTF-8_deckanji, deckanji_UTF-8 Converting from and to UTF--8 format: Unicode(5). Japanese Fonts The operating system provides the following Japanese bitmap fonts in various sizes and typefaces for 75dpi and 100dpi (dot-per-inch) dis- play devices: JIS X0201-1976 characters (Gothic family): -jdecw-gothic-medium-r-normal--8-80-75-75-m-40-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--14-140-75-75-m-70-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--12-120-75-75-m-60-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--24-240-75-75-m-120-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--10-100-75-75-m-50-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--18-180-75-75-m-90-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--17-120-100-100-m-85-jisx0201.1976-0 -jdecw-gothic-medium-r-nor- mal--34-240-100-100-m-170-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--14-100-100-100-m-70-jisx0201.1976-0 -jdecw-gothic-medium-r- normal--25-180-100-100-m-125-jisx0201.1976-0 -jdecw-gothic-medium-r-normal--20-140-100-100-m-100-jisx0201.1976-0 -jdecw-gothic- medium-r-normal--11-80-100-100-m-55-jisx0201.1976-0 JIS X0201-1976 characters (Kmenu family) -jdecw-kmenu-medium-r-normal--12-120-75-75-p-70-jisx0201.1976-0 -jdecw-kmenu-medium-r-normal--17-120-100-100-p-85-jisx0201.1976-0 JIS X0201-1976 characters (Mincho family) -jdecw-mincho-medium-r-normal--8-80-75-75-m-40-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--14-140-75-75-m-70-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--24-240-75-75-m-120-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--10-100-75-75-m-50-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--18-180-75-75-m-90-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--17-120-100-100-m-85-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--34-240-100-100-m-170-jisx0201.1976-0 -jdecw-mincho-medium-r-nor- mal--14-100-100-100-m-70-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--25-180-100-100-m-125-jisx0201.1976-0 -jdecw-mincho-medium-r- normal--20-140-100-100-m-100-jisx0201.1976-0 -jdecw-mincho-medium-r-normal--11-80-100-100-m-55-jisx0201.1976-0 JIS X0201-1976 char- acters (Screen family) -jdecw-screen-medium-r-normal--24-240-75-75-m-120-jisx0201-romankana -jdecw-screen-medium-r-nor- mal--18-180-75-75-m-80-jisx0201-romankana -jdecw-screen-medium-r-normal--14-140-75-75-m-70-jisx0201-romankana -jdecw-screen-medium- r-normal--10-100-75-75-m-50-jisx0201-romankana JIS X0208 characters (Gothic family) -jdecw-gothic-medium-r-normal--14-140-75-75-m-140-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--12-120-75-75-m-120-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--24-240-75-75-m-240-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--10-100-75-75-m-100-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--18-180-75-75-m-180-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--8-80-75-75-m-80-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--17-120-100-100-m-170-jisx0208.1983-1 -jdecw-gothic-medium-r-nor- mal--34-240-100-100-m-340-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--14-100-100-100-m-140-jisx0208.1983-1 -jdecw-gothic-medium- r-normal--25-180-100-100-m-250-jisx0208.1983-1 -jdecw-gothic-medium-r-normal--20-140-100-100-m-200-jisx0208.1983-1 -jdecw-gothic- medium-r-normal--11-80-100-100-m-110-jisx0208.1983-1 JIS X0208 characters (Mincho family) -jdecw-mincho-medium-r-normal--14-140-75-75-m-140-jisx0208.1983-1 jdecw-mincho-medium-r-normal--12-120-75-75-m-120-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--24-240-75-75-m-240-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--10-100-75-75-m-100-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--18-180-75-75-m-180-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--8-80-75-75-m-80-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--17-120-100-100-m-170-jisx0208.1983-1 -jdecw-mincho-medium-r-nor- mal--34-240-100-100-m-340-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--14-100-100-100-m-140-jisx0208.1983-1 -jdecw-mincho-medium- r-normal--25-180-100-100-m-250-jisx0208.1983-1 -jdecw-mincho-medium-r-normal--20-140-100-100-m-200-jisx0208.1983-1 -jdecw-mincho- medium-r-normal--11-80-100-100-m-110-jisx0208.1983-1 JIS X0208 characters (Screen family) -jdecw-screen-medium-r-normal--24-240-75-75-m-240-jisx0208-kanji00 -jdecw-screen-medium-r-nor- mal--10-100-75-75-m-100-jisx0208-kanji00 -jdecw-screen-medium-r-normal--18-180-75-75-m-160-jisx0208-kanji00 -jdecw-screen-medium-r- normal--16-160-75-75-m-160-jisx0208-kanji00 -jdecw-screen-medium-r-normal--14-140-75-75-m-140-jisx0208-kanji00 -jdecw-screen-medium- r-normal--24-240-75-75-m-240-jisx0208-kanji11 -jdecw-screen-medium-r-normal--10-100-75-75-m-100-jisx0208-kanji11 -jdecw-screen- medium-r-normal--18-180-75-75-m-160-jisx0208-kanji11 -jdecw-screen-medium-r-normal--14-140-75-75-m-140-jisx0208-kanji11 For printers, the operating system provides only Japanese fonts that are printer-resident; that is, there are no Japanese fonts that can be dynamically down-loaded to the printer. Refer to i18n_printing(5) for general information on printing non-English text. SEE ALSO
Commands: locale(1) Others: ascii(5), code_page(5), eucJP(5), i18n_intro(5), i18n_printing(5), iconv_intro(5), iso2022jp(5), Japanese(5), jiskanji(5), sdeck- anji(5), shiftjis(5), Unicode(5) deckanji(5)
All times are GMT -4. The time now is 11:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy