Sponsored Content
Full Discussion: Insert commas
Top Forums UNIX for Beginners Questions & Answers Insert commas Post 302983245 by disedorgue on Saturday 8th of October 2016 05:11:01 PM
Old 10-08-2016
Hi,
with gnu sed:
Code:
$ cat /tmp/f2.txt 
ACACCTCAT    129                                              | ACACCTCAT    0
ACACCTCATX   171                                              | ACACCTCATX   0
ACACRESRT    0                                                  ACACRESRT    0
ACACRESRTX   0                                                  ACACRESRTX   0
ACACTCOPY    0                                                  ACACTCOPY    0
ACACTGRP     12                                               | ACACTGRP     0
ACACTIVITY   82                                               | ACACTGRPAU   0
ACACTMXVAL   145                                              | ACACTIVITY   0
                                                              > ACACTMXVAL   0
ACACTMXVDT   0                                                  ACACTMXVDT   0
ACACTREL     0                                                  ACACTREL     0
ACACTSEG     0                                                  ACACTSEG     0
ACADDASSGN   0                                                  ACADDASSGN   0
ACADDLCNTR   4                                                | ACADDLCNTR   0
UKCOTABLE    648                                              <
UKNICAT      37                                               <

Code:
$ sed -e ':bc;/.\{79\}/!s/$/ /;tbc;s/./&,/13;s/./&,/63;s/./&,/79' /tmp/f2.txt 
ACACCTCAT    ,129                                              ,| ACACCTCAT    ,0 
ACACCTCATX   ,171                                              ,| ACACCTCATX   ,0 
ACACRESRT    ,0                                                ,  ACACRESRT    ,0 
ACACRESRTX   ,0                                                ,  ACACRESRTX   ,0 
ACACTCOPY    ,0                                                ,  ACACTCOPY    ,0 
ACACTGRP     ,12                                               ,| ACACTGRP     ,0 
ACACTIVITY   ,82                                               ,| ACACTGRPAU   ,0 
ACACTMXVAL   ,145                                              ,| ACACTIVITY   ,0 
             ,                                                 ,> ACACTMXVAL   ,0 
ACACTMXVDT   ,0                                                ,  ACACTMXVDT   ,0 
ACACTREL     ,0                                                ,  ACACTREL     ,0 
ACACTSEG     ,0                                                ,  ACACTSEG     ,0 
ACADDASSGN   ,0                                                ,  ACADDASSGN   ,0 
ACADDLCNTR   ,4                                                ,| ACADDLCNTR   ,0 
UKCOTABLE    ,648                                              ,<              ,  
UKNICAT      ,37                                               ,<              ,

Regards.
This User Gave Thanks to disedorgue For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I insert commas/delimiters in File

Hi, Newbie here. Need to convert a txt file to .csv format. There's no character to replace so not sure if I can use sed :confused: . The comma is to be inserted after every certain number of characters in each line... Help! Thanks. (4 Replies)
Discussion started by: mbelen
4 Replies

2. Shell Programming and Scripting

formatted output with commas

var=12345 echo $var >>>12345 printf "%8.1f \n" $var >>> 12345.0 How to get this as 12,345? I suppose I could break into sections by dividing by 1000 or 1000000. But, is the a trick to this? (4 Replies)
Discussion started by: joeyg
4 Replies

3. Shell Programming and Scripting

substitute commas with pipe

Hi All, I have a file that contain value below: test,mno,mno, +asc mno,lok,msyu,tts test,poi,test,0,90, 3,00 i need to substitute the comma's into pipe where i... (2 Replies)
Discussion started by: selamba_warrior
2 Replies

4. UNIX for Dummies Questions & Answers

Inserting commas and replacing backslashes with commas

Hi, Newbie here. I have a file that consists of data that I want to convert to a csv file. For example: Jul 20 2008 1111 / visit home / BlackBerry8830/4.2.2 Profile/MIDP-2.0 Configuration/CLOC-1.1 VendorID/105 Jul 21 2008 22222 / add friend / BlackBerry8830/4.2.2 Profile/MIDP-2.0... (3 Replies)
Discussion started by: kangaroo
3 Replies

5. Shell Programming and Scripting

Need help in removing commas

i have the below line as output from a script. I want to delete the string "," and get the output without comma, cat D* | grep "bytes free" | awk '{print $3}' | ????? output: 40,966,189,056 Desired O/P: 40966189056 (1 Reply)
Discussion started by: ali560045
1 Replies

6. UNIX for Dummies Questions & Answers

Insert Commas at fixed positions

Hi I have a text file which is position delimited, i.e. Code1 Description1 Value1 Code2 Description2 Value2 etc. I want to import this file into MySQL so I want to convert the file into Comma delimited format. To do this I want to insert commas at fixed positions on... (7 Replies)
Discussion started by: arossco
7 Replies

7. Shell Programming and Scripting

Commas within Delimeters

Hi experts, I would like a favour from you guys to get the info from 5th column which was separated by the delimeter comma ( , ) The Data file is as below:- 1,USER1,"90, TEST AVENUE, OLD ROAD",test1,124,N 2,USER2,88 TEST STREET NEW ROAD,test2,123,N The User File is as below:- USER1... (1 Reply)
Discussion started by: shenkz
1 Replies

8. Shell Programming and Scripting

Replace field with commas with field without commas

Hey guys, I have the following text: 1,2,3,4,5,6,'NULL','when',NULL,1,2,0,'NULL' 1,2,3,4,5,6,'NULL','what','NULL',1,2,0,1 I need the same text with the word NULL without commas u know something like this: 1,2,3,4,5,6,NULL,'when',NULL,1,2,0,NULL 1,2,3,4,5,6,NULL,'what','NULL',1,2,0,1 ... (1 Reply)
Discussion started by: lmyk72
1 Replies

9. Shell Programming and Scripting

Insert Inverted Commas Around Numeric Values

Hi, I am trying to insert Inverted Commas around all the numeric values within a comma seperated string / variable. 1111,2222,3333,4444 I would like it to be: '1111','2222','3333','4444' Note - This string could have a differing amount of numeric values each time the variable is... (4 Replies)
Discussion started by: RichZR
4 Replies

10. UNIX for Dummies Questions & Answers

Insert single quote and commas

Hi All, I have a set of data as below : XS012371378 Raj 23-09-12 SH128238948 Andrew 24-08-12 CH273712399 Walsh 12-10-12 JK7249923893 Nick 10-02-13 JP6383791389 Braslin 30-12-13 I want the first column to be extracted separately. I can get this using awk. awk '{print $1}' file_name ... (3 Replies)
Discussion started by: Nand Kishor
3 Replies
Locale::Codes::LangExt(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangExt(3pm)

NAME
Locale::Codes::LangExt - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangExt; $lext = code2langext('acm'); # $lext gets 'Mesopotamian Arabic' $code = langext2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langext_codes(); @names = all_langext_names(); DESCRIPTION
The "Locale::Codes::LangExt" module provides access to standard codes used for identifying language extensions, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language extensions. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langext('acm','alpha'); $lext = code2langext('acm',LOCALE_LANGEXT_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from the IANA language registry, such as 'acm' for Mesopotamian Arabic. This is the default code set. ROUTINES
code2langext ( CODE [,CODESET] ) langext2code ( NAME [,CODESET] ) langext_code2code ( CODE ,CODESET ,CODESET2 ) all_langext_codes ( [CODESET] ) all_langext_names ( [CODESET] ) Locale::Codes::LangExt::rename_langext ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangExt::add_langext ( CODE ,NAME [,CODESET] ) Locale::Codes::LangExt::delete_langext ( CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_alias ( NAME ,NEW_NAME ) Locale::Codes::LangExt::delete_langext_alias ( NAME ) Locale::Codes::LangExt::rename_langext_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::add_langext_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangExt::delete_langext_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangExt(3pm)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy