473,383 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Script for counting some columns in file

1
Hello!!
I have a query to count the last column of the file and print it as shown in the below format!!
I tried using ths but dint work

cut fileWithLotsOfColumns.txt -d" " -f 1,2,3,4 >fileWithOnlyFirst4Cols.txt

plz help me

output should be something like this!!!






AF1 AF2 AM1 AM2 EF1 EF2 EM1 EM2
FBgn0033056 119 301 205 141 317 153 506 319
FBgn0037888 20 41 41 22 30 17 57 34
FBgn0034742 3193 3642 2558 2005 1687 1746 3039 3610
FBgn0032640 1243 2804 1969 2130 1777 1536 3143 3259
FBgn0259204 469 1566 971 962 1214 783 1872 1602
FBgn0039821 56 58 36 34 35 46 49 87
Feb 28 '14 #1
1 1982
Luuk
1,047 Expert 1GB
But how does your input look like?

If you have i.e. this:
Expand|Select|Wrap|Line Numbers
  1. a 1 2
  2. b 3 4
than you can add a column with this:
Expand|Select|Wrap|Line Numbers
  1. awk '{ sum=sum+$3 }END{ print sum }
which should output '6'
Mar 1 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Radioactive Man | last post by:
I am fairly new to the latest verion of Python and using it on windows 95, 2000, and/or XP. What libraries, modules, functions, etc. would I need to set up a Python script to download a file, say...
6
by: John Reese | last post by:
def uselessHash(filename): fp= open(filename) hash= 0 for line in fp: hash ^= hash(line.strip()) fp.close() # do I need this or is fp closed by ref count? return hash Consider the function...
1
by: Avin Patel | last post by:
Hi, I am looking for script to allow multiple files can be uploaded/attached in webform ( mostly cgi/perl or php). But I don't like the multiple input boxes using "<input type="file" size="40"...
10
by: EnjoyNews | last post by:
I have a php site I have an include line called "include 'Cookie.php';" In this Cookie.php file I have these codes. <?php $conn = mysql_connect("$db", "$user", "$pass");...
4
by: Regnab | last post by:
As any good code pirate would, I have duly copied the code suggested in this forum from 1998(VBA method to determine number of columns in a table??) but I keep getting an error "Object Required"......
1
by: JJ | last post by:
Is it possible to count the number of columns that match certain conditions and return a single value? For example in the database we have a record where: Column 1 = Male Column 2 = A Column...
0
by: brozanic | last post by:
Does anyone have a script or bat file to uninstall Access97?
1
by: Osoccer | last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem: I need a...
5
by: simplyme7 | last post by:
I have a data file which has not fixed coulmns as follows: Column11 Column12 Column13 Column21 Column22 Column31 Column32 Column33 Column34 . . . I want to...
5
by: ramanagosu | last post by:
Hi, I am new to php please give me an idea how to manage video script in css file using php cheers Ramana.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.