Sponsored Content
Full Discussion: awk count fields not working
Top Forums Shell Programming and Scripting awk count fields not working Post 302765343 by onesuri on Saturday 2nd of February 2013 02:42:45 AM
Old 02-02-2013
awk count fields not working

Hi,

i am trying to count the fields in a file.
Input:
Code:
100,1000,,2000,3000,10/26/2012 12:12:30
200,3000,,1000,01/28/2012 17:12:30
300,5000,,5000,7000,09/06/2012 16:12:30

output:
Cout of the fileds for each row
Code:
6
5
6

Code:
awk -F"," '{print $NF}' file1.txt

When i try with above awk command i am getting the below output and it is not working as expected.
Code:
12:12:30
17:12:30
16:12:30

Any suggestion using awk command for couting the fields.

Last edited by Scott; 02-02-2013 at 03:54 AM.. Reason: More code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

count fields

Is there a way to count the no. of fields (columns) in a file? Actually I need to cut some fields starting from the middle to the end. How can I specify to cut till last field? thanks in advance :) (4 Replies)
Discussion started by: sskb
4 Replies

2. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

3. UNIX for Dummies Questions & Answers

count number of fields not using SED or AWK

hi forums i need help with a little problem i am having. i need to count the number of fields that are in a saved variable so i can use that number to make a different function work properly. is there a way of doing this without using SED/AWK? anything would be greatly appreciated (4 Replies)
Discussion started by: strasner
4 Replies

4. Shell Programming and Scripting

awk - count character count of fields

Hello All, I got a requirement when I was working with a file. Say the file has unloads of data from a table in the form 1|121|asda|434|thesi|2012|05|24| 1|343|unit|09|best|2012|11|5| I was put into a scenario where I need the field count in all the lines in that file. It was simply... (6 Replies)
Discussion started by: PikK45
6 Replies

5. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

6. Shell Programming and Scripting

Speed : awk command to count the occurrences of fields from one file present in the other file

Hi, file1.txt AAA BBB CCC DDD file2.txt abc|AAA|AAAabcbcs|fnwufnq bca|nwruqf|AAA|fwfwwefwef fmimwe|BBB|fnqwufw|wufbqw wcdbi|CCC|wefnwin|wfwwf DDD|wabvfav|wqef|fwbwqfwfe i need the count of rows of file1.txt present in the file2.txt required output: AAA 2 (10 Replies)
Discussion started by: mdkm
10 Replies

7. Shell Programming and Scripting

awk sort based on difference of fields and print all fields

Hi I have a file as below <field1> <field2> <field3> ... <field_num1> <field_num2> Trying to sort based on difference of <field_num1> and <field_num2> in desceding order and print all fields. I tried this and it doesn't sort on the difference field .. Appreciate your help. cat... (9 Replies)
Discussion started by: newstart
9 Replies

8. Shell Programming and Scripting

awk to count and rename based on fields

In the below awk using the tab-delimited input, I am trying count the - symbol in $5 and output the count as well as the renamed condition ins. I am also count the - symbol in $6 and output the count as well as the renamed condition del. I am also count the tomes that in $5 and $6 there are... (6 Replies)
Discussion started by: cmccabe
6 Replies

9. Shell Programming and Scripting

awk to output match and mismatch with count using specific fields

In the below awk I am trying output to one file those lines that match between $2,$3,$4 of file1 and file2 with the count in (). I am also trying to output those lines that are missing between $2,$3,$4 of file1 and file2 with the count of in () each. Both input files are tab-delimited, but the... (7 Replies)
Discussion started by: cmccabe
7 Replies

10. Shell Programming and Scripting

awk to remove lines where field count is greather than 1 in two fields

I am trying to remove all the lines and spaces where the count in $4 or $5 is greater than 1 (more than 1 letter). The file and the output are tab-delimited. Thank you :). file X 5811530 . G C NLGN4X 17 10544696 . GA G MYH3 9 96439004 . C ... (1 Reply)
Discussion started by: cmccabe
1 Replies
COROSYNC-OBJCTL(8)					      System Manager's Manual						COROSYNC-OBJCTL(8)

NAME
corosync-objctl - Configure objects in the Object Database SYNOPSIS
corosync-objctl [-c|-w|-d|-a|-t-h] <OBJECT-SPEC>... DESCRIPTION
corosync-objctl is used to configure objects within the object database at runtime. OBJECT-SPEC There are two types of entities Objects and Key=Value pairs Objects Objects are container like entities that can hold other entities. They are specified as "objectA"."objectB". An example is log- ging.logger. Key=Value pairs These are the entities that actually hold values (read database "fields"). They are specified as object.key=value or just object.key if you are reading. OPTIONS
-c Create a new object. -d Delete an existing object. -w Use this option when you want to write a new value to a key. -a Display all values currently available. -t Track changes to an object and it's children. As changes are made to the object they are printed out. this is kind of like a "tail -f" for the object database. -h Print basic usage. EXAMPLES
Print the objOne object (shouldn't exist yet). $ corosync-objctl objOne Create the objOne object. $ corosync-objctl -c objOne Print the objOne object (empty). $ corosync-objctl objOne objOne Write two new keys to the objOne object. $ corosync-objctl -w objOne.max=3000 objOne.min=100 Print the objOne object (with the two new keys). $ corosync-objctl objOne objOne.min=100 objOne.max=3000 Delete the objOne.min key $ corosync-objctl -d objOne.min=100 Prove that is gone. $ corosync-objctl objOne objOne.max=3000 Delete the whole objOne object. $ corosync-objctl -d objOne Prove that is gone. $ corosync-objctl objOne SEE ALSO
confdb_initialize(3), AUTHOR
Angus Salkeld 2008-07-29 COROSYNC-OBJCTL(8)
All times are GMT -4. The time now is 11:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy