Sponsored Content
Full Discussion: Finding Nth Column
Top Forums Shell Programming and Scripting Finding Nth Column Post 302596476 by ngkumar on Tuesday 7th of February 2012 01:27:07 PM
Old 02-07-2012
Finding Nth Column

Please help me how can I display every nth field present in a "|" delimited file.

Ex: If a have a file with data as a|b|c|d|e|f|g|h|k|l|m|n

I want to display every 3rd feild which means the output should be
c
f
k
n

Please help me.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Finding nth occurrence in line and replacing it

Hi, I have several files with data that have to be imported to a database. These files contain records with separator characters. Some records are corrupt (2 separators are missing) and I need to correct them prior to importing them into the db. Example: ... (5 Replies)
Discussion started by: stresing
5 Replies

2. Shell Programming and Scripting

Editing 1st or nth column

Hi, I have a file whick is pipe delimited : 100| alpha| tabgo|watch| |||| 444444 | alpha| tabgo|watch| |||| 444444 | sweden |tabgo|watch| |||| 444444 | US| tabgo|watch| |||| 444444 100| factory| tabgo|watch| |||| 444444 | ABC| tabgo|watch| |||| 444444 | launch| tabgo|watch| ||||... (4 Replies)
Discussion started by: darshanw
4 Replies

3. UNIX for Dummies Questions & Answers

Finding nth line across multiple files

I have several files (around 50) that have the similar format. I need to extract the 5th line from every file and output that into a text file. So far, I have been able to figure out how to do it for a single file: $ awk 'NR==5' text1.txt > results.txt OR $ sed -n '5p' text1.txt > results.txt... (6 Replies)
Discussion started by: oriqin
6 Replies

4. Shell Programming and Scripting

get 3rd column of nth line

hi; i have a file.txt and its 9th, 10th and 11th line lines are: RbsLocalCell=S2C1 maxPortIP 4 (this is 9th line) RbsLocalCell=S3C1 maxPortIP 4 (this is 10th line) RbsLocalCell=S1C1 ... (11 Replies)
Discussion started by: gc_sw
11 Replies

5. UNIX for Dummies Questions & Answers

finding the nth match

I have a file that has information for a person....each person gets 3 or more lines to describe them. I was hoping to match person 1, then person 2.....BUT I do not know how to tell grep I only want the first (2nd, 3rd or nth) match. The alternative is doing line by line logic, which is fine... (8 Replies)
Discussion started by: countryStyle
8 Replies

6. Shell Programming and Scripting

Using AWK to find top Nth values in Nth column

I have an awk script to find the maximum value of the 2nd column of a 2 column datafile, but I need to find the top 5 maximum values of the 2nd column. Here is the script that works for the maximum value. awk 'BEGIN { subjectmax=$1 ; max=0} $2 >= max {subjectmax=$1 ; max=$2} END {print... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

7. Shell Programming and Scripting

Calculating average for every Nth line in the Nth column

Is there an awk script that can easily perform the following operation? I have a data file that is in the format of 1944-12,5.6 1945-01,9.8 1945-02,6.7 1945-03,9.3 1945-04,5.9 1945-05,0.7 1945-06,0.0 1945-07,0.0 1945-08,0.0 1945-09,0.0 1945-10,0.2 1945-11,10.5 1945-12,22.3... (3 Replies)
Discussion started by: ncwxpanther
3 Replies

8. Answers to Frequently Asked Questions

Finding the nth Particular Week in a Month – shell script

I see lot of request posted in internet to find out the day of nth week in a Month. example: what is the date of 3rd Sunday in October What is the date of 2nd Friday in June 2012 what is the date of 4th Saturday in January 2011..etc.. The below shell script is used to find out the... (1 Reply)
Discussion started by: itkamaraj
1 Replies

9. Shell Programming and Scripting

Taking nth column and putting its value in n+1 column using awk

Hello Members, Need your expert opinion how to tackle below. I have an input file that looks like below: USS|AWCC|AFGAW|93|70 USSAA|Roshan TDCA|AFGTD|93|72,79 ALB|Vodafone|ALBVF|355|69 ALGEE|Wataniya (Nedjma)|DZAWT|213|50,550 I like output file in below format: ... (7 Replies)
Discussion started by: umarsatti
7 Replies

10. UNIX for Dummies Questions & Answers

Getting the lines with nth column non-null

Hi, I have a huge list of archives (.gz). Each archive is about 40MB. A file is generated every minute so if I want to analyze the data for 1 hour I get already 60 files for example. These are text files, ';' separated, each line having about 300 fields (columns). What I need to do is to... (11 Replies)
Discussion started by: Nenad
11 Replies
XGetTextProperty()														XGetTextProperty()

Name
  XGetTextProperty - read one of a window's text properties.

Synopsis
  Status XGetTextProperty(display, w, text_prop_return, property)
	Display *display;
	Window w;
	XTextProperty *text_prop_return;
	Atom property;

Arguments
  display   Specifies a connection to an X server; returned from XOpenDisplay().

  w	    Specifies the window.

  text_prop_return
	    Returns the XTextProperty structure.

  property  Specifies the property name.

Returns
  Zero on failure, non-zero on success.

Availability
  Release 4 and later.

Description
  XGetTextProperty() reads the specified property from the window and stores the data in the returned XTextProperty structure.	It stores the
  data in the value field, the type of the data in the encoding field, the format of the data in the format field, and the number of items of
  data	in  the  nitems  field.  An extra byte containing null (which is not included in the nitems number) is stored at the end of the value
  field of text_prop_return.  The particular interpretation of the property's encoding and data as ``text'' is left to the  calling  applica-
  tion.  If the specified property does not exist on the window, XGetTextProperty() sets the value field to NULL, the encoding field to None,
  the format field to zero, and the nitems field to zero.

  If it was able to set these files in the XTextProperty structure, XGetTextProperty() returns a non-zero status;  otherwise,  it  returns  a
  zero status.

  For more information, see Volume One, Chapter 12, Interclient Communication.

Structures
     typedef struct {
	 unsigned char *value;	      /* same as Property routines */
	 Atom encoding; 	      /* prop type */
	 int format;		      /* prop data format: 8, 16, or 32 */
	 unsigned long nitems;	      /* number of data items in value */
     } XTextProperty;

Errors
  BadAtom
  BadWindow

See Also
  XFreeStringList(), XSetTextProperty(), XStringListToTextProperty(), XTextPropertytoStringList.

Xlib - Window Manager Hints													XGetTextProperty()
All times are GMT -4. The time now is 11:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy