Sponsored Content
Full Discussion: count commas in a script
Operating Systems HP-UX count commas in a script Post 88488 by obedkhan on Friday 4th of November 2005 07:55:36 PM
Old 11-04-2005
count commas in a script

I've a text file which is delimeted by a comma. But there are some commas in side a quoted string. For ex:

My file a1.txt contains:
"ab,bef",a,b,1,2,"abcde",0,

If you look at the above line, the shell script should give me a count of commas which is 7 according to the above example. (Shell script should ignore any commas inside double quotes). Can anybody help me writing a script to achieve this.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

how to handle , in data where separator also commas in awk script

TEST_HEME,"SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1",CELL when I split by FS="," then $0=TEST_HEME $1="SubNetwork=ONRM_RootMoR $2=SubNetwork=ARNC1" but I need this will be single value "SubNetwork=ONRM_RootMoR,SubNetwork=ARNC1" (4 Replies)
Discussion started by: Hemendra
4 Replies

4. Shell Programming and Scripting

how to find the count of commas in a string excluding the ones in double quotes

Hi, my requirement is to find the count of commas in a string excluding the ones in double quotes. For example: If the input string is abc,xyz.com,lmhgdf,"abc, 401 street","tty,stt",45,23,45 The output should be 7 (7 Replies)
Discussion started by: amitshete
7 Replies

5. Shell Programming and Scripting

shell script to remove extra commas from CSV outp file

Name,,,,,,,,,,,,,,,,,,,,Domain,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Contact,Phone,Email,,,,,,,,,,,,,,,,,,,,,,,,,,,,,Location -----------------------,------------------------------------------------,-------,-----,---------------------------------,------------------------------------ ----... (1 Reply)
Discussion started by: sreenath1037
1 Replies

6. 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

7. 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

8. Shell Programming and Scripting

Shell script that should remove unnecessary commas between double quotes in CSV file

i have data as below 123,"paul phiri",paul@yahoo.com,"po.box 23, BT","Eco Bank,Blantyre,Malawi" i need an output to be 123,"paul phiri",paul@yahoo.com,"po.box 23 BT","Eco Bank Blantyre Malawi" (5 Replies)
Discussion started by: mathias23
5 Replies

9. UNIX for Beginners Questions & Answers

Insert commas

Original content: ACACCTCAT 129 | ACACCTCAT 0 ACACCTCATX 171 | ACACCTCATX 0 ACACRESRT 0 ACACRESRT 0 ACACRESRTX 0 ... (4 Replies)
Discussion started by: loktamann
4 Replies

10. Shell Programming and Scripting

Is there a way to handle commas inside the data when generating a csv file from shell script?

I am extracting data via sql query and some of the data has commas. Output File must be csv and I cannot update the data in the db (as it is used by other application). Example table FavoriteThings Person VARCHAR2(25), Favorite VARCHAR2(100) Sample Data Greta rain drop on... (12 Replies)
Discussion started by: patk625
12 Replies
XBaseFontNameListOfFontSet(3X)					  XLIB FUNCTIONS				    XBaseFontNameListOfFontSet(3X)

NAME
XBaseFontNameListOfFontSet - obtain font set information SYNTAX
char *XBaseFontNameListOfFontSet(font_set) XFontSet font_set; ARGUMENTS
font_set Specifies the font set. DESCRIPTION
The XBaseFontNameListOfFontSet function returns the original base font name list supplied by the client when the XFontSet was created. A null-terminated string containing a list of comma-separated font names is returned as the value of the function. White space may appear immediately on either side of separating commas. If XCreateFontSet obtained an XLFD name from the font properties for the font specified by a non-XLFD base name, the XBaseFontNameListOf- FontSet function will return the XLFD name instead of the non-XLFD base name. The base font name list is owned by Xlib and should not be modified or freed by the client. It will be freed by a call to XFreeFontSet with the associated XFontSet. Until freed, its contents will not be modified by Xlib. SEE ALSO
XCreateOC(3X), XExtentsOfFontSet(3X), XFontSetExtents(3X), XFontsOfFontSet(3X), XLocaleOfFontSet(3X), XContextDependentDrawing(3X), XCon- textualDrawing(3X), XDirectionalDependentDrawing(3X) X Version 11 Release 6 XBaseFontNameListOfFontSet(3X)
All times are GMT -4. The time now is 07:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy