Sponsored Content
Top Forums Shell Programming and Scripting Remove the file content based on the Header of the file Post 302681199 by itkamaraj on Friday 3rd of August 2012 02:15:17 AM
Old 08-03-2012
try this..

Code:
 
awk -F\| 'NR==1{for(i=1;i<=NF;i++)if($i~/DepId/)val=i}{for(i=1;i<=val-1;i++)printf("%s|",$i);print $val}' input.txt

This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Reading a file and sending mail based on content of the file

Hi Gurus, I am having an requirement. i have to read a list file which contains file names and send mail to different users based on the files in the list file. eg. if file a.txt exists then send a mail to a@a.com simillary for b.txt,c.txt etc. Thanks for your help, Nimu (6 Replies)
Discussion started by: nimu1979
6 Replies

2. Shell Programming and Scripting

Remove specific pattern header and its content problem facing

Input file: >TRACK: Position: 1 TYPE: 1 Pos: SVAVPQRHHPGGTVFREPIIIPAIPRLVPGWNKPIIIGRHAFGDQYRATDRVIPGPGKLE LVYTPVNGEPETVKVYDFQGGGIAQTQYNTDESIRGFAHASFQMALLKGLPLYMSTKNTI LKRYDGRFKDIFQEIYESTYQKDFEAKNLWYEHRLIDDMVAQMIKSEGGFVMALKNYDGD >TRACK: Position: 1 TYPE: 2 Pos: FAHASFQMALLKGLPLYMS... (8 Replies)
Discussion started by: patrick87
8 Replies

3. Shell Programming and Scripting

Help with rename header content based on reference file problem

I got long list of reference file >data_tmp_number_22 >data_tmp_number_12 >data_tmp_number_20 . . Input file: >sample_data_1 Math, 5, USA, tmp SDFEWRWERWERWRWER FSFDSFSDFSDGSDGSD >sample_data_2 Math, 15, UK, tmp FDSFSDFF >sample_data_3 Math, 50, USA, tmp ARQERREQR . . Desired... (7 Replies)
Discussion started by: perl_beginner
7 Replies

4. UNIX for Dummies Questions & Answers

Changing file content based on file header

Hi, I have several text files each containing some data as shown below: File1.txt >DataHeader Data... Data... File2.txt >DataHeader Data... Data... etc. What I want is to change the 'DataHeader' based on the file name. So the output should look like: File1.txt >File1 ... (1 Reply)
Discussion started by: Fahmida
1 Replies

5. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

6. Shell Programming and Scripting

Print the column content based on the header

i have a input of csv file as below but the sequence of column get changed. I,e it is not necessary that name comes first then age and rest all, it may vary. name,age,marks,roll,section kevin,25,80,456,A Satch,23,56,789,B Meena,24,78,H245,C So i want to print that column entires which... (12 Replies)
Discussion started by: millan
12 Replies

7. Shell Programming and Scripting

How to remove exisiting file content from a file and have to append new file content?

hi all, i had the below script x=`cat input.txt |wc -1` awk 'NR>1 && NR<'$x' ' input.txt > output.txt by using above script i am able to remove the head and tail part from the input file and able to append the output to the output.txt but if i run it for second time the output is... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

8. Shell Programming and Scripting

Split a file based on encountering header

I need to split a file based on headers found Input file file1 content: ADD john mickey DROP matt sam output of file F1 john mickey output of file F2 matt sam (5 Replies)
Discussion started by: Diddy
5 Replies

9. Shell Programming and Scripting

Find columns in a file based on header and print to new file

Hello, I have to fish out some specific columns from a file based on the header value. I have the list of columns I need in a different file. I thought I could read in the list of headers I need, # file with header names of required columns in required order headers_file=$2 # read contents... (11 Replies)
Discussion started by: LMHmedchem
11 Replies

10. Shell Programming and Scripting

How to create file and file content based existing information?

Hi Gurus, I am SQL developer and new unix user. I need to create some file and file content based on information in two files. I have one file contains basic information below file1 and another exception file file2. the rule is if "zone' and "cd" in file1 exists in file2, then file name is... (13 Replies)
Discussion started by: Torhong
13 Replies
Courriel::Part::Single(3pm)				User Contributed Perl Documentation			       Courriel::Part::Single(3pm)

NAME
Courriel::Part::Single - A part which does not contain other parts, only content VERSION
version 0.29 SYNOPSIS
my $headers = $part->headers(); my $ct = $part->content_type(); my $content = $part->content(); print ${$content}; DESCRIPTION
This class represents a single part that does not contain other parts, just content. API
This class provides the following methods: Courriel::Part::Single->new( ... ) This method creates a new part object. It accepts the following parameters: o content This can either be a string or a reference to a scalar. It should be in Perl's native utf-8 encoding and not a byte string. If you pass a reference, then the scalar underlying the reference may be modified, so don't pass in something you don't want modified. o encoded_content This can either be a string or a reference to a scalar. If you pass a reference, then the scalar underlying the reference may be modified, so don't pass in something you don't want modified. o content_type A Courriel::Header::ContentType object. This will default to one with the mime type "text/plain". o disposition A Courriel::Header::Disposition object representing this part's content disposition. This will default to "inline" with no other attributes. o encoding The Content-Transfer-Encoding for this part. This defaults to the value found in the part's headers, or "8bit" if no header is found. o headers A Courriel::Headers object containing headers for this part. You must pass a "content" or "encoded_content" value when creating a new part, but there's really no point in passing both. It is strongly recommended that you pass a "content" parameter and letting this module do the encoding for you internally. $part->content() This returns returns the decoded content for the part. It will be in Perl's native utf-8 encoding, decoded from whatever character set the content is in. $part->encoded_content() This returns returns the encoded content for the part. $part->mime_type() Returns the mime type for this part. $part->has_charset() Return true if the part has a charset defined. Binary attachments will usually not have this defined. $part->charset() Returns the charset for this part. $part->is_inline(), $part->is_attachment() These methods return boolean values based on the part's content disposition. $part->filename() Returns the filename from the part's content disposition, if any. $part->content_type() Returns the Courriel::Header::ContentType object for this part. $part->disposition() Returns the Courriel::Header::Disposition object for this part. $part->encoding() Returns the encoding for the part. $part->headers() Returns the Courriel::Headers object for this part. $part->is_multipart() Returns false. $part->container() Returns the Courriel or Courriel::Part::Multipart object to which this part belongs, if any. This is set when the part is added to another object. $part->content_ref() This returns returns a reference to a scalar containing the decoded content for the part. $part->encoded_content_ref() This returns returns a reference to a scalar containing the encoded content for the part, without any decoding. $part->as_string() Returns the part as a string, along with its headers. Lines will be terminated with " ". $part->stream_to( output => $output ) This method will send the stringified part to the specified output. The output can be a subroutine reference, a filehandle, or an object with a "print()" method. The output may be sent as a single string, as a list of strings, or via multiple calls to the output. See the "as_string()" method for documentation on the "charset" parameter. ROLES
This class does the "Courriel::Role::Part" and Courriel::Role::Streams roles. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.14.2 2012-03-07 Courriel::Part::Single(3pm)
All times are GMT -4. The time now is 04:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy