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
MT_SRAND(3)								 1							       MT_SRAND(3)

mt_srand - Seed the better random number generator

SYNOPSIS
void mt_srand ([int $seed]) DESCRIPTION
Seeds the random number generator with $seed or with a random value if no $seed is given. Note There is no need to seed the random number generator with srand(3) or mt_srand(3) as this is done automatically. PARAMETERS
o $seed - An optional seed value RETURN VALUES
No value is returned. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.2.1 | | | | | | | The Mersenne Twister implementation in PHP now | | | uses a new seeding algorithm by Richard Wagner. | | | Identical seeds no longer produce the same | | | sequence of values they did in previous versions. | | | This behavior is not expected to change again, | | | but it is considered unsafe to rely upon it none- | | | theless. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 mt_srand(3) example <?php // seed with microseconds function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); } mt_srand(make_seed()); $randval = mt_rand(); ?> SEE ALSO
mt_rand(3), mt_getrandmax(3), srand(3). PHP Documentation Group MT_SRAND(3)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy