Sponsored Content
Top Forums Shell Programming and Scripting Insert Columns before the last Column based on the Count of Delimiters Post 302914177 by RudiC on Friday 22nd of August 2014 11:59:54 AM
Old 08-22-2014
Try (untested):
Code:
awk -FÇ 'NF < 140 {NF+=2; $NF=$(NF-2);$(NF-2)=""}' file

This would add two columns even if there's just e.g. three of them. Is that what you want?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count first column on the basis of two other columns

Hello, I have a file ================= 12 SRV1 GRP1 19 SRV1 GRP1 19 SRV1 GRP2 3 SRV1 GRP1 3 SRV1 GRP2 30 SRV1 GRP2 7 SRV1 GRP1 8 SRV1 GRP3 =========== I want output like =============== 41 SRV1 GRP1 52 SRV1 GRP2 8 SRV1 GRP3 (1 Reply)
Discussion started by: kaustubh137
1 Replies

2. Shell Programming and Scripting

insert leading zeroes based on the character count

Hi, I need add leading zeroes to a field in a file based on the character count. The field can be of 1 character to 6 character length. I need to make the field 14bytes. eg: 8351,20,1 8351,234,6 8351,2,0 8351,1234,2 8351,123456,1 8351,12345,2 This should become. ... (3 Replies)
Discussion started by: gpaulose
3 Replies

3. Shell Programming and Scripting

Insert new line based on numerical number of column

My input file: Class Number Position Range 1 Initial 50 1 Initial 50 2 Terminal 150 2 Terminal 20 2 Single 10 3 Single 20 4 Double 50 5 Initial 50 5 Initial 60 Class Number... (11 Replies)
Discussion started by: patrick87
11 Replies

4. UNIX for Dummies Questions & Answers

How to insert alternative columns and sort text from first column to second?

Hi Everybody, I am just new to UNIX as well as to this forum. I have a text file with 10,000 coloumns and each coloumn contains values separated by space. I want to separate them into new coloumns..the file is something like this as ad af 1 A as ad af 1 D ... ... 1 and A are in one... (7 Replies)
Discussion started by: Unilearn
7 Replies

5. Shell Programming and Scripting

Count Columns and If less add new column

Hi All, My Input.txt should have always 4 columns in some cases i may not get all the 4columns data. My requirement is if columns as not equal to 4 then append new column delimiter. Input.txt A,1,2 B,1,2,3 C,1 Desired output should be in below format Output.txt A,1,2,... (3 Replies)
Discussion started by: kmsekhar
3 Replies

6. Shell Programming and Scripting

count the unique records based on certain columns

Hi everyone, I have a file result.txt with records as following and another file mirna.txt with a list of miRNAs e.g. miR22, miR123, miR13 etc. Gene Transcript miRNA Gar Nm_111233 miR22 Gar Nm_123440 miR22 Gar Nm_129939 miR22 Hel Nm_233900 miR13 Hel ... (6 Replies)
Discussion started by: miclow
6 Replies

7. Shell Programming and Scripting

Insert space in specific column among many columns

Hello, I have some problem in inserting the space for the pairs of columns. I have the input file : I used this code below in replacing it using space in specific column (replace space in each two columns) sed -e "s/,/ /2" -e "s/,/ /3" inputfile Output showed : However, I have many... (3 Replies)
Discussion started by: awil
3 Replies

8. Shell Programming and Scripting

Insert value of column based on file name matching

At the top of the XYZ file, I need to insert the ABC data value of column 2 only when ABC column 1 matches the prefix XYZ file name (not the ".txt"). Is there an awk solution for this? ABC Data 0101 0.54 0102 0.48 0103 1.63 XYZ File Name 0101.txt 0102.txt 0103.txt ... (7 Replies)
Discussion started by: ncwxpanther
7 Replies

9. Shell Programming and Scripting

Convert rows to columns based on key and count

Team, I am having requirement to convert rows to columns Input is: key ,count, id1, pulse1, id2, pulse2 ,id3, pulse3 12, 2 , 14 , 56 , 15, 65 13, 3, 12, 32, 14, 23, 18, 54 22, 1 , 32, 42 Expected Out put: key, id,pulse 12, 14, 56 12, 15, 65 13 ,12, 32 13, 14 ,23 13, 18 ,54 22 ,32,... (3 Replies)
Discussion started by: syam1406
3 Replies

10. Shell Programming and Scripting

Linux shell script to insert new lines based on delimiter count

The input file is a .dat file which is delimited by null (^@ in Linux). On a windows PC it looks something like this (numbers are masked with 1). https://i.imgur.com/nta2Gqp.jpg The entire file is in one row but it has multiple records - each record contains 80 fields i.e. there are 81 counts... (9 Replies)
Discussion started by: digitalnirvana
9 Replies
RCVPACK(1)                                                           [nmh-1.5]                                                          RCVPACK(1)

NAME
rcvpack - append message to file SYNOPSIS
/usr/lib/mh/rcvpack file [-mbox] [-mmdf] [-version] [-help] DESCRIPTION
The rcvpack program will append a copy of the message to the file listed on its command line. If the -mbox switch is given (the default), then the messages are separated using mbox (uucp) style delimiters. This is the format used by most mail clients (elm, mailx, etc.). If the -mmdf switch is given, then the messages are separated by mmdf style delimiters. Each message in the file is separated by four CTRL-A's and a newline. rcvpack will correctly lock and unlock the file to serialize access to the file, when running multiple copies of rcvpack . In general, its use is obsoleted by the file action of slocal, although it might still have occasional uses in various shell scripts. FILES
/etc/nmh/mts.conf nmh mts configuration file SEE ALSO
rcvdist(1), rcvstore(1), rcvtty(1), slocal(1) BUGS
Only two return codes are meaningful, others should be. MH.6.8 11 June 2012 RCVPACK(1)
All times are GMT -4. The time now is 09:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy