Perl program for find one entry and put in different file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl program for find one entry and put in different file
# 15  
Old 05-04-2012
ok thanks kamraj
I got it now but its not coming as output file separately with all IDs and I cant copy all Uniprot IDs from Unix shell..

And, Video wasn't working in my system I checked now on my iPAD so here it is code tag..thanks for reply

Code:
$ perl -lane 'print $F[-1] if $_=~/UniProt ID/' Uniprot

---------- Post updated at 02:33 AM ---------- Previous update was at 02:31 AM ----------

And, I was planning to do this in perl script in perl file is it possible?
# 16  
Old 05-04-2012
redirect the output to another file

Code:
perl -lane 'print $F[-1] if $_=~/UniProt ID/' input.txt  > output.txt

read basics about the perl ( search in google )
# 17  
Old 05-04-2012
The output file is still blank file without any output

Code:
perl -lane 'print $F[-1] if $_=~/UniProt ID/' input.txt  > output.txt

# 18  
Old 05-04-2012
As per the below code

1) your input file name is test.txt
2) your output file name is output.txt

When you are saying "its not working", "no output", etc....

Always post the command which you tried.

Code:
 
$ cat test.txt 
TTDS00001 Antagonist GSK233705 DCL000823
TTDS00001 Antagonist NVA237 DCL000901
TTDS00001 Antagonist Org-23366 DCL000911
TTDS00001 Antagonist OrM3 DCL000913
TTDS00001 Multitarget Org-23366 DCL000911
TTDS00001 Antagonist Aprophen DNC000245
TTDS00001 Antagonist Benactyzine DNC000293
TTDS00001 Antagonist Hyoscine DNC000757
TTDS00001 Antagonist Hyoscyamine sulfate DNC000758
TTDS00001 Antagonist Ipratropium bromide DNC000806
TTDS00001 Agonist Muscarine DNC000970
TTDS00001 Agonist RS 86 DNC001236
TTDS00001 Target Validation TTDS00001
TTDS00002 UniProt ID P11229
TTDS00002 Name Muscarinic acetylcholine receptor M1
TTDS00002 Type of target Successful target
TTDS00002 Synonyms M1 receptor
TTDS00002 Disease Alzheimer's disease
TTDS00002 Disease Bronchospasm (histamine induced)
TTDS00002 Disease Cognitive deficits
TTDS00002 Disease Schizophrenia
TTDS00002 Function The muscarinic acetylcholine receptor mediates various cellular responses, including inhibition of adenylate cyclase.................. so on for TTD 03/04/..14447

$ perl -lane 'print $F[-1] if $_=~/UniProt ID/' test.txt > output.txt
 
$ cat output.txt 
P11229

# 19  
Old 05-04-2012
Okk now I got the Results..Indeed so many thanks for u...

actually I was not writing star before input and after output file name
now i changed file name as input Uniprot and output Uniprot2 I got results.

Code:
bash-3.2$  perl -lane 'print $F[-1] if $_=~/UniProt ID/' * Uniprot> Uniprot2*

So may thanks once again...now I cant print here whole because if I will run gain it says Uniprot2 ambiguous redirect.. so but I got results
# 20  
Old 05-04-2012
Answer my questions.

1) What is your input file name ? ( is it multiple files or only one file )
2) What should be your outputfile name ?
# 21  
Old 05-04-2012
Request to check

Hi

My Input file name is Uniprot(I changed it it was test earlier)

My output file name is Uniprot2 (all list of Uniprot IDs)

My input file is single file.. I have got results many thankd for that

Now I have to compare 2 files which means 2 files with common entries in same column and separate those common entries in a diferent file as well right before those entries common so that I can separat common and Uncommon entries in rows in 2 different files. Is it possible

For eg.

one file
Code:
name1   1    2 
name2    3   4
name3     5   6

second file
Code:
name1   1    2
name2    3   4
name6     8    9

output file
Code:
name1   1    2 common
name2    3   4  common
name6     8    9  not common

Moderator's Comments:
Mod Comment Also code tags for samples please

Last edited by Scrutinizer; 05-04-2012 at 06:36 AM.. Reason: extra code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to find a garbage entry in a column wise text file in Linux?

Suppose I have a file containing :- 1 Apple $50 2 Orange $30 3 Banana $10 4 Guava $25 5 Pine@apple $12 6 Strawberry $21 7 Grapes $12 In the 5th row, @ character inserted. I want through sort command or by any other way this row should either on top or bottom. By sort command garbage... (1 Reply)
Discussion started by: Dipankar Mitra
1 Replies

2. Shell Programming and Scripting

remove brackets and put it in a column and remove repeated entry

Hi all, I want to remove the remove bracket sign ( ) and put in the separate column I also want to remove the repeated entry like in first row in below input (PA156) is repeated ESR1 (PA156) leflunomide (PA450192) (PA156) leflunomide (PA450192) CHST3 (PA26503) docetaxel... (2 Replies)
Discussion started by: manigrover
2 Replies

3. UNIX for Dummies Questions & Answers

Statement to find if an entry exists in a file

I need to check if an entry input by the user is in a file. If so, I need to run a command, and if it does not exist then it should output entry does not exist. So I have so far... echo "Enter record:" read record //command || //command Can I use an if statement to do this? (3 Replies)
Discussion started by: itech4814
3 Replies

4. Shell Programming and Scripting

How to find the matched numbers between 2 text file using perl program??

hi dudes, I nee you kind assistance, I have to find the matched numbers from 2 text files and output of matched numbers should be in another text file.. I do have text files like this , for example File 1 787 665*5-p 5454 545-p 445-p 5454*-p File 2 5455 787 445-p 4356 2445 144 ... (3 Replies)
Discussion started by: sureshraj
3 Replies

5. Shell Programming and Scripting

Find similar entry in a .txt file acting as a database.

May i know how do i go along finding similar entry in a .txt file, which is used a as a "database" and post and error saying the entry existed when we key in the entry. ---------- Post updated at 05:18 PM ---------- Previous update was at 05:16 PM ---------- i mean post an error saying the... (5 Replies)
Discussion started by: santonio
5 Replies

6. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

7. Shell Programming and Scripting

find function name in a program file

Hello All, Is there any way to find a function name in a program file using perl. for example, there is a file called Test.C in that . . void function1(..) { <some code> } int function2(..) { . . sam() /*RA abc100*/ ... .. .. xyz()/*RA abc201*/ .. (8 Replies)
Discussion started by: Parthiban
8 Replies

8. UNIX for Dummies Questions & Answers

Program to find palindrome from a file

hello i came up with this ..The problematic part that i am facing is in underline and bold format. exec<file while read line do set $line i=1 while do str=$i #problematic i want the positional parameter but here it takes integer value. p=1 q=`expr length $str` flag=1... (6 Replies)
Discussion started by: salman4u
6 Replies

9. Shell Programming and Scripting

Perl find::file can I sort the out put

Perl file::find can I sort the out put I am using file::find in my script but how I wish to process each file found in date order. Can I sort this module? eg part of current script is.... use File::Find; # Recursively find all files and directories in $mqueue_directory find(\&wanted,... (2 Replies)
Discussion started by: Andrek
2 Replies

10. Shell Programming and Scripting

Adding entry into crontab in ksh program

Hi falks, I have the following ksh function ,which adding entry to crontab during ksh program running: { print "Go\c" >/dev/null 2>&1 print '0 0 * * * su - ias -c "/home/orca/core-${SCHEMA_NAME}/CLI/cleanup_BRMS.ksh"\c' >/dev/null 2>&1 print "\033:wq!" >/dev/null 2>&1 } | \crontab -e... (2 Replies)
Discussion started by: nir_s
2 Replies
Login or Register to Ask a Question