Sponsored Content
Top Forums Shell Programming and Scripting concatenate 'n' number of columns in a file Post 302460416 by mlpathir on Wednesday 6th of October 2010 06:44:08 PM
Old 10-06-2010
concatenate 'n' number of columns in a file

i have a file which may have 'n' number of columns

1 222 fafda 32 afdaf 4343 4343
234 43fdaf 4343 fdd fdfd fdfd fdd fdfd fdfd
fdfd fdfd fdfd fdd fdfd fdfd

need to concatenate the columns with space separator using shell script

output should look like

1 222 fafda 32 afdaf 4343 4343
234 43fdaf 4343 fdd fdfd fdfd fdd fdfd fdfd
fdfd fdfd fdfd fdd fdfd fdfd

Last edited by mlpathir; 10-06-2010 at 08:36 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find number of columns in a file

Hi all, may seem a very stupid question.but me stuck up in it for long.... How to find the number of columns in a ASCII file. EX:-Demo.lst songs 1 34 45 67 Number of columns should be 5. Regards, Anindya ;) (13 Replies)
Discussion started by: rahul26
13 Replies

2. Shell Programming and Scripting

Print columns in a file by number list in another file

This should follow with my last post but I think it's better to start a new one. Now I have a list of numbers stored in pos.txt: 2 6 7 . . . n . . . And I need to extract (2n-1, 2n) columns from matrix.txt: ind1 A B C D E F G H I J K L M N O P Q R ... ind2 B C D E F G H... (3 Replies)
Discussion started by: Zoho
3 Replies

3. Shell Programming and Scripting

Concatenate columns from files

Hi, I have a file1.txt like this: and a file2.txt like this: I wat only append file2.txt to file1.txt and to have something like this: How could i do ? (2 Replies)
Discussion started by: AdminLew
2 Replies

4. Shell Programming and Scripting

Concatenate columns from multiple files

Hi all, I want the 2nd column of every file in the directory in a single file with the file name as column header. $cat file1.txt a b c d e f $cat file2.txt f g h g h j $cat file3.txt a b d f g h (2 Replies)
Discussion started by: newbie83
2 Replies

5. UNIX for Dummies Questions & Answers

Concatenate two columns and separate by - (minus)

hi all could you please help me to concatenate two colomns and separate them by "-" the two colomns to concatenate are colomuns 1 and 3 of a very bif file clomn 1 is chr, 2 is snp and 3 is bp the new colomn is chr_B input file : 1 rs1111 10583 1 rs1891 10611 1 rs1807 ... (13 Replies)
Discussion started by: biopsy
13 Replies

6. AIX

How to find number of columns in xml file?

How to find the number of columns in xml file. i tried following command. Code: #!bin/ksh cat $1 | grep -c "</mdm:attribute>"exit 0but i am not getting accurate result which is not matching with the manual count. data format : Code: <mdm:attribute> value </mdm:attribute> No... (1 Reply)
Discussion started by: victory
1 Replies

7. Shell Programming and Scripting

Number of columns in xml file

How to find the number of columns in xml file. i tried following command. #!bin/ksh cat $1 | grep -c "</mdm:attribute>" exit 0 but i am not getting accurate result which is not matching with the manual count. data format : <mdm:attribute> value </mdm:attribute> (6 Replies)
Discussion started by: victory
6 Replies

8. Shell Programming and Scripting

Grouping multiple columns and concatenate

I have a CSV file that goes like this: Name,Group,Email Max,Group1,max@.com Dan,Group2,dan@.com Max,Group3,max@.com Max,Group4,max@.com Dan,Group5,dan@.com Jim,Group6,jim@.comBasically my desired output should be: Name,Group,Email Max,Group1|Group3|Group4,max@.com... (6 Replies)
Discussion started by: jeffreybsu
6 Replies

9. Shell Programming and Scripting

How to concatenate 2-columns by 2 -columns for a text file?

Hello, I want to concatenate 2-columns by 2-columns separated by colon. How can I do so? For example, I have a text file containing 6 columns separated by tab. I want to concatenate column 1 and 2; column 3 and 4; column 5 and 6, respectively, and put a colon in between. input file: 1 0 0 1... (10 Replies)
Discussion started by: huiyee1
10 Replies

10. Shell Programming and Scripting

Concatenate two columns in a file

Hi i am having one requirement like to concatenate two columns in to one columns, can any one help on this please sample scenario i am placing below COL1,COL2,COL3,COL4 1,A,B,C,D 2,e,f,g,h ouput should be 3 columns like below. COL1,COL2,newcolumns 1,A,B,CD 2,e,f,gh ... (9 Replies)
Discussion started by: bhaskar v
9 Replies
localeconv(3C)															    localeconv(3C)

NAME
localeconv() - query the numeric formatting conventions of the current locale SYNOPSIS
DESCRIPTION
The function sets the components of an object of type (defined in with values appropriate for the formatting of numeric quantities (mone- tary and otherwise) according to the rules of the program's current locale (see setlocale(3C)). The members of the structure with type are strings, any of which (except can point to "" (the empty string) to indicate that the value is not available in the current locale or is of zero length. The members with type are non-negative numbers, any of which can be (defined in to indicate that the value is not available in the current locale. The members include the following: The decimal point character used to format nonmonetary quantities. This is the same value as that returned by a call to with as its argument (see nl_langinfo(3C)). The character used to separate groups of digits to the left of the decimal point character in formatted nonmonetary quantities. This is the same value as that returned by a call to with as its argument (see nl_langinfo(3C)). A string where the numeric value of each byte indicates the size of each group of digits in formatted nonmonetary quantities. The international currency symbol applicable to the current locale. The first three characters contain the alphabetic international currency symbol in accordance with those specified in The fourth character (immediately preceding the null character) is the character used to separate the international currency symbol from the monetary quantity. The local currency symbol applicable to the current locale. This value along with positioning information is returned by a call to with as its argument (see nl_langinfo(3C)). The decimal point used to format monetary quantities. The separator for groups of digits to the left of the decimal point in formatted monetary quantities. A string where the numeric value of each byte indicates the size of each group of digits in formatted monetary quantities. The string used to indicate a positive valued formatted monetary quantity. The string used to indicate a negative valued formatted monetary quantity. The number of fractional digits (those to the right of the decimal point) to be displayed in an internationally formatted monetary quantity. The number of fractional digits (those to the right of the decimal point) to be displayed in a locally formatted monetary quantity. Set to 1 or 0 if the precedes or succeeds the value for a non-negative formatted monetary quantity. Set to a value indicating the separation of the the sign string, and the value of a non-negative formatted monetary quantity. Set to 1 or 0 if the precedes or succeeds the value for a negative formatted monetary quantity. Set to a value indicating the separation of the the sign string, and the value of a negative formatted monetary quantity. Set to a value indicating the positioning of the for a non-negative formatted monetary quantity. Set to a value indicating the positioning of the for a negative formatted monetary quantity. The following members are also available to UNIX 2003 conforming applications: Set to 1 or 0 if the precedes or succeeds the value for a non-negative internationally formatted monetary quantity. Set to a value indicating the separation of the the sign string, and the value of a non-negative internationally formatted monetary quantity. Set to 1 or 0 if the precedes or succeeds the value for a negative internationally formatted monetary quantity. Set to a value indicating the separation of the the sign string, and the value of a negative internationally formatted monetary quantity. Set to a value indicating the positioning of the for a non-negative internationally formatted monetary quantity. Set to a value indicating the positioning of the for a negative internationally formatted monetary quantity. The numeric value of each byte of and is interpreted according to the following: No further grouping is to be performed. The previous byte is to be repeatedly used for the remainder of the digits. other The value is the number of digits that comprise the current group. The next byte is examined to determine the size of the next group of digits to the left of the current group. The values of and are interpreted according to the following: No space separates the currency symbol and value. If the currency symbol and sign string are adjacent, a space separates them from the value; otherwise, a space separates the currency symbol from the value. If the currency symbol and sign string are adjacent, a space separates them; otherwise, a space separates the sign string from the value. For and the fourth character of is used instead of a space for UNIX 2003 conforming applications. The values of and are interpreted according to the following: Parentheses surround the quantity and or The sign string precedes the quantity and or The sign string succeeds the quantity and or The sign string immediately precedes the or The sign string immediately succeeds the or behaves as if no library function calls EXTERNAL INFLUENCES
Locale The category influences the and members of the structure referenced by the pointer returned from a call to The category influences all of the other members of this structure. International Code Set Support Single and multibyte character codesets are supported. RETURN VALUE
returns a pointer to the filled-in EXAMPLES
The following table illustrates the formatting used in five languages for monetary quantities. +---------------+-----------------+-----------------+----------------------+ | Country | Positive format | Negative format | International format | +---------------+-----------------+-----------------+----------------------+ |en_US.iso88591 | $1,234.56 | -$1,234.56 | USD 1,234.56 | +---------------+-----------------+-----------------+----------------------+ |it_IT.iso88591 | L.1.234 | -L.1.234 | ITL.1.234 | +---------------+-----------------+-----------------+----------------------+ |nl_NL.iso88591 | F 1.234,56 | F -1.234,56 | NLG 1.234,56 | +---------------+-----------------+-----------------+----------------------+ |no_NO.iso88591 | kr1.234,56 | kr1.234,56- | NOK 1.234,56 | +---------------+-----------------+-----------------+----------------------+ |pt_PT.iso88591 | 1,234$56 | -1,234$56 | PTE 1,234$56 | +---------------+-----------------+-----------------+----------------------+ For these five languages, the respective values for the monetary members of the structure returned by are: +------------------+----------+-----------+----------+----------+--------+ | | en_US. | it_IT. | nl_NL. | no_NO. | pt_PT. | | iso88591 | iso88591 | .iso88591 | iso88591 | iso88591 | | +------------------+----------+-----------+----------+----------+--------+ |int_curr_symbol | USD | ITL. | NLG | NOK | PTE | +------------------+----------+-----------+----------+----------+--------+ |currency_symbol | $ | L. | F | kr | $ | +------------------+----------+-----------+----------+----------+--------+ |mon_decimal_point | . | "" | , | , | $ | +------------------+----------+-----------+----------+----------+--------+ |mon_thousands_sep | , | . | . | . | , | +------------------+----------+-----------+----------+----------+--------+ |mon_grouping | 3 | 3 | 3 | 3 | 3 | +------------------+----------+-----------+----------+----------+--------+ |positive_sign | "" | "" | "" | "" | "" | +------------------+----------+-----------+----------+----------+--------+ |negative_sign | - | - | - | - | - | +------------------+----------+-----------+----------+----------+--------+ |int_frac_digits | 2 | 0 | 2 | 2 | 2 | +------------------+----------+-----------+----------+----------+--------+ |frac_digits | 2 | 0 | 2 | 2 | 2 | +------------------+----------+-----------+----------+----------+--------+ |p_cs_precedes | 1 | 1 | 1 | 1 | 0 | +------------------+----------+-----------+----------+----------+--------+ |p_sep_by_space | 0 | 0 | 1 | 0 | 0 | +------------------+----------+-----------+----------+----------+--------+ |n_cs_precedes | 1 | 1 | 1 | 1 | 0 | +------------------+----------+-----------+----------+----------+--------+ |n_sep_by_space | 0 | 0 | 1 | 0 | 0 | +------------------+----------+-----------+----------+----------+--------+ |p_sign_posn | 1 | 1 | 1 | 1 | 1 | +------------------+----------+-----------+----------+----------+--------+ |n_sign_posn | 4 | 1 | 4 | 2 | 1 | +------------------+----------+-----------+----------+----------+--------+ WARNINGS
The structure returned by should not be modified by the calling program. Calls to with categories or can overwrite the contents of the structure that points to when it returns (see setlocale(3C)). AUTHOR
was developed by OSF and HP. SEE ALSO
nl_langinfo(3C), setlocale(3C), localedef(4), langinfo(5), thread_safety(5). STANDARDS CONFORMANCE
localeconv(3C)
All times are GMT -4. The time now is 10:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy