Sponsored Content
Top Forums Shell Programming and Scripting Pull Data After Comma if 2 word before comma Post 302399546 by msalam65 on Sunday 28th of February 2010 09:46:17 PM
Old 02-28-2010
Pull Data After Comma if 2 word before comma

Hi,

I am trying to truncate word after comma in a file ONLY if there are already 2 words BEFORE comma. If there is one word or 3 or more words BEFORE comma, then I have to leave the data AS IS. See below for example.

Code:
 
Input File :
 
John Smith, Manager
Smith, John Frank
J F K Peterson, Home
John, Smith
 
Output File :
 
John Smith
Smith, John Frank
J F K Peterson, Home
John, Smith
 
I have the following code so far but it is not doing what I am looking for.
 
cat input.dat | awk 'BEGIN{FS=","}{print $1 " " $2 ","}END { }' | tr -s "," " " >output.dat


Please advise.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need to get the last word in comma sep line

I have a file with aaa,bbb,ccc,dddd,eee,xyz aaa,bbb,ccc,dddd,eee,xyz,12345,rty aaa,bbb,ccc,dddd,eee,xyz,12345,rty,tsrt 1. line columns are not fixed 2. all words are seperated by comma what i want is always the string after last comma. regards, Senthil... (9 Replies)
Discussion started by: senthilk615
9 Replies

2. Shell Programming and Scripting

count data separate by comma

hi experts, i have some problem with count data which separate by comma, below sample data : 01,011222823b6d,011222823f29,0028a5,002993,6212345678, 659111111111,6598204507,6281105008,6596197849,_,525016160836958,_, ffffffff,000000000000000000000000,_,_,_,fd,fd,ff,00,1,0028a5-002993,_,... (10 Replies)
Discussion started by: bucci
10 Replies

3. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

4. Shell Programming and Scripting

Append the text file with comma at the end of every word

Hi folks, Using shell, I am trying the append comma to every line of text. the requirement is like, I have to open the txt file in unix and read line by line and should add comma at the end of every word to make it single line txt file ------- abc@gmail.com bcd@gmail.com... (7 Replies)
Discussion started by: giridhar276
7 Replies

5. Shell Programming and Scripting

How to grep after the first comma till the next comma in a line

Hi Can any one pls tell me how to grep this line POPULATION,69691,20120509 I want the number 69691 from the above line. How to grep from the first comma till the next comma. Thank You.:confused: (8 Replies)
Discussion started by: rxg
8 Replies

6. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

7. Shell Programming and Scripting

Replace comma and blank with comma and number

I, I have a file and i need to replace comma and blank space with comma and 0. cat file.txt a,5 b,1 c, d, e,4 I need the output as cat file.txt a,5 b,1 c,0 d,0 (4 Replies)
Discussion started by: jaituteja
4 Replies

8. Shell Programming and Scripting

Insert single quote on every word separated by comma

Hello, I have a text file as:-ABC BCD CDF DEF EFGI need to convert as 'ABC', 'BCD', 'CDF', 'DEF', 'EFG' using a unix command anybody can help me out on this. Regards, Jas Please wrap all code, files, input & output/errors in CODE tags. It makes them easier to read and preserves... (12 Replies)
Discussion started by: jassi10781
12 Replies

9. Shell Programming and Scripting

Replace spaces with underscores up to first comma but not after the comma

I have a comma delimited file of major codes and descriptions. I want to replace all occurrences of spaces with underscores up to the first comma (only in the first field), but not replace spaces following the comma. For instance I have the following snippet of the file: EK ED,Elementary and... (7 Replies)
Discussion started by: tdouty
7 Replies

10. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies
cs00toatok(1)							   User Commands						     cs00toatok(1)

NAME
cs00toatok - conversion cs00 user dictionary to ATOK user dictionary SYNOPSIS
cs00toatok [filename...] AVAILABILITY
SUNWjfpu DESCRIPTION
cs00toatok is a filter that converts cs00 word-list-file to ATOK word-list-file. cs00toatok is used for the purpose of using cs00 user words on ATOK12 as well as on cs00. cs00toatok reads file(s) specified by filename(s). If no filenames are given, cs00toatok reads a file from the standard input. The con- tents of the files must be the format of cs00 word-list-file. cs00toatok writes ATOK word-list-file to the standard output. cs00toatok con- verts each word according to the following rules. Kana reading (Phonetic), Kanji word Does not change any character and the length of Kana reading and Kanji word of each source word. Part-of-speech (Hinshi) Converts Hinshi of source word according to the table shown below. +--------------------------------------------------------------------------------------------------------+ |Part-of-speech in cs00 Part-of-speech in ATOK | | |:N1 noun1 | 01 common noun | |:N2 noun2 | 01 common noun | |:M1 person's name1 | 02 proper noun | |:M2 person's name2 | 02 proper noun | |:T1 place name1 | 02 proper noun | |:T2 place name2 | 02 proper noun | |:NM numeral | 13 numeral | |:NN supplemental numeral | 12 suffix | |:PR prefix | 11 prefix | |:SF suffix | 12 suffix | |:AD adverb | 29 adverb | |:CN conjunction | 09 conjunction | |:RT participial adjective | 08 participial adjective | |:AJ adjective | 27 adjective | |:AV adjective verb | 28 adjective verb | |:SH S-series irregular conjugation verb | 03 noun form of S-series irregu- | | | lar conjugation verb | |:ZH Z-series irregular conjugation verb | 04 noun form of Z-series irregu- | | | lar conjugation verb | |:1V single conjugation verb | 23 single conjugation verb | |:KV K-series five conjugation verb | 14 K-series five conjugation verb | |:GV G-series five conjugation verb | 15 G-series five conjugation verb | |:SV S-series five conjugation verb | 16 S-series five conjugation verb | |:TV T-series five conjugation verb | 17 T-series five conjugation verb | |:NV N-series five conjugation verb | 18 N-series five conjugation verb | |:BV B-series five conjugation verb | 19 B-series five conjugation verb | |:MV M-series five conjugation verb | 20 M-series five conjugation verb | |:RV R-series five conjugation verb | 21 R-series five conjugation verb | |:WV W-series five conjugation verb | 22 W-series five conjugation verb | |:UN no classification | - - | |:TK single kanji | 07 single kanji | |:BS clause | - - | +-------------------------------------------------------------+------------------------------------------+ Words with the part of speech "no classification" (:UN) or "clause" (:BS) need -a option to be put out. Also, a source word with multiple parts of speech is converted to plural words, each of which has the each part of speech. OPTIONS
-a Put out words whose part of speech are "no classification" or "clause" as words whose parts of speech are unknown, in addition to words put out by default. NOTES
cs00toatok does not change Kana reading and Kanji word of any word. Therefore, note below. o A word may not be registered to ATOK user dictionary with the characters or the length of kana reading and kanji word of the word. o If the edge of a word is `'' (Zenkaku single quote) or `"' (Zenkaku double quote), a new word stripped the edge of characters from the word is registered. o If Kanji word of a word contains `,' (Zenkaku comma), the word cannot be registered to ATOK user dictionary. Use ATOK12 dictionary utility to register a word-list-file to ATOK dictionary. For detail, refer to ATOK12 User's Guide. SEE ALSO
atok12(1), atok8wordlist(4) SunOS 5.10 10 Jan 2003 cs00toatok(1)
All times are GMT -4. The time now is 02:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy