Sponsored Content
Top Forums Shell Programming and Scripting perl script to split the text file after every 4th field Post 302682531 by itkamaraj on Monday 6th of August 2012 11:12:26 AM
Old 08-06-2012
Code:
$ perl -F, -lane 'foreach(@F){$i++;if($i%4!=0){printf("%s,",$_)}else{print $_ .","}}' input.txt
196237,ram,25-May-06,ram.kiran@xyz.com,
204183,Pavan,4-Jun-07,Pavan.Desai@xyz.com,
237107,ram Chandra,15-Mar-10,ram.krishna@xyz.com  ,
237547,Ravi,6-Apr-10,ravi.gupta@xyz.com,
245281,Dheeraj,6-Dec-10,Dheeraj_Turupu@xyz.com,
257599,Venkata Maniteja,5-Dec-11,Venkat.alaga@xyz.com,

This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Split a field in awk script

Hi all, I have a field in the line, let's say argument $6, which is in the format 00.00 If i want to split the field to get rid of the "." in between of the amount, how can i do that i awk script? I have it like this split($6,a,".") but it will get rid of the last 2 digits after the... (4 Replies)
Discussion started by: CamTu
4 Replies

2. AIX

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (4 Replies)
Discussion started by: vasuarjula
4 Replies

3. Shell Programming and Scripting

display file where 4th field = 200704

Hello I have a file which is pipe delimited. The 4 th field has value like 200704 or 200705 etc. Now i have to get only those records where 4th field is 200704 How can i do this? I have to get the whole record where 4th field = 200704 (7 Replies)
Discussion started by: vasuarjula
7 Replies

4. Shell Programming and Scripting

Perl script to load text file into DB field

Hello, maybe this post is offtopic, sorry for the inconveniencies (maybe should be in the forum with questions about C, C++, Java, SQL...). I found examples about how to populate different fields from a text file (with MySQL, the LOAD DATA INFILE sentece), but not about how to load a complete... (2 Replies)
Discussion started by: aristegui
2 Replies

5. Shell Programming and Scripting

Split file based on field

Hi I have a large file 2.6 million records and I am trying to split the file based on last column. I am doing awk -F"|" '{ print > $NF }' filename1 After around 1000 splits it gives me a error awk: can't open file 3332332423 input record number 1068, file filename1 source... (6 Replies)
Discussion started by: s_adu
6 Replies

6. Shell Programming and Scripting

awk script to split field data

Hi Experts, I have a Input.txt document which contains data fields seperated by tabs. There are 4 fields totally Named UNIQUE, ORDER, CONTACT and WINS. The UNIQUE field contains unique ID and the CONTACT field contains data seperated by comma in some records. I am looking to write an awk script... (12 Replies)
Discussion started by: forumthreads
12 Replies

7. Shell Programming and Scripting

how to get split output of a file, using perl script

Hi, I have file: data.log.1 ### s1 main.build.3495 main.build.199 main.build.3408 ###s2 main.build.3495 main.build.3408 main.build.199 I want to read this file and store in two arrays in Perl. I have following command, which is working fine on command prompt. perl -n -e... (1 Reply)
Discussion started by: ashvini
1 Replies

8. Shell Programming and Scripting

Perl Split for text in file

Hi all I have written Perl script to swap the strings in the second a third column from a text file. My input file format is : the|empty|the|det lake|empty|lake|conj_and was|empty|was|auxpass drained|empty|drained|conj_and birds|empty|bird|s|nn The expected output file format is... (11 Replies)
Discussion started by: my_Perl
11 Replies

9. UNIX for Dummies Questions & Answers

Split a file into parts only if the first field is different

Hi, I have a file like this: aaa 123 aaa 223 aaa 225 bbb 332 bbb 423 bbb 6755 bbb 324 ccc 112 ccc 234 ccc 897 Which I need to split into several files, something like split -l 3 but the way that the lines with the same names would only go into one file: (7 Replies)
Discussion started by: coppuca
7 Replies

10. Shell Programming and Scripting

Modification of perl script to split a large file into chunks of 5000 chracters

I have a perl script which splits a large file into chunks.The script is given below use strict; use warnings; open (FH, "<monolingual.txt") or die "Could not open source file. $!"; my $i = 0; while (1) { my $chunk; print "process part $i\n"; open(OUT, ">part$i.log") or die "Could... (4 Replies)
Discussion started by: gimley
4 Replies
PACKAGE(1)                                                    General Commands Manual                                                   PACKAGE(1)

NAME
package - register package user via mailagent SYNOPSIS
package address system version patchlevel [ mailpatches | notifypatches ] DESCRIPTION
This command is not intended to be run directly by a user, but may appear in any mail whose subject is set to Command. Such mail will be processed by the mailagent(1), which will extract all lines beginning with @SH, which may specify this command. The mailagent first sets environment variables that will be used by the command. Package is used to notify the author of a package about its users. It is normally generated automatically by the MailAuthor.U unit when the user runs Configure. If the patchlevel specified is not the latest for that system and version, mail is immediately sent suggesting that they upgrade and remindng them how to request the latest patches. The final parameter, if included may be set to mailpatches to specify that the user would like to have future patches mailed to them, or notifypatches to specify that a mail notification of future patches should be sent, rather than the entire patch. The user's address and notification request are saved in the file users in the package's directory. Package performs an approximate address match in order to avoid duplicate entries. Whenever this elimination occurs, a warning message is issued in the logfile. Two addresses will be said equivalent if one of them has an added machine name or if they are really equal. There- fore, the following addresses are equivalent: ram@acri.fr ram@main.acri.fr whereas the following two are not equivalent, unfortunately: ram@acri.acri.fr ram@main.acri.fr When a user is asking to be left alone, it is important to let him know if the request failed, because he will be annoyed when the next set of patches is issued and he still gets them despite his previous request. Therefore, if no approximate match occurs, a warning message is sent back, with a list of addresses that are close to his own e-mail address, but not equivalent. Fortunately, the following addresses are considered close: ram@acri.fr ram@somewhere.com raphael@main.acri.fr manfredi@acri.acri.fr because they either have the same login (important when someone changes company) or share the same domain or sub-domain part. In order to edit the users file, the edusers script should be used. For one thing, it will let you edit the users file from whatever pack- age you name in the command line, but it will also properly lock the file so that the execution of package will stall for the duration of the manual edition (provided you have a strict locking policy defined in your ~/.mailagent configuration file). FORWARDING
Package supports command forwarding as described in the mailhelp(1) page. FILES
~/.mailagent configuration file for mailagent. System/users list of users of that system. This file consists of single line records, one for each registered user. Each record consists of three tab-separated fields. The first field indicates the level of updates requested by the user by a single letter as follows: M Mail future patches directly to the user when they are issued. N Notify the user of future patches. U The users chose to let the author know that they have tried the program, but does not wish to know about future updates. L The user is no longer interested in the program and wants to be left alone. The second field is their last notified patch level, or a dash (-) if it is not known. The third field is the user's Email address. Log/agentlog mailagent's log file AUTHORS
Graham Stoney <greyham@research.canon.oz.au> Raphael Manfredi <Raphael_Manfredi@pobox.com> (minor enhancements) SEE ALSO
edusers(1), mailagent(1), metaconfig(1). PACKAGE(1)
All times are GMT -4. The time now is 03:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy