Sponsored Content
Top Forums Shell Programming and Scripting How to remove the lines from file using perl Post 302201764 by radoulov on Tuesday 3rd of June 2008 05:43:59 AM
Old 06-03-2008
Quote:
Originally Posted by dipakg
Hi radoulov,

Thanks for your reply it worked but after some time it goes wrong or may be it worked wrong way...

What I did is
perl -ane'print unless $_{$F[-1]}++' YES.txt

As I manually does the analysis to find the seeds I get the result 71 seeds but by this command it gives only 21.
[...]
Please post more sampe data and the desired output using code tags
HTML Code:
[code]your text[/code]
What's the expected output given your first sample?
Is the below output the one you expect?

Code:
$ cat file
187 TAL_SPI_CORRECT_REQ_OUT seed : 894328066;
187 TAL_SPI_NO_OF_BYTES_OUT seed : 894328066;
30445 TAL_SPI_MASTER_NO_MORE_DATA_OUT seed : 894328066;
352 TAL_SPI_MASTER_APPLY_COMMAND_OUT seed : 894328066;
944 TAL_SPI_MASTER_DATA_OUT seed : 894328066;
935 TAL_SPI_MASTER_ADDR_OUT seed : 894328066;
1 a_dsync100_no_wr_dsync_ucode_exec_nike seed : 1072076501;
1 a_dsync100_no_wr_dsync_ucode_exec_ath1 seed : 1805353229;
1 a_dsync100_no_wr_dsync_ucode_exec_ath0 seed : 1805353229;
1 a_dsync100_no_wr_dsync_ucode_exec_capt seed : 1805353229;
2 a_dsync_lcm_xm2_output seed : 894328066;
1 a_dsync_pulse_gen_to_rcsdi_clkgen seed : 894328066;
1 a_dsyncEnWrite_to_rcsdi_clkgen seed : 894328066;
3 a_extsynth_buf_en_ch1 seed : 1072076501;
3 a_extsynth_buf_en_ch0 seed : 1072076501;
3 a_extTrig2_width_ch1 seed : 1617187839;
2 a_extTrig1_width_ch1 seed : 1617187839;
$ perl -ane'print unless $_{$F[-1]}++' file
187 TAL_SPI_CORRECT_REQ_OUT seed : 894328066;
1 a_dsync100_no_wr_dsync_ucode_exec_nike seed : 1072076501;
1 a_dsync100_no_wr_dsync_ucode_exec_ath1 seed : 1805353229;
3 a_extTrig2_width_ch1 seed : 1617187839;


Last edited by radoulov; 06-03-2008 at 06:49 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

remove specific lines from flat file using perl

Hi, Here is wat im looking for.. i have a flat file which looks like this.. 00 * * * * .. .. * * text text text COL1 COL2 ----- ----- 1 a (12 Replies)
Discussion started by: meghana
12 Replies

2. Shell Programming and Scripting

How to remove the specific lines from file using perl

Can anyone tell me what could be the solution to following : I have one .txt file which contains some "seed" information. This seed may appear multiple time in the file so what I want do is if this seed appears again in the file then that line should be removed. Please provide the script code... (4 Replies)
Discussion started by: dipakg
4 Replies

3. UNIX for Advanced & Expert Users

Remove lines using perl

Hi, Using the egrep ,i can exclude header and trailer records in file.I want to do in perl.Please help egrep -iv 'head|trail' filename Thanks in advance MR (6 Replies)
Discussion started by: mohan705
6 Replies

4. Shell Programming and Scripting

perl or awk remove empty lines when condition

Hi Everyone, # cat 1 a b b cc 1 2 3 3 3 4 55 5 a b (2 Replies)
Discussion started by: jimmy_y
2 Replies

5. Shell Programming and Scripting

Command to remove duplicate lines with perl,sed,awk

Input: hello hello hello hello monkey donkey hello hello drink dance drink Output should be: hello hello monkey donkey drink dance (9 Replies)
Discussion started by: cola
9 Replies

6. Shell Programming and Scripting

perl/shell need help to remove duplicate lines from files

Dear All, I have multiple files having number of records, consist of more than 10 columns some column values are duplicate and i want to remove these duplicate values from these files. Duplicate values may come in different files.... all files laying in single directory.. Need help to... (3 Replies)
Discussion started by: arvindng
3 Replies

7. Shell Programming and Scripting

Need to remove first 6 lines and last line in a array ---- perl scripting

Hi I have stored a command output in an array like below @a = `xyz`; actually xyz comnad will give the output like this tracker date xxxxxxx xxxxxxx --------------------- 1 a 2 b ---------------------- i have stored the "xyz" output to an... (3 Replies)
Discussion started by: siva kumar
3 Replies

8. Shell Programming and Scripting

Using sed, awk or perl to remove substring of all lines except the first

Greetings All, I would like to find all occurences of a pattern and delete a substring from the all matching lines EXCEPT the first. For example: 1234::group:user1,user2,user3,blah1,blah2,blah3 2222::othergroup:user9,user8 4444::othergroup2:user3,blah,blah,user1 1234::group3:user5,user1 ... (11 Replies)
Discussion started by: jacksolm
11 Replies

9. UNIX for Dummies Questions & Answers

Want to remove all lines but not latest 50 lines from a file

Hi, I have a huge file which has Lacs of lines. File system got full. I want your guys help to suggest me a solution so that I can remove all lines from that file but not last 50,000 lines. I want solution which can remove lines from existing file so that I can have some space left with. (28 Replies)
Discussion started by: prashant2507198
28 Replies

10. Shell Programming and Scripting

Remove lines that are subsets of other lines in File

Hello everyone, Although it seems easy, I've been stuck with this problem for a moment now and I can't figure out a way to get it done. My problem is the following: I have a file where each line is a sequence of IP addresses, example : 10.0.0.1 10.0.0.2 10.0.0.5 10.0.0.1 10.0.0.2... (5 Replies)
Discussion started by: MisterJellyBean
5 Replies
rand(3C)						   Standard C Library Functions 						  rand(3C)

NAME
rand, srand, rand_r - simple random-number generator SYNOPSIS
#include <stdlib.h> int rand(void); void srand(unsigned int seed); int rand_r(unsigned int *seed); DESCRIPTION
The rand() function uses a multiplicative congruential random-number generator with period 2^32 that returns successive pseudo-random num- bers in the range of 0 to RAND_MAX (defined in <stdlib.h>). The srand() function uses the argument seed as a seed for a new sequence of pseudo-random numbers to be returned by subsequent calls to rand(). If srand() is then called with the same seed value, the sequence of pseudo-random numbers will be repeated. If rand() is called before any calls to srand() have been made, the same sequence will be generated as when srand() is first called with a seed value of 1. The rand_r() function has the same functionality as rand() except that a pointer to a seed seed must be supplied by the caller. If rand_r() is called with the same initial value for the object pointed to by seed and that object is not modified between successive calls to rand_r(), the same sequence as that produced by calls to rand() will be generated. The rand() and srand() functions provide per-process pseudo-random streams shared by all threads. The same effect can be achieved if all threads call rand_r() with a pointer to the same seed object. The rand_r() function allows a thread to generate a private pseudo-random stream by having the seed object be private to the thread. USAGE
The spectral properties of rand() are limited. The drand48(3C) function provides a better, more elaborate random-number generator. When compiling multithreaded applications, the _REENTRANT flag must be defined on the compile line. This flag should be used only in mul- tithreaded applications. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
drand48(3C), attributes(5), standards(5) SunOS 5.11 19 May 2004 rand(3C)
All times are GMT -4. The time now is 09:12 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy