Sponsored Content
Top Forums Shell Programming and Scripting Cut wildcard characters from a string Post 302893201 by raokl on Tuesday 18th of March 2014 12:53:41 AM
Old 03-18-2014
Hello Lucas,

Thank you very much for your reply

I am sorry for the typo error, the requirement should have to be

string a = "test1.props,test2.props,*,test3.props,?,test4,props"

so in this i need to remove the wildcard characters and assign them as the below

string b = "*,?"

string c = "test1.props,test2.props,test3.props,test4.props"

your commands works great , but is there any way that for example if i have below

string a = "test1.props,test2.props,*,test3.props,?,test4.props,*,test5.props,?"


then i need the loop to exit the moment it finds the first wildcard character , so in this case

string b="*"

string c="test1.props,test2.props,test3.props,test4.props,test5.props"

because based on the string b i will write a conditional statement in my ANT to display error to user if string b = "*" or string b= "?"

and continue my ANT operation on the string c

Sing- Thank you for your response but i am getting the below error

a ="test1.props,test2.props,*,test3.props,?,test4.props,*,test5.props,?"
Code:
echo $a| awk 'gsub(/\*/,X) gsub(/\,Y) 1'
awk: gsub(/\*/,X) gsub(/\,Y) 1
awk:                    ^ unterminated regexp
awk: cmd. line:1: gsub(/\*/,X) gsub(/\,Y) 1
awk: cmd. line:1:                          ^ unexpected newline or end of string


Last edited by Scrutinizer; 03-18-2014 at 02:06 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. AIX

CUT command - cutting characters from end of string

Hello, I need to delete the final few characters from a parameter leaving just the first few. However, the characters which need to remain will not always be a string of the same length. For instance, the parameter will be passed as BN_HSBC_NTRS/hub_mth_ifce.sf. I only need the bit before the... (2 Replies)
Discussion started by: JWilliams
2 Replies

2. Shell Programming and Scripting

how to cut string with wildcard (sed)

i got text file and contain.... SKYPE Dec 11 09:26:05 IN=eth0 OUT=eth1 SRC=75.38.161.80 DST=192.168.1.56 PROTO=UDP SPT=30645 DPT=12630 LEN=66 SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0 SRC=192.168.1.56 DST=118.109.39.86 PROTO=UDP SPT=12630 DPT=15889 LEN=75 SKYPE Dec 11 09:26:05 IN=eth1 OUT=eth0... (2 Replies)
Discussion started by: slackman
2 Replies

3. Solaris

Problem in using wildcard characters in xargs with find

Hi, Under my parent diectory I have directory named "Response" in many of its subfolders. I am interested to see all files with extention .pro in Response Directory. I am giving following command - find . -name "Response" -type d | xargs -i ls -lrt {}/*.pro but it is not giving result. ... (3 Replies)
Discussion started by: sanjay1979
3 Replies

4. Shell Programming and Scripting

use sed do batch wildcard string replace

Hi, Here is what I want to do I want to search local directory and its sub directory, all the files which contain any string like _12345, then remove this string. String is a combination of _ plus a random integer number. For example, here is one line in a file before <properties... (1 Reply)
Discussion started by: bp5000
1 Replies

5. Shell Programming and Scripting

Find replace a particular string of data with wildcard

Hi I am having a csv file in which lots of data are available wherein i need to find a particular kind of data and replace it with null value. here is the sample data.. I need to find the string starting with 404-064- and up to the first space i have to remove the data and keep the... (4 Replies)
Discussion started by: aemunathan
4 Replies

6. Shell Programming and Scripting

sed delete wildcard within a string

Hi I would like to batch delete the "note" entry from bib files. The start would be defined by "note ={" and the end by "}." (see example bib entry below). I tried the following command which does not have any effect: cat input.bib| sed -e 's/note = {.*}.//' > output.bib Any help would... (2 Replies)
Discussion started by: gerggeismann
2 Replies

7. Shell Programming and Scripting

sed cut characters of string

helloo I wonder if there's a way to cut characters out of a string and keep only the last 2 by using sed. For example if there's the todays' date: 2012-05-06 and we only want to keep the last 2 characters which are the day. Is there a quick way to do it with sed? (2 Replies)
Discussion started by: vlm
2 Replies

8. Shell Programming and Scripting

Help Needed! - Cut characters after a text string and append to end of filename

Hi all.. I have several unique files that contain one thing in common, and that is acct#. For all files in the directory, I want to append the 10 characters following the word "ACCOUNT:" to the end of the filename. for example: I have file 111_123 that contains ACCOUNT:ABC1234567 The file... (5 Replies)
Discussion started by: cinderella1
5 Replies

9. Shell Programming and Scripting

Cut a string for last 8 characters

Hello All I have a file like this abc.tpt.ctl bdc.tpt.ctl cdw.tpt.ctl I have looped every line using the for Loop, now I want to take each line and cut the .tpt.ctl part of it and store it in a variable and use the variable in same loop. The part I am stuck at is how do I cut the last... (9 Replies)
Discussion started by: nnani
9 Replies

10. Shell Programming and Scripting

sed replace characters using a wildcard

Hello, I have some data that looks like the following, > <SALTDATA> (OVS0199262) HCl > <IDNUMBER> (OVS0199262) OVS0199262 > <SUPPLIER> (OVS0199262) TimTec > <EMAIL> (OVS0199262) info@timtec.net > <WEBSITE> (OVS0199262) http://www.timtec.net I need to remove the data in... (3 Replies)
Discussion started by: LMHmedchem
3 Replies
Prophet::Record(3pm)					User Contributed Perl Documentation				      Prophet::Record(3pm)

NAME
Prophet::Record DESCRIPTION
This class represents a base class for any record in a Prophet database. METHODS
new { handle => Prophet::Replica, type => $type } Instantiates a new, empty Prophet::Record of type $type. declared_props Returns a sorted list of the names of the record's declared properties. Declared properties are always validated even if the user provides no value for that prop. This can be used for such things as requiring records to have certain props in order to be created, for example. record_type Returns the record's type. register_reference $class, $accessor, $foreign_class, @args Registers a reference to a foreign class to this record. The foreign class must be of type Prophet::Collection or Prophet::Record, or else a fatal error is triggered. register_collection_reference $accessor, $collection_class, by => $key_in_model Registers and creates an accessor in the current class to the associated collection $collection_class, which refers to the current class by $key_in_model in the model class of $collection_class. register_record_reference $accessor, $record_class, by => $key_in_model Registers and creates an accessor in the current class to the associated record $record_class, which refers to the current class by $key_in_model in the model class of $collection_class. create { props => { %hash_of_kv_pairs } } Creates a new Prophet database record in your database. Sets the record's properties to the keys and values passed in. Automatically canonicalizes and then validates the props. Upon successful creation, returns the new record's "uuid". In case of failure, returns undef. load { uuid => $UUID } or { luid => $UUID } Given a UUID or LUID, look up the LUID or UUID (the opposite of what was given) in the database. Set this record's LUID and UUID attributes, and return the LUID or UUID (whichever wasn't given in the method call). Returns undef if the record doesn't exist in the database. set_prop { name => $name, value => $value } Updates the current record to set an individual property called $name to $value This is a convenience method around "set_props". set_props { props => { key1 => val1, key2 => val2} } Updates the current record to set all the keys contained in the "props" parameter to their associated values. Automatically canonicalizes and validates the props in question. In case of failure, returns false. On success, returns true. get_props Returns a hash of this record's properties as currently set in the database. exists When called on a loaded record, returns true if the record exists and false if it does not. prop $name Returns the current value of the property $name for this record. (This is a convenience method wrapped around "get_props"). delete_prop { name => $name } Deletes the current value for the property $name. (This is currently equivalent to setting the prop to ''.) delete Deletes this record from the database. (Note that it does _not_ purge historical versions of the record) changesets { limit => $int } Returns an ordered list of changeset objects for all changesets containing changes to the record specified by this record object. Note that changesets may include changes to other records. If a limit is specified, this routine will only return that many changesets, starting from the changeset containing the record's creation. changes Returns an ordered list of all the change objects that represent changes to the record specified by this record object. uniq @list The "List::MoreUtils::uniq" function (taken from version 0.21). Returns a new list by stripping duplicate values in @list. The order of elements in the returned list is the same as in @list. In scalar context, returns the number of unique elements in @list. my @x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 1 2 3 5 4 my $x = uniq 1, 1, 2, 2, 3, 5, 3, 4; # returns 5 validate_props $propsref Takes a reference to a props hash and validates each prop in the hash or in the "PROPERTIES" attribute that has a validation routine ("validate_prop_$prop"). Dies if any prop fails validation. Returns true on success. Returns false if any prop is not allowable (prop name fails validation). _validate_prop_name A hook to allow forcing users to only use certain prop names. Currently just returns true for all inputs. canonicalize_props $propsref Takes a hashref to a props hash and canonicalizes each one if a "canonicalize_prop_$prop" routine is available. Returns true on completion. default_props $props_ref Takes a reference to a hash of props and looks up the defaults for those props, if they exist (by way of "default_prop_$prop" routines). Sets the values of the props in the hash to the defaults. default_prop_creator Default the creator of every record to the changeset_creator (usually the current user's email address.) default_prop_original_replica Default the original_replica of every record to the replica's uuid. validate_prop_from_recommended_values 'prop', $argsref Checks to see if the given property has a valid value and returns true if so. If not, adds an error message to $argsref->{errors}{prop} and returns false. recommended_values_for_prop 'prop' Given a record property, return an array of the values that should usually be associated with this property. If a property doesn't have a specific range of values, undef is returned. This is mainly intended for use in prop validation (see validate_prop_from_recommended_values). Recommended values for a prop are set by defining methods called "_recommended_values_for_prop_$prop" in application modules that inherit from Prophet::Record. _default_summary_format A string of the default summary format for record types that do not define their own summary format. A summary format should consist of format_string,field pairs, separated by | characters. Fields that are not property names must start with the "$" character and be handled in the "atom_value" routine. Example: '%s,$luid | %s,summary | %s,status' _summary_format Tries to find the summary format for the record type. Returns _default_summary_format if nothing better can be found. _atomize_summary_format [$format] Splits a summary format into pieces (separated by arbitrary whitespace and the | character). Returns the split list. If no summary format is supplied, this routine attempts to find one by calling _summary_format. _parse_format_summary Parses the summary format for this record's type (or the default summary format if no type-specific format exists). Returns a list of hashrefs to hashes which contain the following keys: "format", "prop", "value", and "formatted" (These are the format string, the property to be formatted, the value of that property, and the atom formatted according to "format_atom", respectively.) If no format string is supplied in a given format atom, %s is used. If a format atom $value's value does not start with a "$" character, it is swapped with the value of the prop $value (or the string "(no value)". All values are filtered through the function "atom_value". format_summary Returns a formatted string that is the summary for the record. In an array context, returns a list of atom_value $value_in Takes an input value from a summary format atom and returns either its output value or itself (because it is a property and its value should be retrieved from the props attribute instead). For example, an input value of "$uuid" would return the record object's "uuid" field. format_atom $string => $value Takes a format string / value pair and returns a formatted string for printing. Dies with a message if there's an error in the format string that sprintf warn()s on. find_or_create_luid Finds the luid for the records uuid, or creates a new one. Returns the luid. history_as_string Returns this record's changesets as a single string. record_reference_methods Returns a list of method names that refer to other individual records collection_reference_methods Returns a list of method names that refer to collections perl v5.10.1 2010-01-03 Prophet::Record(3pm)
All times are GMT -4. The time now is 06:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy