10-30-2006
echo "A,B,C,D" | awk -F, '{print NF}'
Here NF signifies number of fields.
Each field of the line will be marked as $1, $2 etc
you can use a loop , if condition to print the required fields.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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
Dear All,
Please help me to do this.
I have a file like this.
5|94662240807|94776109911|94776325901|94779007172||||||
5|94112925421|94352240384|94352259199|94672229012||||||
5|94714242745|94722952461|94777660793|94788914465||||||
5|94242224624|94776145420|94776172499|94776531059||||||
... (7 Replies)
Discussion started by: Nayanajith
7 Replies
3. Shell Programming and Scripting
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
4. UNIX for Dummies Questions & Answers
Hi,
I used to count number of fields using following command head -1 <filename> | awk -F"," '{print NF}'
Now the scenario is the delimiter(comma) occurs inside one of the data field. How to ignore the comma inside data and consider only delimiter and count number of fields. The fields are... (1 Reply)
Discussion started by: ethanr100
1 Replies
5. Shell Programming and Scripting
Hi,
I would like to know how can I get the number of rows in file1 that:
- the 1st and 2nd field should be the same (text)
- the 3rd field should be less or equal (numeric)
when comparing to file2.
So for each row of file1, I would like to have the number of rows in file2 that follow the... (5 Replies)
Discussion started by: fadista
5 Replies
6. Shell Programming and Scripting
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
7. Shell Programming and Scripting
Hi,
i am trying to count the fields in a file.
Input:
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
6
5
6
awk -F"," '{print $NF}' file1.txt
When i try with above awk... (3 Replies)
Discussion started by: onesuri
3 Replies
8. Shell Programming and Scripting
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
9. Shell Programming and Scripting
I am new to cut and I want to use the field option with a space delimiter on an Apache log file.
For example, if I wanted to find the 200 HTTP code using cut in this manner on the file below
cat access_abc.log | cut -d' ' -f7 | grep "200"
157.55.39.183 - - "GET /content/696-news041305... (4 Replies)
Discussion started by: sharingsunshine
4 Replies
10. UNIX for Beginners Questions & Answers
I'm trying to use awk to count the occurrences of two matching fields of a CSV file.
For instance, for data that looks like this...
Joe,Blue,Yes,No,High
Mike,Blue,Yes,Yes,Low
Joe,Red,No,No,Low
Joe,Red,Yes,Yes,Low
I've been trying to use code like this...
countvar=`awk ' $2~/$color/... (4 Replies)
Discussion started by: nmoore2843
4 Replies
LEARN ABOUT CENTOS
xtallocategc
XtAllocateGC(3) XT FUNCTIONS XtAllocateGC(3)
NAME
XtAllocateGC - obtain a sharable GC with modifiable fields
SYNTAX
GC XtAllocateGC(Widget w, Cardinal depth, XtGCMask value_mask, XGCValues *values, XtGCMask dynamic_mask, XtGCMask unused_mask);
ARGUMENTS
values Specifies the actual values for this GC.
value_mask
Specifies which fields of the values are specified.
w Specifies the widget.
depth Specifies the depth for which the returned GC is valid, or 0.
dynamic_mask
Specifies the fields of the GC that will be modified by the caller.
unused_mask
Specifies the fields of the GC that will not be needed by the caller.
DESCRIPTION
The XtAllocateGC function returns a sharable GC that may be modified by the client. The screen field of the specified widget or of the
nearest widget ancestor of the specified object and the specified depth argument supply the root and drawable depths for which the GC is to
be valid. If depth is zero the depth is taken from the depth field of the specified widget or of the nearest widget ancestor of the speci-
fied object.
The value_mask argument specifies the fields of the GC that will be initialized with the respective members of the values structure. The
dynamic_mask argument specifies fields that the caller intends to modify during program execution. The caller must ensure that the corre-
sponding GC field is set prior to each use of the GC. The unused_mask argument specifies fields of the GC that are of no interest to the
caller. The caller may make no assumptions about the contents of any fields specified in unused_mask. The caller may assume that at all
times all fields not specified in either dynamic_mask or unused_mask have their default value if not specified in value_mask or the value
specified by values. If a field is specified in both value_mask and dynamic_mask, the effect is as if it were specified only in
dynamic_mask and then immediately set to the value in values. If a field is set in unused_mask and also in either value_mask or
dynamic_mask, the specification in unused_mask is ignored.
XtAllocateGC tries to minimize the number of unique GCs created by comparing the arguments with those of previous calls and returning an
existing GC when there are no conflicts. XtAllocateGC may modify and return an existing GC if it was allocated with a nonzero unused_mask.
SEE ALSO
XtGetGC
X Toolkit Intrinsics - C Language Interface
Xlib - C Language X Interface
X Version 11 libXt 1.1.4 XtAllocateGC(3)