Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Selective case conversion of a file Post 302656847 by joeyg on Friday 15th of June 2012 01:24:29 PM
Old 06-15-2012
Confused...

Code:
$ cat sample16.txt
Sample: ABCdefgh
domain: when you think abcd@tester.com
domain: abcdefgh@tester2.com
Goods for purchase:234
domain: efgh@anyother.com
Sample: PQRST
Sample: nmjkl
Sample: 123jjkl Mer.
Goods for purchase: No ChaNGE

$ awk '{if($1=="Sample:") {print tolower($_)} else {print}}' <sample16.txt | sed 's/^sample:/Sample:/'
Sample: abcdefgh
domain: when you think abcd@tester.com
domain: abcdefgh@tester2.com
Goods for purchase:234
domain: efgh@anyother.com
Sample: pqrst
Sample: nmjkl
Sample: 123jjkl mer.
Goods for purchase: No ChaNGE

This User Gave Thanks to joeyg For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. UNIX for Dummies Questions & Answers

Selective, recursive file diddling!

Hello, I have been trying all sorts of combinations and been royally screwing up my filesystem in the process :rolleyes: I have a bunch of .wav files in a hierarchical album/artist etc folder structure and each has a duplicate .w4a file next to it. All I want to do is move all the .w4a... (7 Replies)
Discussion started by: dinalt
7 Replies

3. UNIX for Dummies Questions & Answers

To compare selective file in different folders

Hello, I am using dircmp -d <folde1> <Folder2> to compare the files from two different foldes, but this command compares for all the files. Is there any option to select only some files for comparision. For example in Folder1: file1.txt file2.txt file3.txt Folder2 file1.txt file2.txt... (0 Replies)
Discussion started by: gmahesh2k
0 Replies

4. Shell Programming and Scripting

Extract selective block from XML file

Hi, There's an xml file produced from a front-end tool as shown below: <INPUT DATABASE ="ORACLE" DBNAME ="UNIX" NAME ="FACT_TABLE" OWNERNAME ="DIPS"> <INPUTFIELD DATATYPE ="double" DEFAULTVALUE ="" DESCRIPTION ="" NAME ="STORE_KEY" PICTURETEXT ="" PORTTYPE ="INPUT" PRECISION ="15" SCALE... (6 Replies)
Discussion started by: dips_ag
6 Replies

5. Shell Programming and Scripting

Copy selective lines from text file

Hello, I have a text file which I need to check for presence of certain tags, and then copy a subsequent portion of text into another file. The tag matching canbe done with Grep but I do not know how to copy selective lines from one file to another. Is it possible do that? I checked up some... (8 Replies)
Discussion started by: ajayram
8 Replies

6. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

7. Shell Programming and Scripting

capturing selective data from a vcd file

Hi, This is a vcd file.A vcd file may have 'n' modules. 1) I need to capture the data in bold,i.e. the module names (shown in bold) 2) Also i need to capture the data inside each individual module,say for tst_bench_top ,i need to capture data from line 4 to line 20 ... I just want one... (2 Replies)
Discussion started by: veerabahu
2 Replies

8. Shell Programming and Scripting

How to output selective delimited data to a new file?

I have the following file which at times can be quite large so can be difficult to read, I need a script that just extracts particular delimited data and outputs to alternate file $cat fix1.log FIX4.4|0=12|55=LIT.L|48=123456|32=5|52=20111107-10:52:22.128|38=100|10=200| ... (6 Replies)
Discussion started by: Buddyluv
6 Replies

9. Shell Programming and Scripting

Case conversion within a command

Hi All, I need the variable to be set in both uppercase and lowercase in a single command DATABASE=ORCL something like the below which is absolutly wrong find /ora/admin/11.1.0/diag/rdbms/{print tolower($0)}${DATABASE}/{print toupper($0)}${DATABASE} The o/p should be as below:... (4 Replies)
Discussion started by: jjoy
4 Replies

10. Shell Programming and Scripting

Backup script with selective file types only

i am looking for a backup script to be run in ssh which can move all *.php files only to a archive Eg. a folder has 5 sub folders with different file types, which can be mix of PDF, jpeg, gif etc etc. but the archive generated should only include the *.php files without breaking the directory... (3 Replies)
Discussion started by: netatma
3 Replies
Algorithm::Numerical::Sample(3pm)			User Contributed Perl Documentation			 Algorithm::Numerical::Sample(3pm)

NAME
Algorithm::Numerical::Sample - Draw samples from a set SYNOPSIS
use Algorithm::Numerical::Sample qw /sample/; @sample = sample (-set => [1 .. 10000], -sample_size => 100); $sampler = Algorithm::Numerical::Sample::Stream -> new; while (<>) {$sampler -> data ($_)} $random_line = $sampler -> extract; DESCRIPTION
This package gives two methods to draw fair, random samples from a set. There is a procedural interface for the case the entire set is known, and an object oriented interface when the a set with unknown size has to be processed. A: "sample (set => ARRAYREF [,sample_size => EXPR])" The "sample" function takes a set and a sample size as arguments. If the sample size is omitted, a sample of 1 is taken. The keywords "set" and "sample_size" may be preceeded with an optional "-". The function returns the sample list, or a reference to the sample list, depending on the context. B: "Algorithm::Numerical::Sample::Stream" The class "Algorithm::Numerical::Sample::Stream" has the following methods: "new" This function returns an object of the "Algorithm::Numerical::Sample::Stream" class. It will take an optional argument of the form "sample_size => EXPR", where "EXPR" evaluates to the sample size to be taken. If this argument is missing, a sample of size 1 will be taken. The keyword "sample_size" may be preceeded by an optional dash. "data (LIST)" The method "data" takes a list of parameters which are elements of the set we are sampling. Any number of arguments can be given. "extract" This method will extract the sample from the object, and reset it to a fresh state, such that a sample of the same size but from a different set, can be taken. "extract" will return a list in list context, or the first element of the sample in scalar context. CORRECTNESS PROOFS
Algorithm A. Crucial to see that the "sample" algorithm is correct is the fact that when we sample "n" elements from a set of size "N" that the "t + 1"st element is choosen with probability "(n - m)/(N - t)", when already "m" elements have been choosen. We can immediately see that we will never pick too many elements (as the probability is 0 as soon as "n == m"), nor too few, as the probability will be 1 if we have "k" elements to choose from the remaining "k" elements, for some "k". For the proof that the sampling is unbiased, we refer to [3]. (Section 3.4.2, Exercise 3). Algorithm B. It is easy to see that the second algorithm returns the correct number of elements. For a sample of size "n", the first "n" elements go into the reservoir, and after that, the reservoir never grows or shrinks in size; elements only get replaced. A detailed proof of the fairness of the algorithm appears in [3]. (Section 3.4.2, Exercise 7). LITERATURE
Both algorithms are discussed by Knuth [3] (Section 3.4.2). The first algoritm, Selection sampling technique, was discovered by Fan, Muller and Rezucha [1], and independently by Jones [2]. The second algorithm, Reservoir sampling, is due to Waterman. REFERENCES
[1] C. T. Fan, M. E. Muller and I. Rezucha, J. Amer. Stat. Assoc. 57(1962), pp 387 - 402. [2] T. G. Jones, CACM 5(1962), pp 343. [3] D. E. Knuth: The Art of Computer Programming, Volume 2, Third edition. Reading: Addison-Wesley, 1997. ISBN: 0-201-89684-2. DEVELOPMENT
The current sources of this module are found on github, <git://github.com/Abigail/algorithm--numerical--sample.git>. AUTHOR
This package was written by Abigail, cpan@abigail.be. COPYRIGHT and LICENSE Copyright (C) 1998, 1999, 2009, Abigail. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. perl v5.10.1 2010-06-12 Algorithm::Numerical::Sample(3pm)
All times are GMT -4. The time now is 01:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy