Text Convert


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Text Convert
# 1  
Old 04-15-2012
Text Convert

Hello,

I have a text file(utf8-bom). I want convert to following format. Thank you.

Code:
1***hello 35345
29***hello test6
380***bill33
4327***hello test6
47829***hull55
65644***hello test6

I want this format.

Code:
1***hello 35345
29***hello test6
380***bill33
4327***hello test6 2
47829***hull55
65644***hello test6 3


Last edited by kata33; 04-15-2012 at 06:40 AM..
# 2  
Old 04-15-2012
Try:
Code:
awk -F'[*]{3}' 'A[$2]++{$0=$0 OFS A[$2]}1' infile

# 3  
Old 04-15-2012
Hello,

Thanks but output:
Code:
1***hello 35345
29***hello test6
 2
380***bill33
 3
4327***hello test6
 4
47829***hull55
 5
65644***hello test6 6

# 4  
Old 04-15-2012
Could you post this output?
Code:
od -c infile

What OS/version are you working on?
# 5  
Old 04-15-2012
Hello,

OS: Centos 5.8
I want add a number only "same words" not all words.

Output:

Code:
0000000   1   *   *   *   h   e   l   l   o       3   5   3   4   5  \n
0000020   2   9   *   *   *   h   e   l   l   o       t   e   s   t   6
0000040  \n   3   8   0   *   *   *   b   i   l   l   3   3  \n   4   3
0000060   2   7   *   *   *   h   e   l   l   o       t   e   s   t   6
0000100  \n   4   7   8   2   9   *   *   *   h   u   l   l   5   5  \n
0000120   6   5   6   4   4   *   *   *   h   e   l   l   o       t   e
0000140   s   t   6
0000143

# 6  
Old 04-15-2012
Try:
Code:
awk --posix -F'[*]{3}' 'A[$2]++{$0=$0 OFS A[$2]}1' infile

I still don't get how the counter ended up on the next line, could that be due to the way it was cut-and-pasted?
# 7  
Old 04-15-2012
Thanks its works Smilie


I dont know I think this text file needed dos2unix.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert text to columns

Hi. I need an input file of a single word pr. line converted in into a list of random pairs. i need input like this word1 word2 word3 word4 to be outputted like this: word3 word1 word2 word4 My attempt is a tedious while loop like this: nfiles=$(cat inputfile | wc -l) ... (4 Replies)
Discussion started by: BotHead
4 Replies

2. Shell Programming and Scripting

Convert text to csv

Hi, Is there somebody there to post an idea on how to convert this 5 liner row to 1 liner or tab delimiter to be import to database. Here the text file format: Description: Description1 Link: https://www.google.com Date: June 2, 2018 Time: 00:07:44 Age: 1 days ago Description:... (2 Replies)
Discussion started by: lxdorney
2 Replies

3. Shell Programming and Scripting

How to convert Text data to xls?

Hi Team, I have created a script to output DB Query data to a text file. It displays output as follows for 2 different queries appended to same file. I want help to convert this data to xls format so that the output of first query is in 1 tab and the other in second tab. Please help. ... (14 Replies)
Discussion started by: srkmish
14 Replies

4. Shell Programming and Scripting

Convert text to CSV

Hi Gurus I need urgent help to convert a flat log file into csv format to load into database. Log looks like: a=1 b=2 c=3 a=4 b=5 c=6 Only the values at right side of = will come into csv and it should create a new line once it receives "a" field. (8 Replies)
Discussion started by: sandipjee
8 Replies

5. Shell Programming and Scripting

Text Convert

Hello, I have a text file(utf8-bom). I want convert to following format. Thank you. 1***hello 35345 test test666 test 77 ? - test666 6//77 2***ktest 765 3***john6666 net 565433 nebb I want this format. 1***hello 35345 test test666 test 77 ? - test666 6//77 2***ktest 765... (4 Replies)
Discussion started by: kata33
4 Replies

6. UNIX for Dummies Questions & Answers

How to convert text to columns in tab delimited text file

Hello Gurus, I have a text file containing nearly 12,000 tab delimited characters with 4000 rows. If the file size is small, excel can convert the text into coloumns. However, the file that I have is very big. Can some body help me in solving this problem? The input file example, ... (6 Replies)
Discussion started by: Unilearn
6 Replies

7. Programming

convert text file to csv

hi all, i have a select query that gives me the output in the following way... SYSTYPE -------------------------------------------------------------------------------- Success Failures Total RFT ---------- ---------- ---------- ---------- TYP 1 0 ... (3 Replies)
Discussion started by: sais
3 Replies

8. Shell Programming and Scripting

convert Text to Excel

I have some text data generated by a perl script and want to put it into an excel sheet. Is there a perl script that can do this for me, i.e, convert text data to excel? (1 Reply)
Discussion started by: Pavankk
1 Replies

9. Shell Programming and Scripting

Convert text to numerical

Hi folks, I am trying to convert one character to a numeric format, for example : " 1" to number 1 :cool: Ups forgot to tell you .. !!! I am trying to do it with kornshell !!! ;) (4 Replies)
Discussion started by: nzq71k
4 Replies

10. UNIX for Dummies Questions & Answers

How do I convert unix text to to win text?

How do I convert unix text files into readable text for windows. Dave (1 Reply)
Discussion started by: nucca
1 Replies
Login or Register to Ask a Question