11-06-2011
extracting information from multiple files
Hello there,
I am trying to extract (string) information ( a list words) from 4 files and then put the results into 1 file. Currently I am doing this using grep -f list.txt file1 . and repeat the process for the other 3 files. The reasons i am doing that (a) I do know how to code (b) each file has a header that must be include with the string (c) I have to put the word and underneath it the results from 4 files and if there is no results from one and/or all I need to write a specific sentence like there is no results from file No. Below I will explain what I am trying to achieve.
(1) The list.txt
Gene1
Gene2
Gene3
(2) file1.txt
Chromosome Position Genes Mutation
1 251565465 Gene1 T/G
1 215465511 Gene3 G/A
(3) file 2.txt
Chromosome Position Genes Protein
1 251565471 Gene1 Damaged
1 215465614 Gene2 Pass
(4) file 3 and file 4.txt with different results
I want get the results file from the list.txt in a text as the format below
---
Gene1
(add a sentence) "From Mutation point of view" or file name
Chromosome Position Genes Mutation
1 251565465 Gene1 T/G
(add a sentence) "From Protein point of view" or file name
Chromosome Position Genes Protein
1 251565471 Gene1 Damaged
(add a sentence) "There was No results from file 3 and 4" or file name
(a gap, the follow the list with the next word)
Gene2
(add a sentence) "No resultsFrom Mutation point of view" or file name
(add a sentence) "From Protein point of view" or file name
Chromosome Position Genes Protein
1 215465614 Gene2 Pass
---
Any suggestions ?
I searched for grep for multiple files on the forum but it seems that perl will be needed and I am not an expert in coding.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hello All,
This is my first post on this forums, which I consider one of the best of its kind. The reason for my post is that I want to export some information form Nagios configuration files to a DB. I know that there are other tools available to do this, like NDO, monarch, etc... But I want to... (3 Replies)
Discussion started by: oconmx
3 Replies
2. UNIX for Advanced & Expert Users
i want to write a perl script that gets/displays all those files having multiple links (in current directory) (4 Replies)
Discussion started by: guptesanket
4 Replies
3. UNIX for Dummies Questions & Answers
hi everyone!
I already posted it in scripts, I'm sorry, it's doubled
I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is:
awk 'NR==FNR{a=$2; next}... (1 Reply)
Discussion started by: orcaja
1 Replies
4. Shell Programming and Scripting
hi everyone!
I'd like to extract a single column from 5 different files and put them together in an output file. I saw a similar question for 2 input files, and the line of code workd very well, the code is:
awk 'NR==FNR{a=$2; next} {print a, $2}' file1 file2
I added the file3, file4 and... (10 Replies)
Discussion started by: orcaja
10 Replies
5. Shell Programming and Scripting
Hello,
I am new to unix and need help with a problem. I have 2 files each containing multiple columns of information ie;
File 1 :
A B C D E
1 2 3 4 5
File 2 :
F G
6 7
I would like to merge the information from File 2 to File 1 so that the data reads as follows;
File 1:
A... (4 Replies)
Discussion started by: crunchie
4 Replies
6. Shell Programming and Scripting
Hi Everyone,
I'm really new to all this so I'm really hoping someone can help. I have a directory with ~1000 lists from which I want to extract lines from and write to new files. For simplicity lets say they are shopping lists and I want to write out the lines corresponding to apples to a new... (2 Replies)
Discussion started by: born2phase
2 Replies
7. Shell Programming and Scripting
consider the following is the contents of the file
cat 11.sql
drop procedure if exists hoop1 ;
Delimiter $$
CREATE PROCEDURE hoop1(id int)
BEGIN
END
$$
Delimiter ;
.
.
.
.
drop procedure if exists hoop2;
Delimiter $$
CREATE PROCEDURE hoop2(id int)
BEGIN
END
$$ (8 Replies)
Discussion started by: vivek d r
8 Replies
8. Shell Programming and Scripting
hi everyone,
im stuck in here with shell :) can you help me??
i have a directory with alot files (genbank files ... all ended in .gbk ) more than 1000 for sure ... and i want to read each one of them and search for some information and if i found the right one i save in new file with new... (6 Replies)
Discussion started by: andreia
6 Replies
9. Shell Programming and Scripting
Hi,
Can somebody help me?
I am testing a demo with the given function
PATH525="/uscms/home/emily/READme/extra/data/"
TEMP=temp
FileName=DataFileName
CopyFiles() {
# PATHNAME="$paths" ... (9 Replies)
Discussion started by: emily
9 Replies
10. Shell Programming and Scripting
Hey,
I have number of .tgz files and want to extract the file with the ending *results.txt from each one.
I have tried
for file in *.tgz; do tar --wildcards -zxf $file *results.txt; doneas well as
list=$(ls *.tgz)
for i in $list; do tar --wildcards -zxvf $i *.results.txt; done... (1 Reply)
Discussion started by: jfern
1 Replies
ucto(1) General Commands Manual ucto(1)
NAME
ucto - Unicode Tokenizer
SYNOPSYS
ucto [[options]] [input-file] [[output-file]]
DESCRIPTION
ucto ucto tokenizes text files: it separates words from punctuation, splits sentences (and optionally paragraphs), and finds paired quotes.
Ucto is preconfigured with tokenisation rules for several languages.
OPTIONS
-c configfile
read settings from a file
-d value
set debug mode to 'value'
-e value
set input encoding. (default UTF8)
-f
disable filtering of special characters
-L language
Automatically selects a configuration file by language code. e.g. 'fr' will select the file tokconfig-fr from the installation
directory
-l
Convert to all lowercase
-u
Convert to all uppercase
-n
Assume one sentence per line on input
-m
Emit one sentence per line on output
--passthru
Don't tokenize, but perform input decoding and simple token role detection
-P
Disable Paragraph Detection
-Q
Enable Quote Detection. (this is experimental and may lead to unexpected results)
-S
Disable Sentence Detection
-s <string>
Set End-of-sentence marker. (Default <utt>)
-V
Show version information
-v
set Verbose mode
-x <DocId>
Output FoLiA XML, use the specified Document ID. (this disables usage of most other options: -nulPQvsS)
-F
Read a FoLiA XML document, tokenize it, and output the modified doc. (this disables usage of most other options: -nulPQvsS)
BUGS
likely
AUTHORS
Maarten van Gompel proycon@anaproy.nl
Ko van der Sloot Timbl@uvt.nl
2011 november 28 ucto(1)