Sponsored Content
Top Forums Shell Programming and Scripting Identify the First Column Position in Second Column and add the position value Post 302934317 by Franklin52 on Friday 6th of February 2015 06:53:50 AM
Old 02-06-2015
Something like this?
Code:
awk -F\| '{NF=3}$1 ~ /[a-zA-Z]/{$3=NR}1' OFS=\| file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File Manipulation (Move Column Position)

Hi All, I have a comma separated value (.CSV) file like the one below. The file contains about 20000 lines. FileName EmpNo,Name,Age,Sex,Band,Spouse,Children,Salary, 1000,Arnold,24,M,B,N.A.,No,10000, 1001,Jenny,27,F,C,John,2,20000, ................................... What i need is to... (1 Reply)
Discussion started by: ultimate
1 Replies

2. Shell Programming and Scripting

How to add a column numbers at a particular position?

Problem discription: I have many files which contain the same lines. for instance, (15 lines) file1 ..last column add by hand arbitrarily. 1.78116800 0.68396600 0.00061900 0.47641600 -0.49794500 -0.00024000 -1.70662800 0.29577100 0.67863600 -1.70647600 0.29654600 ... (9 Replies)
Discussion started by: liuzhencc
9 Replies

3. Shell Programming and Scripting

row to column and position data in to fixed column width

Dear friends, Below is my program and current output. I wish to have 3 or 4 column output in order to accomodate in single page. i do have subsequent command to process after user enter the number. Program COUNT=1 for MYDIR in `ls /` do VOBS=${MYDIR} echo "${COUNT}. ${MYDIR}" ... (4 Replies)
Discussion started by: baluchen
4 Replies

4. Shell Programming and Scripting

Identify the position of character

Hi, Can some one guide me to identify the position of a character using index in UNIX. I have a record like "17/11/2010 15:16:39;reject;10.44.48.65;daemon alert; src: 10.44.48.112; dst: 172.21.52.88" . I need to identify the value which comes after _src:_ (_ denotes space). I am able to... (15 Replies)
Discussion started by: suneel.mekala
15 Replies

5. Shell Programming and Scripting

Find the position of a field/column in a flat file

Hi, Let say I have a file which has around 400 fields. SampleFile ========= PATIENTID|FACILITY|................|TIME_LAST_VISITED_BY_MD|.....|STATUS| How is it possible to find out which field is TIME_LAST_VISITED_BY_MD?fro example by seeing the above structure we can saw FACILITY... (5 Replies)
Discussion started by: machomaddy
5 Replies

6. Shell Programming and Scripting

Trying to move a column into another position within a sed script

Currently the table looks like this student-id,last,first,hwk1,hwk2,hwk3,exam1,hwk4,hwk5,exam2 pts-avail,,,100,150,100,200,100,150,300 991-78-7872,Thompson,Ken,95,143,79,185,95,135,259 123-45-6789,Richie,Dennis,99,123,89,189,97,139,279 234-56-7891,Aho,Al,78,146,75,176,88,128,285... (3 Replies)
Discussion started by: ertang
3 Replies

7. Shell Programming and Scripting

Regex to identify word in second position on a line

I am interested in finding a regex to find a word in second position on a line. The word in question is या I tried the following PERL EXPRESSION but it did not work: ] या or ^\W या But both gave Null results I am giving below a Sample file: देना या सौंपना=delegate तह जमना या... (8 Replies)
Discussion started by: gimley
8 Replies

8. Shell Programming and Scripting

Need command or script to print all lines from 2nd position to last but one position

hi guys, i want command or script to display the content of file from 2nd position to last but one position of a file abcdefghdasdasdsd 123,345,678,345,323 434,656,656,656,656 678,878,878,989,545 4565656667,65656 i want to display the same above file without first and... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

9. Linux

Removing a character at specific position in a column

Hi, I have a file like this (about 8 columns in total, this being the 2nd column) gi_49482297_ref_YP_039521.1_ gi_49482297_ref_YP_039521.1_ gi_49482315_ref_YP_039539.1_ gi_49482315_ref_YP_039539.1_I want to remove the _ at the end of the line. And at later stages I would want to replace the... (5 Replies)
Discussion started by: Syeda Sumayya
5 Replies

10. Shell Programming and Scripting

Column to row and position data in a text file

Hi everyone.. I have a list of values in a file... a, b, c, 1, 2, 3, aaaa, bbbbb, I am interested in converting this column to a row.. "text",aaaa, bbbb a,1 (7 Replies)
Discussion started by: manihi
7 Replies
RTBL(3) 						   BSD Library Functions Manual 						   RTBL(3)

NAME
rtbl_create, rtbl_destroy, rtbl_set_flags, rtbl_get_flags, rtbl_set_prefix, rtbl_set_separator, rtbl_set_column_prefix, rtbl_set_column_affix_by_id, rtbl_add_column, rtbl_add_column_by_id, rtbl_add_column_entry, rtbl_add_column_entry_by_id, rtbl_new_row, rtbl_format -- format data in simple tables LIBRARY
The roken library (libroken, -lroken) SYNOPSIS
#include <rtbl.h> int rtbl_add_column(rtbl_t table, const char *column_name, unsigned int flags); int rtbl_add_column_by_id(rtbl_t table, unsigned int column_id, const char *column_header, unsigned int flags); int rtbl_add_column_entry(rtbl_t table, const char *column_name, const char *cell_entry); int rtbl_add_column_entry_by_id(rtbl_t table, unsigned int column_id, const char *cell_entry); rtbl_t rtbl_create(void); void rtbl_destroy(rtbl_t table); int rtbl_new_row(rtbl_t table); int rtbl_set_column_affix_by_id(rtbl_t table, unsigned int column_id, const, char, *prefix", const char *suffix); int rtbl_set_column_prefix(rtbl_t table, const char *column_name, const char *prefix); unsigned int rtbl_get_flags(rtbl_t table); void rtbl_set_flags(rtbl_t table, unsigned int flags); int rtbl_set_prefix(rtbl_t table, const char *prefix); int rtbl_set_separator(rtbl_t table, const char *separator); int rtbl_format(rtbl_t table, FILE, *file"); DESCRIPTION
This set of functions assemble a simple table consisting of rows and columns, allowing it to be printed with certain options. Typical use would be output from tools such as ls(1) or netstat(1), where you have a fixed number of columns, but don't know the column widths before hand. A table is created with rtbl_create() and destroyed with rtbl_destroy(). Global flags on the table are set with rtbl_set_flags and retrieved with rtbl_get_flags. At present the only defined flag is RTBL_HEADER_STYLE_NONE which suppresses printing the header. Before adding data to the table, one or more columns need to be created. This would normally be done with rtbl_add_column_by_id(), column_id is any number of your choice (it's used only to identify columns), column_header is the header to print at the top of the column, and flags are flags specific to this column. Currently the only defined flag is RTBL_ALIGN_RIGHT, aligning column entries to the right. Columns are printed in the order they are added. There's also a way to add columns by column name with rtbl_add_column(), but this is less flexible (you need unique header names), and is considered deprecated. To add data to a column you use rtbl_add_column_entry_by_id(), where the column_id is the same as when the column was added (adding data to a non-existent column is undefined), and cell_entry is whatever string you wish to include in that cell. It should not include newlines. For columns added with rtbl_add_column() you must use rtbl_add_column_entry() instead. rtbl_new_row() fills all columns with blank entries until they all have the same number of rows. Each column can have a separate prefix and suffix, set with rtbl_set_column_affix_by_id; rtbl_set_column_prefix allows setting the prefix only by column name. In addition to this, columns may be separated by a string set with rtbl_set_separator (by default columns are not seprated by anything). The finished table is printed to file with rtbl_format. EXAMPLES
This program: #include <stdio.h> #include <rtbl.h> int main(int argc, char **argv) { rtbl_t table; table = rtbl_create(); rtbl_set_separator(table, " "); rtbl_add_column_by_id(table, 0, "Column A", 0); rtbl_add_column_by_id(table, 1, "Column B", RTBL_ALIGN_RIGHT); rtbl_add_column_by_id(table, 2, "Column C", 0); rtbl_add_column_entry_by_id(table, 0, "A-1"); rtbl_add_column_entry_by_id(table, 0, "A-2"); rtbl_add_column_entry_by_id(table, 0, "A-3"); rtbl_add_column_entry_by_id(table, 1, "B-1"); rtbl_add_column_entry_by_id(table, 2, "C-1"); rtbl_add_column_entry_by_id(table, 2, "C-2"); rtbl_add_column_entry_by_id(table, 1, "B-2"); rtbl_add_column_entry_by_id(table, 1, "B-3"); rtbl_add_column_entry_by_id(table, 2, "C-3"); rtbl_add_column_entry_by_id(table, 0, "A-4"); rtbl_new_row(table); rtbl_add_column_entry_by_id(table, 1, "B-4"); rtbl_new_row(table); rtbl_add_column_entry_by_id(table, 2, "C-4"); rtbl_new_row(table); rtbl_format(table, stdout); rtbl_destroy(table); return 0; } will output the following: Column A Column B Column C A-1 B-1 C-1 A-2 B-2 C-2 A-3 B-3 C-3 A-4 B-4 C-4 HEIMDAL
June 26, 2004 HEIMDAL
All times are GMT -4. The time now is 09:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy