Sponsored Content
Top Forums Shell Programming and Scripting Request for file read option in Unix shell scripting Post 302526824 by ciupinet on Wednesday 1st of June 2011 01:57:57 PM
Old 06-01-2011
This one will do the job as well (assuming all the lines start with "Sample "):

Code:
sed "s|^Sample \(.*\)|Sample $(date +%m/%d/%Y) \1|g" a.txt > b.txt

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

2. Shell Programming and Scripting

why shell scripting takes more time to read a file

i have done a coding in shell scripting which reads a file line by line and does something....it takes more than 30 seconds to execute for a single file. when i do the same with perl scripting it takes less than a second. is that shell scripting is not efficient while working with large number of... (1 Reply)
Discussion started by: brkavi_in
1 Replies

3. AIX

Unix shell scripting to find latest file having timestamp embedded...

Hi guys, I have a directory in UNIX having files with the below format, i need to pickup the latest file having recent timestamp embedded on it, then need to rename it to a standard file name. Below is the file format: filename_yyyymmdd.csv, i need to pick the latest and move it with the... (2 Replies)
Discussion started by: kaushik25
2 Replies

4. UNIX for Dummies Questions & Answers

Unix Shell Scripting -- update employees not present in input file

ALL, My shell script takes a employee file as input. I have to identify the list of employees not in the input file and update their status in the database. Approach I followed: by traversing through the input file add all the emplid's to a variable. update the status of employees not in... (2 Replies)
Discussion started by: sailussr
2 Replies

5. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

6. Shell Programming and Scripting

generate tabular output from an input text file in unix shell scripting

Hi, I have the output (as below) which i want it to be in a table. For e.g. space utilization in PSE on path /logs is 0% space utilization in PSE on path /logs/tuxedo/tuxlsp is 16% space utilization in PSE on path /ldvarlsp/lsp/log is 37% space utilization in PSE on path /home is 6%... (7 Replies)
Discussion started by: pkbond
7 Replies

7. Shell Programming and Scripting

sh file: READ (menu) but now run with option

I have a script which uses READ to detect choice of menu option...now I want to change the script without doing whole rewrite such that when user runs ./script.sh 5 it would execute menu option 5 rather than user running ./script.sh waiting for it to load and then pressing "5 enter" Is it... (1 Reply)
Discussion started by: holyearth
1 Replies

8. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

9. Shell Programming and Scripting

UNIX Shell Scripting (Solaris) for File Checking

Hi guys, I'm sorry but i badly need your help. I am assigned to do a basic shell script in my job but sadly i don't have any idea on what it is because i am an electronics engineer, but i googled all of it, ask my friends but i cant finalize my scripts. so do please help me. The requirement... (47 Replies)
Discussion started by: daveaztig14
47 Replies

10. Shell Programming and Scripting

Read csv file, convert the data and make one text file in UNIX shell scripting

I have input data looks like this which is a part of a csv file 7,1265,76548,"0102:04" 8,1266,76545,"0112:04" I need to make the output data should look like this and the output data will be part of text file: 7|1265000 |7654899 |A| 8|12660000 |76545999 |B| The logic behind the... (6 Replies)
Discussion started by: RJG
6 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 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy