Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 03 Mar 2015, 11:10
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
How to read line by line and loop through elements in bash ?
Post_new_topic   Topic_locked View_previous_topic :: View_next_topic
Page 1 of 1 Posts_count_1  
Author Message

Joined: 11 Jun 2012
Posts: 2

PostPosted: Mon 11 Jun 2012, 22:51    Post_subject:  How to read line by line and loop through elements in bash ?  

0 down vote favorite
share [g+] share [fb] share [tw]

I need help reading a txt file line by line, and then looping through each element in bash script. After hitting a element I need to cut the # of the column represented by the current numerical element, and then assign it to a file. In the end I need to paste all these files together. The columns are in a separate file. The first txt file reads as such




Then for example I need to cut column 5 in a separate file, and then assign to a new file. One the line is done the process starts again.This process would be easy in python or java, but I'm just very new to bash script.

This is a sample column:





while read line; do
cut -f2 ccData_t.nnv >p
for i in $(line);


cut -fi+1 ccData_t.nnv |sed "s/^/"i":/" >ti
echo paste p t1 t2 t3 t4 |grep -v pro >svm_train_model1.tsv
done < FILE

In the end I have to have all columns appended together as such.

1:45 6:45 62:45

1:56 6:34 62:23

1:56 6:32 62:52

1:69 6:12 62:123
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 1 Posts_count_1  
Post_new_topic   Topic_locked View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0339s ][ Queries: 11 (0.0029s) ][ GZIP on ]