Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
|
12-16-2009, 01:38 AM
|
#16
|
LQ Newbie
Registered: Dec 2009
Posts: 14
Original Poster
Rep:
|
Code:
IFS=$'\n'; arr=( $( < arts1.tsv ) );
for ((i=0; i<$((${#arr[@]})); i++)); do
echo "${arr[$i]}" | tr "[[:space:]]" '\n' | grep -v '^$' | sort | uniq >> ar;
sed -i -e 's/^/ /;s/$/ /' ar;
while read line <&3; do
sed -i -e "s/[[:space:]]$line[[:space:]]/ /g" ar;
done 3<stopwords;
cat ar | sed "s/[[:space:]]//g" | grep -v '^$' > aar;
mv aar ar;
num="1";
while read line <&5; do
while read LINE <&4; do
if [ "$line" == "$LINE" ]; then
echo "$num" >> artres;
fi;
done 4<ar;
((num++));
done 5<word.tsv;
artarr[$i]=`cat artres`;
rm ar; rm artres;
done
aha, got it!!
|
|
|
12-16-2009, 01:40 AM
|
#17
|
LQ Newbie
Registered: Dec 2009
Posts: 14
Original Poster
Rep:
|
also another question... can i load this array into matlab? then i can make a matrix out of it maybe there... but how can i save this array ??? i know very little about coding in bash and stuff... maybe i can, can i?
|
|
|
12-16-2009, 01:42 AM
|
#18
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
and where are your input samples and output ? your shell script is badly written. A lot of redundant calls to external tools that do the same thing. your script is going to perform poorly on big data.
|
|
|
12-16-2009, 01:55 AM
|
#19
|
LQ Newbie
Registered: Dec 2009
Posts: 14
Original Poster
Rep:
|
yes i know. this is my first attempt at coding... by extrenal tools you mean ...? how can i fix them?
my data sample, arts1.txt is attached ; i cut it short. it didnt let me attach it in .tsv format. my code is still running, so i have no output yet.
Last edited by jayran; 12-16-2009 at 02:00 AM.
|
|
|
12-16-2009, 02:00 AM
|
#20
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by jayran
also another question... can i load this array into matlab? then i can make a matrix out of it maybe there..
|
i already told you , you can do all these in matlab. It will be the same procedure, opening of your file, loading the data into matlab arrays, doing your matrix manipulation and closing your files. All it takes is search and read the mathworks documents. or search google. here's one example to read/save files
|
|
|
12-16-2009, 02:04 AM
|
#21
|
LQ Newbie
Registered: Dec 2009
Posts: 14
Original Poster
Rep:
|
yes i was reading dlmread. I will try that tomorrow morning when i wake up.
Another question what did you mean by external tools?
thanks a loooot.
|
|
|
12-16-2009, 02:19 AM
|
#22
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by jayran
Another question what did you mean by external tools?
thanks a loooot.
|
those that are not built into the shell. eg awk, sed, grep, sort, uniq, cat, wc etc...
|
|
|
12-16-2009, 08:21 AM
|
#23
|
LQ Newbie
Registered: Dec 2009
Posts: 14
Original Poster
Rep:
|
good morning. so how can I avoid using those external tools? what would one use instead of sed...? or should i just try to limit my use of those?
|
|
|
All times are GMT -5. The time now is 08:14 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|