Sponsored Content
Full Discussion: String copy
Top Forums Shell Programming and Scripting String copy Post 302507919 by mrpugster on Friday 25th of March 2011 06:47:24 AM
Old 03-25-2011
String copy

Hi guys

I've got two columns, PRODUCT and BRAND, the Brand column currently has the first word of each product, I've acheived this by using SED to copy the first word of the PRODUCT column, however you run into trouble when the brand has more than one word, i.e. 'Weight Watchers'.

Is there a way I can do a search for all the products that have 'Weight Watchers' in the title and then copy the string 'Weight Watchers' to the brand column?

Weight Watchers Apricot Jam Reduced Sugar Weight
All Natural Peanut Butter & Co Crunch Time All
Streamline Reduced Sugar Apricot Jam Streamline

Many thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy / string.

I'm trying to get a script to copy a url then put it in a different place in the file. Example is currently the script goes to a site takes the urls on it and then puts them into an html file. Only thing is I want to make them into links. So currently lynx goes to the page takes out the urls.... (6 Replies)
Discussion started by: Paulw0t
6 Replies

2. UNIX for Dummies Questions & Answers

Copy or Grep all text below a string

Hello, I am trying to copy all the text from a file below a search string... For example i want to grep all text below the word sure: UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! ... (2 Replies)
Discussion started by: aliaa2a
2 Replies

3. Shell Programming and Scripting

find a string and copy the string after that

Hi! just want to seek help on this: i have a file wherein i want to find a string and copy the string after that and paste that other string to a new file. ex: TOTAL 123456 find "TOTAL" and copy "123456" and paste "123456" to a new file NOTE: there are many "TOTAL" strings on that... (12 Replies)
Discussion started by: kingpeejay
12 Replies

4. Shell Programming and Scripting

how to copy one string in ksh into another

Hi Does anybody know if there is a utility/command in ksh which would allow to copy/insert the contents of one string into certain positions of the other? for example: A=" ABCDEF " B="HHH" I need to insert contents of string "B" into string "A" from position 3 to 5, so... (3 Replies)
Discussion started by: aoussenko
3 Replies

5. Shell Programming and Scripting

Copy-paste string automatically

Hi i'm not really sure if it's possible or not in bash. Basically I want to convert a ssh key created with ssh-keygen to putty format. The problem is that puttygen doesn't have an option for supplying passphrase in batch mode so it must be entered manually. For sskey generated with ssh-keygen i use... (2 Replies)
Discussion started by: ktm
2 Replies

6. Programming

String copy in C language

Hello, I have a text file (FILE.txt) that contains the following information: userAxxx.name@email.com userA userBxxx.name@email.com userB userxxCx.name@email.com userC and more.... in scripting, I can easily do a grep and awk to store an email info into a string... (6 Replies)
Discussion started by: tqlam
6 Replies

7. Shell Programming and Scripting

input a string and copy lines from a file with that string on it

i have a file1 with many lines. i have a script that will let me input a string. for example, APPLE. what i need to do is to copy all lines from file1 where i can find APPLE or any string that i specify and paste in on file 2 thanks in advance! (4 Replies)
Discussion started by: engr.jay
4 Replies

8. Shell Programming and Scripting

Help on Script of Copy String from column

Hello, My DATA: PLOKIJ1234G 12 13 14 15 PLOKIJ1234E 12 13 14 15 PLOKIJ1234F 12 22 33 44 IJNUHB12346 55 66 77 88 IJNUHB12347 32 34 45 67 IJUHU345D 23 23 22 33 IJUHYG23E 11 24 23 23 IJUHYG23F 77 88 99 00 output: PLOKIJ1234 PLOKIJ1234G 12 13 14 15 PLOKIJ1234... (11 Replies)
Discussion started by: asavaliya
11 Replies

9. Shell Programming and Scripting

Copy last third char form string

HI Input A.txt ABC907 ABC907_1B_9 ABC985 ABC985_1A_9 ABC985 ABC985_1B_9 ABC985 ABC985_1C_9 ABC05037 ABC05037_1A_9 ABC05037 ABC05037_1B_9 Base of column 2 last third char. If It is A the 1,if B then 2 If C then 3 File B.txt ABC907 ABC907_1B_9 2 ABC985 ABC985_1A_9 1 ABC985... (8 Replies)
Discussion started by: asavaliya
8 Replies

10. Shell Programming and Scripting

Copy a string to another file

OS version: RHEL 6.7 Shell : Bash I have a file like below. It has 500K lines. I want to extract TAG_IDs shown in single quote at the end to copied to another file. As if I had copied the TAG_IDs using block select (Column Select) in modern text editor $ cat file.txt UPDATE TAGREF SET... (9 Replies)
Discussion started by: John K
9 Replies
Algorithm::Dependency::Weight(3pm)			User Contributed Perl Documentation			Algorithm::Dependency::Weight(3pm)

NAME
Algorithm::Dependency::Weight - Calculate dependency 'weights' SYNOPSIS
# Create a source from a file my $Source = Algorithm::Dependency::Source->new( 'file.txt' ); # Create a Weight algorithm object my $alg = Algorithm::Dependency::Weight->new( source => $Source ); # Find the weight for a single item my $weight = $alg->weight('foo'); print "The weight of 'foo' is $weight "; # Or a group my $hash = $alg->weight_hash('foo', 'bar', 'baz'); print "The weight of 'foo', 'bar', and 'bar' are $hash->{foo}," . " $hash->{bar} and $hash->{baz} respectively "; # Or all of the items my $all = $alg->weight_all; print "The following is a list from heaviest to lightest: "; foreach ( sort { $all->{$b} <=> $all->{$a} } keys %$all ) { print "$_: $all->{$_} "; } DESCRIPTION
In dependency systems, it can often be very useful to calculate an aggregate or sum for one or all items. For example, to find the "naive install weight" of a Perl distribution (where "naive" means you treat each distribution equally), you would want the distribtion(1) + all its dependencies (n) + all their dependencies (n2) recursively downwards. If calculated using a normal Algorithm::Dependency object, the result would be (in a simple systems) equal to: # Create your normal (non-ordered alg:dep) my $dependency = Algorithm::Dependency->new( ... ); # Find the naive weight for an item my $weight = scalar($dependency->schedule('itemname')); "Algorithm::Dependency::Weight" provides a way of doing this with a little more sophistication, and in a way that should work reasonable well across all the Algorithm::Dependency family. Please note that the this might be a little (or more than a little) slower than it could be for the limited case of generating weights for all of the items at once in a dependency system with no selected items and no circular dependencies. BUT you can at least rely on this class to do the job properly regardless of the particulars of the situation, which is probably more important. METHODS new @params The "new" constructor creates a new "Algorithm::Dependency::Weight" object. It takes a number of key/value pairs as parameters (although at the present time only one). source => $Source The "source" param is mostly the same as for Algorithm::Dependency. The one addition is that as a source you can provide an Algorithm::Dependency object, and the Algorithm::Dependency::Source for that will be used. Returns a new "Algorithm::Dependency::Weight" object, or "undef" on error. source The "source" accessor returns the source used for the weight calculations. This will be either the one passed to the constructor, or the source from inside the "Algorithm::Dependency" object passed as the "source" param (not the object itself, its source). weight $name The "weight" method takes the name of a single item and calculates its weight based on the configuration of the "Algorithm::Dependency::Weight" object. Returns the weight as a scalar (which in the naive case will be an integer, but in more complex uses may be any real number), or "undef" on error. weight_merged @names The "weight_merged" method takes the name of a set of items and calculates an aggregated weight for the whole set. Returns the weight as a scalar, or "undef" on error. weight_hash @names The "weight_hash" method takes a list of item names, and calculates their weights. Returns a reference to a "HASH" with the item names as keys and weights as values, or "undef" on error. weight_all The "weight_all" method provides the one-shot method for getting the weights of all items at once. Please note that this does not do anything different or special, but is slightly faster than iterating yourself. Returns a reference to a "HASH" with the item names as keys and weights as values, or "undef" on error. TO DO
- Add support for non-naive weights via either custom code or method name SUPPORT
Bugs should be submitted via the CPAN bug tracker, located at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Dependency> For general comments, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
Algorithm::Dependency, Algorithm::Dependency::Source COPYRIGHT
Copyright 2003 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.12.4 2009-04-14 Algorithm::Dependency::Weight(3pm)
All times are GMT -4. The time now is 08:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy