Count number of characters in particular column


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Count number of characters in particular column
# 1  
Old 01-31-2012
Count number of characters in particular column

Hi i have data like
abchd 124 ldskc aattggcc

each separated by tab space i want to count number of characters in 4th column and print it in new column with tabspace for every line can anyone help me how to do it.

Thanks.
# 2  
Old 01-31-2012
Code:
awk '{print $0"\t"length($4)}' infile

Please use code tags when posting sample input/output or code.
This User Gave Thanks to mirni For This Post:
# 3  
Old 01-31-2012
Code:
awk '$0=$0"\t"length($4)' input.txt

This User Gave Thanks to itkamaraj For This Post:
# 4  
Old 01-31-2012
Thank you it worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

2. Shell Programming and Scripting

Find number of characters in a column and replace

Hi all, I want to count total no. of characters in a column. and if no. of charaters are more than 3 then it must replace it by splitted string. ie, it must place a space after 3 characters. Ex: 21 435g asd3dd jklfjwe wer column number 3 has 4 alphanumeric character, so it must be splitted... (3 Replies)
Discussion started by: CAch
3 Replies

3. UNIX for Dummies Questions & Answers

count different characters from one column

Hi everyone, and thanks after all I'm a biologist and i have to extract information from one text. The text is something like this 1023 A A 56 0 cc...,,,,..gg..Cc.c,,c..CC..,, 1024 T T 86 0 ..,,,..aaAA..,,aAA,,a,,A,,a 1025 G G 125 0 ... (5 Replies)
Discussion started by: beajorrin
5 Replies

4. Shell Programming and Scripting

Count the number of fields in column

Hi I was going through the below thread https://www.unix.com/shell-programming-scripting/48535-how-count-number-fields-record.html I too have something similar requirement as specified in this thread but the number of columns in my case can be very high, so I am getting following error. ... (3 Replies)
Discussion started by: shekharjchandra
3 Replies

5. Shell Programming and Scripting

Count the number or row with same value in a column

This is the source file, we called it errorlist.out 196 server_a server_unix_2 CD 196 server_b server_win_1 CD 196 server_c server_win_2 CD 196 server_bd server_unix_2 CD 196 server_d server_unix_2 CD 196 server_es server_win_1 CD 196 ... (14 Replies)
Discussion started by: sQew
14 Replies

6. UNIX for Dummies Questions & Answers

reducing the number of characters in a column

Hi, I would like to take the first column of a bunch of lines and take only the 6th through 15th characters. The first column are not regular. gbAY277147.1Ptv3.T1469 CTTGAACAT gbAY277149.1Ptro3.T1469 CTTGAACAT gbAY287891.1Hs3.T1469 CTTGAACATTTGC into 7147.1Ptv3 CTTGAACAT... (4 Replies)
Discussion started by: mikey11415
4 Replies

7. Shell Programming and Scripting

to count the number of occurences of a column value

im trying to count the number of occurences of column 2 value(starting from KKK*) of the below file, file.txt using the code cat file.txt | awk ' BEGIN { print "Category Counts"} {FS=","} {NR > 2} { cats = cats + 1} END { for(c in cats) { print c, "=", cats} } ' but its returning as ... (6 Replies)
Discussion started by: michaelrozar17
6 Replies

8. Shell Programming and Scripting

awk count characters, sum, and divide by another column

Hi All, I am another biologist attempting to parse a large txt file containing several million lines like: tucosnp 56762 T Y 228 228 60 23 .CcCcc,,..c.c,cc,,.C... What I need to do is get the frequency of periods (.) plus commas (,) in column 9, and populate this number into another... (1 Reply)
Discussion started by: peromhc
1 Replies

9. UNIX for Dummies Questions & Answers

Unix command to count the number of files with specific characters in name

Hey all, I'm looking for a command that will search a directory (and all subdirectories) and give me a file count for the number of files that contain specific characters within its filename. e.g. I want to find the number of files that contain "-a.jpg" in their name. All the searching I've... (6 Replies)
Discussion started by: murphysm
6 Replies

10. Programming

Count the number of repeated characters in a given string

i have a string "dfasdfasdfadf" i want to count the number of times each character is repeated.. For instance, d is repeated 4 times, f is repeated 4 times.. can u give a program in c (1 Reply)
Discussion started by: pgmfourms
1 Replies
Login or Register to Ask a Question