Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Cut specific column from 2 file and merge Post 302994477 by arunkumar_mca on Thursday 23rd of March 2017 11:08:49 AM
Old 03-23-2017
Cut specific column from 2 file and merge

Hi ALL,

I have two file. I need to combine these two file based on a layout.

I used the below code and able to extract the record. But now able to insert that to a 3'rd file in between the extract

FILE 1
Code:
CAID NUMBER 1-20
TID   NUMBER 21-22
LABEL CHAR    23-44
BASE               45-60

FILE 2
Code:
 CCODE NUMBER 1-20
CCID    NUMBER 21-40

MERGE FILE
Code:
 CAID NUMBER 1-20
TID   NUMBER 21-22
LABEL CHAR    23-44
CCODE NUMBER 45-65
BASE               66-81

Code:
awk '{print ((substr($0,1,20))) "," ((substr($0,21,22))) "," ((substr($0,23,44))) "," ((substr($0,45,60)))}'    FILE1
awk '{print ((substr($0,1,20))}'    FILE1

Thanks,
Arun


Moderator's Comments:
Mod Comment Please use CODE tags correctly as required by forum rules!

Last edited by RudiC; 03-23-2017 at 12:25 PM.. Reason: Changed QUOTE to CODE tags.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To cut entire column from a file and apend it to another file as another column

file1.txt : india pakistan bangladesh japan canada africa USA srilanka Nepal file2.txt Delhi Tokyo washington I have to cut the first column of file1.txt and apend it with file2.txt as another column like this Delhi india Tokyo japan washington USA ... (4 Replies)
Discussion started by: sakthifire
4 Replies

2. UNIX for Advanced & Expert Users

cut a specific value from a column

Dear Friends, I have an output like this: 7072;0;7072901 7072;1001;7072902 7072;101;7072903 7072;102;7072904 7072;1101;7072905 7072;1301;7072906 7072;1401;7072907 7072;162;7072908 7072;1;7072909 and I need to print the value in the column 3 , row number 1. which is 7072901 only.... (2 Replies)
Discussion started by: sfaqih
2 Replies

3. Shell Programming and Scripting

How to cut first line only from a text near a specific column without cutting a word

First I have to say thank you to this community and this forum. You helped me very much builing several useful scripts. Now, I can't get a solution the following problem, I'm stuck somehow. Maybe someone has an idea. In short, I dump a site via lynx and pipe the output in a file. I need to... (7 Replies)
Discussion started by: lowmaster
7 Replies

4. Shell Programming and Scripting

Assigning a specific format to a specific column in a text file using awk and printf

Hi, I have the following text file: 8 T1mapping_flip02 ok 128 108 30 1 665000-000008-000001.dcm 9 T1mapping_flip05 ok 128 108 30 1 665000-000009-000001.dcm 10 T1mapping_flip10 ok 128 108 30 1 665000-000010-000001.dcm 11 T1mapping_flip15 ok 128 108 30... (2 Replies)
Discussion started by: goodbenito
2 Replies

5. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

6. Shell Programming and Scripting

Awk: Need help replacing a specific column in a file by part of a column in another file

Hi, I have two input files as File1 : ABC:client1:project1 XYZ:client2-aa:project2 DEF:client4:proj File2 : client1:W-170:xx client2-aa:WT-04:yy client4:L-005A:zz Also, array of valid values can be hardcoded like Output : ABC:W:project1 XYZ:WT:project2 (1 Reply)
Discussion started by: aa2601
1 Replies

7. UNIX for Dummies Questions & Answers

How to cut from a text file based on value of a specific column?

Hi, I have a tab delimited text file from which I want to cut out specific columns. If the second column equals one, I want to cut out columns 1 and 5 and 6. If the second column equals two, I want to cut out columns 1 and 5 and 7. How do I go about doing that? Thanks! (4 Replies)
Discussion started by: evelibertine
4 Replies

8. Shell Programming and Scripting

How to merge variable data from another file into specific place?

Hello, I'm trying to create multiple commands using a variable input from another file but am not getting any successful results. Basically, file1.txt contains multiple lines with single words: <file1.txt> yellow blue black white I want to create multiple echo commands with these... (8 Replies)
Discussion started by: demmel
8 Replies

9. Shell Programming and Scripting

Merge column file

Hi All, I have on file1 and file2 some, $cat file1 aaa bbb ccc ddd eee fff ggg hhh iii jjj with line blank, and (12 Replies)
Discussion started by: aav1307
12 Replies

10. Shell Programming and Scripting

Overwrite specific column in xml file with the specific column from adjacent line

I have an xml file dumped from rrd file, that I want to "patch" so the xml file doesn't contain any blank hole in the resulting graph of the rrd file. Here is the file. <!-- 2015-10-12 14:00:00 WIB / 1444633200 --> <row><v> 4.0419731265e+07 </v><v> 4.5045912770e+06... (2 Replies)
Discussion started by: rk4k
2 Replies
ptpd(8) 						  Precision Time Protocol daemon						   ptpd(8)

NAME
ptpd - Precision Time Protocol daemon (1588-2008) SYNOPSIS
ptpd [?] [-c] [-S] [-f FILE] [-R FILE] [-d] [-D] [-x] [-M NUMBER] [-t] [-T ttl] [-a NUMBER,NUMBER] [-w NUMBER] [-b NAME] [-u ADDRESS] [-e] [-h] [-l NUMBER,NUMBER] [-o NUMBER] [-i NUMBER] [-n NUMBER] [-y NUMBER] [-m NUMBER] [-g] [-v NUMBER] [-r NUMBER] [-s NUMBER] [-p NUMBER] [-q NUMBER] DESCRIPTION
Implements the Precision Time Protocol (PTP) Version 2 as defined by the IEEE 1588-2008 standard. PTP was developed to provide very precise time coordination of LAN connected computers. PTPd is a complete implementation of the IEEE 1588 v2 specification for a standard (ordinary) clock. PTPd has been tested with and is known to work properly with other IEEE 1588 implementations. The source code for PTPd is freely available under a BSD-style license. Thanks to contributions from users, PTPd is becoming an increasingly portable, interoperable, and stable IEEE 1588 implementation. For more information, see http://ptpd.sourceforge.net/ OPTIONS
-? display a short help text -c run in command line (non-daemon) mode -S log information to syslog -f FILE send output to FILE -R FILE record a quality FILE -d display stats -D display stats in .csv format -x do not reset the clock if off by more than one second -M NUMBER do not reset the clock if off by more than NUMBER nanoseconds -t do not adjust the system clock -T set multicast TTL for packets. Defaults to 1. -a NUMBER,NUMBER specify clock servo P and I attenuations -w NUMBER specify one way delay filter stiffness -b NAME bind PTP to network interface NAME -u ADDRESS also send uni-cast to ADDRESS -e run in ethernet mode (level2) -h run in End to End mode -l NUMBER,NUMBER specify inbound, outbound latency in nsec -o NUMBER specify current UTC offset -i NUMBER specify PTP domain number -n NUMBER specify announce interval in 2^NUMBER sec -y NUMBER specify sync interval in 2^NUMBER sec -m NUMBER specify max number of foreign master records -g run as slave only -v NUMBER specify system clock allen variance -r NUMBER specify system clock accuracy -s NUMBER specify system clock class -p NUMBER specify priority1 attribute -q NUMBER specify priority2 attribute AUTHOR
Gael Mace <gael_mace@users.sourceforge.net> & Alexandre Van Kempen. Steven Kreuzer <skreuzer@freebsd.org> George Neville-Neil <gnn@freebsd.org> This manual page was written by Gael Mace for any Linux environment project. version 2.1.0 October, 2010 ptpd(8)
All times are GMT -4. The time now is 03:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy