I have a set of simple, one columned text files (in thousands).
file1:
a
b
c
d
file 2:
b
c
d
e
and so on. There is a collection of words in another file:
b d
b c d e
I have to find out the set of words (in each row) is present or absent in the given set of files. So, the output would be in matrix form (file*set) like:
1 0
1 1
I have the following code in bash, which is working well, but it involves very high computational cost with the increase of the file and set size. Any suggestion for better checking for the words is much appreciated.
My code segment:
Code:
#!/bin/sh
rm -f feat.txt
touch feat.txt
rm -f tem.txt
touch tem.txt
#read the rows of set file s.txt and put into seperate files
lables=1
while read myline
do
echo $myline > temp.txt
cat temp.txt|awk '{for (i=1;i<=NF;i++) print $i}'|sort|uniq > l$lables.txt
lables=`expr $lables + 1`
done < s.txt
p=`wc -l s.txt| awk '{print $1}'`
q=`expr $p - 1`
a=1
c=`expr $a + $q`
while [ $a -le $c ]
do
rm -f a.txt
touch a.txt
fileno=1
while [ $fileno -le 1000 ]
do
cat l$a.txt|fgrep -xvf $fileno.txt| awk '{printf ($1 " ")}' >> a.txt
echo >>a.txt
fileno=`expr $fileno + 1`
done
cat a.txt |awk '{if ($0 != NULL) print "0"; if ($0 == null) print "1"}'>c.txt
paste c.txt feat.txt > feat1.txt
cat feat1.txt >feat.txt
a=`expr $a + 1`
done
Thank you in advance
Last edited by vidyadhar85; 05-31-2009 at 10:45 AM..
Reason: code tag added
Hello,
I want an one line command that brings me back all the files in a folder that contain 4 specific words anywhere inside them.
I want to use find,xargs and grep. for example i know for one word the command would be:
find . | xargs grep 'Word1'
But i don't know for 4 specific words... (13 Replies)
Hi, everyone,
Let's say, we have
xxx.txt
A 1 2 3 4 5
C 1 2 3 4 5
E 1 2 3 4 5
yyy.txt
A 1 2 3 4 5
B 1 2 3 4 5
C 1 2 3 4 5
D 1 2 3 4 5
E 1 2 3 4 5
First I match the first column I find intersection (A,C, E), then I want to take those lines with ACE out from yyy.txt, like
A 1... (11 Replies)
Hi! I have a large set of pairs of text files (each pair in their own subdirectory) and each pair shares head/tail (a couple of first and last lines) but differs in the middle part. I need to delete the heads/tails and keep only the middle portions in which they differ. The lengths of heads/tails... (1 Reply)
Hi Friends,
I have been trying to write the script since morning and reached some where now. but i think i am stuck in the final step. please help
I want to search the strings below in red in the be be searched in the directories below. How can i do that in my shell script.
Thanks
Adi
... (8 Replies)
Hi All,
I am completely stuck here.
I have a set of files (with names A.txt, B.txt until L.txt) which contain words like these:
computer
random access memory
computer networking
mouse
terminal
windows
All the files from A.txt to L.txt have the same format i.e. complete words in... (2 Replies)
I have two (or more, to make it generic) csv files. Each line contains words separated by comma. None of words have any space. The number of words per line is not fixed. Some may have one, and some may have 12... The number of lines per file is also not fixed.
What I need is to find common words... (1 Reply)
Hi,
Need your help for this scripting issue I have. I am not really good at this, so seeking your help.
I have a file looking similar to this:
Hello, i am human and name=ABCD.
How are you?
Hello, i am human and name=PQRS.
I am good.
Hello, i am human and name=ABCD.
Good bye.
Hello, i... (12 Replies)
Hi,
I am looking for a shell script which serves the below purpose.
Please find below the algorithm for the same and any help on this would be highly appreciated.
1)set of strings need to be replaced among set of files(directory may contain different types of files)
2)It should search for... (10 Replies)
Hi
I have two files. One is a text file consisting of sentences i.e. INPUT.txt and the second file is SEARCH.txt consisting of two or three columns. I need help to write a script to search the second column of SEARCH.txt for each set of five words (blue color as set one and green color as set... (6 Replies)
Discussion started by: my_Perl
6 Replies
LEARN ABOUT DEBIAN
pofilespell
POFILESPELL(1)POFILESPELL(1)NAME
POFileSpell - checks the spelling in a collection of PO files
SYNOPSIS
POFileSpell [OPTION] [...] [FILE] [...]
INTRODUCTION
POFileSpell checks the spelling in a collection of PO files.
COMMAND LINE OPTIONS --help or -h
show usage instructions
--interactive or -i
interactive mode, iterate through the spelling errors using a text mode interface; see the Interactive Mode section
--overview or -o
generate an overview file, grouping by error and not by file
--dict=file or -d file
load a file with a list of words to consider correct; can be used multiple times
--batch-add=file
load a file with a list of words to add to the X-POFile-SpellExtra section of each of the target PO files; can be used multiple
times; when used, the actual spelling process is not run
--command=command
the command used for actually spell checking the text, by default aspell --encoding=utf-8 -l; if you want to use ispell, try
something like --comand="ispell -l" or --comand="iconv -t iso-8859-1 | ispell -l"
INTERACTIVE MODE
In interactive mode you iterate through each of the errors found. In each prompt you can press a to add the word to a file's
X-POFile-SpellExtra entry, n to ignore all further errors from this file, Enter to ignore this error or, if you are using one or more
dictionary files, the number of the file (1, 2, ...) to add the word to that dictionary file.
PO FILE HEADER DIRECTIVES
POFileSpell recognizes one PO file header directive. As with all gettext lint tools, this directive is prefixed with X-POFile.
X-POFile-SpellExtra: word
adds the word to the file's list of accepted words
DICTIONARY FILE FORMAT
Dictionary files are just lists of words, one on each line. For example:
word 1
word 2
word n
MORE INFORMATION
gettext-lint web page: http://gettext-lint.sourceforge.net/
AUTHOR
Pedro Morais.
<morais@kde.org>
08/16/2006 POFILESPELL(1)