Sponsored Content
Top Forums Shell Programming and Scripting Text columns processing using awk Post 302909481 by dovah on Thursday 17th of July 2014 08:26:05 AM
Old 07-17-2014
P { margin-bottom: 0.25cm; line-height: 120%; }CODE.cjk { font-family: "WenQuanYi Micro Hei",monospace; }CODE.ctl { font-family: "Lohit Hindi",monospace; }A:link { } P { margin-bottom: 0.25cm; line-height: 120%; }CODE.cjk { font-family: "WenQuanYi Micro Hei",monospace; }CODE.ctl { font-family: "Lohit Hindi",monospace; }A:link { }
Code:
awk '{split($2,a,",")}' file1; awk '{OFS="\t"; print $1, $2, $3, length(a), length($3), length($3)/length($2)}' file1 > file2


I tried this but I get as output:
Code:
:~$ cat file2
A    1,2,3    *    0    1    0.2
A    4,5,6    **    0    2    0.4
B    1        0    0    0
B    4,5    *    0    1    0.333333




Close, but not correct. Column 4 has zeros.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

text processing ( sed/awk)

hi.. I have a file having record on in 1 line.... I want every 400 characters in a new line... means in 1st line 1-400 in 2nd line - 401-800 etc pl help. (12 Replies)
Discussion started by: clx
12 Replies

2. Shell Programming and Scripting

awk, perl Script for processing a single line text file

I need a script to process a huge single line text file: The sample of the text is: "forward_inline_item": "Inline", "options_region_Australia": "Australia", "server_event_err_msg": "There was an error attempting to save", "Token": "Yes", "family": "Family","pwd_login_tab": "Enter Your... (1 Reply)
Discussion started by: hmsadiq
1 Replies

3. Shell Programming and Scripting

Awk text processing

Hi Very much appreciate if somebody could give me a clue .. I undestand that it could be done with awk but have a limited experience. I have the following text in the file 1 909 YES NO 2 500 No NO . ... 1 ... (8 Replies)
Discussion started by: zam
8 Replies

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

5. UNIX for Dummies Questions & Answers

Removing columns from a text file that do not have any values in second and third columns

I have a text file that has three columns. But at the end of the text file, there are trailing lines that have missing second and third columns: 4 0.04972604 KLHL28 4 0.0497332 CSTB 4 0.04979822 AIF1 4 0.04983331 DECR2 4 0.04990344 KATNB1 4 4 4 4 How can I remove the trailing... (3 Replies)
Discussion started by: evelibertine
3 Replies

6. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

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

8. Shell Programming and Scripting

awk - print columns with text and spaces

Hi, I'm using awk to print columns from a tab delimited text file: awk '{print " "$2" "$3" $6"}' file The problem I have is column 6 contains text with spaces etc which means awk only prints the first word. How can I tell awk to print the whole column content as column 6? Thanks, (10 Replies)
Discussion started by: keenboy100
10 Replies

9. Shell Programming and Scripting

Text processing using awk

I dispose of two tab-delimited files (the first column is the primary key): File 1 (there are multiple rows sharing the same key, I cannot merge them) A 28,29,30,31 A 17,18,19 B 11,13,14,15 B 8,9File 2 (there is one only row beginning with a given key) A 2,8,18,30,31 B ... (3 Replies)
Discussion started by: dovah
3 Replies

10. Shell Programming and Scripting

awk for text processing

Hi,my file is in this format ", \"symbol\": \"Rbm38\" } ]" I want to convert it to a more user readable format _id pubmed text symbol 67196 18667844 Overexpression of UBE2T in NIH3T3 cells significantly promoted colony formation in mouse cell cultures Ube2t 56190 21764855 ... (3 Replies)
Discussion started by: biofreek
3 Replies
SM(6)								   Games Manual 							     SM(6)

NAME
sm - Displays a short text fullscreen SYNOPSIS
sm [OPTIONS] [text|-] DESCRIPTION
Screen Message will display a given multi-line message as large as possible, fullscreen and black on white. You can specify the text either when launching sm, or edit it while the program is running. After a short timeout, the text entry and the quit button will disappear, leaving nothing on the screen but the entered text. To continue entering text, just start typing or (left-)click anywhere on the screen. To clear the displayed text, press Escape. To quit the program, press Ctrl-Q or press the button. OPTIONS
[text] Text to display at start up. Defaults to ":-)". If "-" is passed to sm, it will read the text to display from stdin. -f, --foreground=colordesc Define a different color to use for the foreground of the text to display than black. The text string can be in any of the forms accepted by XParseColor; these include name for a color from rgb.txt, such as DarkSlateGray, or a hex specification such as #3050b2 or #35b. -b, --background=colordesc Define a different color to use for the background of the text to display than white. For possible values, see above. -n, --font=fontspec Define a different font to use than the default sans-serif font of your system. The fontspec be the complete name for a truetype font (like "DejaVu Sans" or "Bitstream Vera Serif") or just a short font family specification ("serif", "sans-serif"). -r, --rotate=rotation Rotates the display by rotation*90 degrees counter-clock-wise. So -r 1 rotates the display to the left, and -r 2 puts it upside down. -- (Double dash) End option parsing. This is used to be able to actually hand over text that starts of with an dash. -h, --help This option will give you a short usage message summarizing the recognized options and quits. -V, --version This prints the project name together with its version number quits. AUTHOR
This manual page was written by Joachim Breitner <mail@joachim-breitner.de> and updated by Gerfried Fuchs <rhonda@deb.at> to reflect addi- tions for commandline option handling. August 05, 2008 SM(6)
All times are GMT -4. The time now is 12:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy