Sponsored Content
Top Forums Shell Programming and Scripting Using filename to determine a prefix that needs to be added to string column on file? Post 302701005 by lrluis on Friday 14th of September 2012 02:20:27 PM
Old 09-14-2012
Using filename to determine a prefix that needs to be added to string column on file?

Possible filenames:

CDD_Whatever.txt
DDD_Whatever.txt

If the file prefix = CDD, I'd like to prefix every person ID (second column in my examples below) on the file with "c-"

If the file prefix = DDD, I'd like to prefix ever person ID with "d-"

Input:
Quote:
01|5284338|Person 1|SAT Mail|75
Desired Output:
Quote:
02|c-5284338|Person 1|SAT Mail|75
Any help would be appreciated

Last edited by lrluis; 09-14-2012 at 03:39 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remove filename prefix

I've got a bunch of files called oldabc, olddef etc. i want to copy these to be abc, def.... I can do this with file extensions....but can get the logic to work for prefixes. All the files I am interested in have a prefix of 'old'. This loop is no good for me....it looks at the content... (2 Replies)
Discussion started by: peter.herlihy
2 Replies

2. UNIX for Dummies Questions & Answers

Use same filename for prefix in the split command

I want to execute something like this: find . -type f -regex '$REGEX' -print | xargs split -d -C $SIZE The problem is that I want the name of the split files to be the same name as original files. So if my directory has two files called abc.txt and def.txt, then I want the split files to be... (1 Reply)
Discussion started by: namityadav
1 Replies

3. UNIX for Dummies Questions & Answers

How Can I Easily Determine If A File Has been Added to a Directory

I am uploading files that need to be processed prior to uploading. I will put the files in a directory. My question is how can I write an easy process to kick off a script once a file has been added? Is there an easy way to determine if a file has been added to a directory? Thanks (1 Reply)
Discussion started by: goodmis
1 Replies

4. UNIX for Advanced & Expert Users

How Can I Easily Determine If A File Has been Added to a Directory

I am uploading files that need to be processed prior to uploading. I will put the files in a directory. My question is how can I write an easy process to kick off a script once a file has been added? Is there an easy way to determine if a file has been added to a directory? Thanks (7 Replies)
Discussion started by: goodmis
7 Replies

5. Shell Programming and Scripting

Prefix a string to the contents of a file

Hi all, I have a requirement where in i have to create a temporary file by prefixing a string of special characters to each row of a input file. the input file is '|' delimited. here is the content of input file aaa|1234|axad|123 bbb|qwqw|qw|1334 the output should be ... (5 Replies)
Discussion started by: nvuradi
5 Replies

6. Shell Programming and Scripting

Execute command on first column (filename) retrieved from a file

Hi, I have a file abcd.txt which in turn contains 20 file names as column 1. Now I want to run a command "ct co -nc" / "cp" / "mv" on each of these $1 column content i.e. on each of the 20 file names. How can do this using a script so that I need not run the same command 20 times... (13 Replies)
Discussion started by: royzlife
13 Replies

7. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

8. UNIX for Dummies Questions & Answers

Add a new column to txt file containing filename

I would like help adding a new column to a large txt file (~10MB) that contains the filename. I have searched other posts but have not found an adequate solution. I need this extra column so I can concatenate >100 files and perform awk searches on this large file. My current txt file look... (4 Replies)
Discussion started by: kellywilliams
4 Replies

9. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

10. Shell Programming and Scripting

Prefix a variable in the first column of all the records of the files with and without header

In a bash shell, I have to prefix a variable to two .CSV files File1.CSV and File2.CSV. One of the files has a header and the other one is with no header in the below format: "value11","value12","value13","value14","value15","value16" "value21","value22","value23","value24","value25","value26"... (7 Replies)
Discussion started by: dhruuv369
7 Replies
Mail::SPF::Mech::MX(3)					User Contributed Perl Documentation				    Mail::SPF::Mech::MX(3)

NAME
Mail::SPF::Mech::MX - SPF record "mx" mechanism class DESCRIPTION
An object of class Mail::SPF::Mech::MX represents an SPF record mechanism of type "mx". Constructors The following constructors are provided: new(%options): returns Mail::SPF::Mech::MX Creates a new SPF record "mx" mechanism object. %options is a list of key/value pairs representing any of the following options: qualifier domain_spec ipv4_prefix_length ipv6_prefix_length See "new" in Mail::SPF::Mech. new_from_string($text, %options): returns Mail::SPF::Mech::MX; throws Mail::SPF::ENothingToParse, Mail::SPF::EInvalidMech Creates a new SPF record "mx" mechanism object by parsing the string and any options given. Class methods The following class methods are provided: default_qualifier default_ipv4_prefix_length default_ipv6_prefix_length qualifier_pattern See "Class methods" in Mail::SPF::Mech. name: returns string Returns 'mx'. name_pattern: returns Regexp Returns a regular expression that matches a mechanism name of 'mx'. Instance methods The following instance methods are provided: text qualifier params stringify domain match_in_domain See "Instance methods" in Mail::SPF::Mech. domain_spec: returns Mail::SPF::MacroString Returns the "domain-spec" parameter of the mechanism. ipv4_prefix_length: returns integer Returns the IPv4 network prefix length of the mechanism. ipv6_prefix_length: returns integer Returns the IPv6 network prefix length of the mechanism. match($server, $request): returns boolean Checks whether any MX hosts of the mechanism's target domain name (that is, any of the host addresses of its DNS "MX" records) matches the given request's IP address (see "ip_address" in Mail::SPF::Request), and returns true if it does, or false otherwise. The mechanism's IP network prefix lengths are respected when matching address records against the request's IP address. See RFC 4408, 5 and 5.4, for the exact algorithm used. SEE ALSO
Mail::SPF, Mail::SPF::Record, Mail::SPF::Term, Mail::SPF::Mech <http://tools.ietf.org/html/rfc4408> For availability, support, and license information, see the README file included with Mail::SPF. AUTHORS
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> perl v5.18.2 2017-10-06 Mail::SPF::Mech::MX(3)
All times are GMT -4. The time now is 06:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy