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
1,6,62,6
7,7,52,24
3,145,25,69
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:
1:45
1:56
1:56
1:69
ccData_t.nnv
while read line; do
cut -f2 ccData_t.nnv >p
for i in $(line);
do
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
How to read line by line and loop through elements in bash ?
For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
Jump to
- House Training
- ↳ Beginners Help ( Start Here)
- ↳ Users ( For the regulars )
- ↳ Für deutschsprachige Anhänger
- ↳ Pour les francophones
- ↳ Usuarios de habla Hispana
- ↳ HOWTO ( Solutions )
- ↳ Bugs ( Submit bugs )
- Advanced Topics
- ↳ Additional Software (PETs, n' stuff)
- ↳ Package Collections / Repositories
- ↳ REQUESTS
- ↳ Browsers and Internet
- ↳ Business
- ↳ Compiling
- ↳ Desktop
- ↳ Documents
- ↳ Drivers
- ↳ Educational
- ↳ Engineering/Science/Simulation
- ↳ Eye Candy
- ↳ Filesystem
- ↳ Games
- ↳ Graphics
- ↳ Multimedia
- ↳ Network
- ↳ Security/Privacy
- ↳ System
- ↳ Utilities
- ↳ Virtualization
- ↳ Unsorted
- ↳ Cutting edge
- ↳ Multi-session live-CD/DVD
- ↳ Hardware
- ↳ Audio
- ↳ Networking
- ↳ Dialup
- ↳ Ethernet
- ↳ Wireless
- ↳ Printers
- ↳ Video
- ↳ Puppy Derivatives
- ↳ Puppy Projects
- ↳ Next Puppy Development
- ↳ 4.x
- ↳ Bugs (4.x dev)
- ↳ Usability Issues (4.x dev)
- ↳ 5.x
- ↳ Bugs (5.x dev)
- ↳ Usability Issues (5.x dev)
- ↳ Localization Project
- ↳ Documentation Project
- Taking the Puppy out for a walk
- ↳ Announcements
- ↳ Puppy Power
- ↳ Suggestions
- ↳ Misc
- Off-Topic Area
- ↳ Programming
- ↳ Security
- ↳ Truly off-topic conversations
- ↳ Spam reports