Bash for loop help please
hi everyone i want to use this command in for loop
sed 1d filename | sort -k9 -g | head -100
i am doing
#!/bin/bash
for i in `ls -v *.txt`
do
one=`sed 1d $i | sort -k9 -g|head -100`
echo $i $one >> hello.txt
done
it is giving me 100 lines from each files but each 100 lines are in one row. i want that script print 100 lines from each files and each line as separate line
please help
• 1,335 views
•
link
0 answers
No answers yet.
Log in to answer this question.
You are better off looking at unix forum sites for things like these. This question will likely be closed due to pure unix/bash context.
you can delete sorry for putting it here
You just need to add a newline character at the end of your
echocommand (this isn't tested as we haven't seen your input files, but I think it's right off the top of my head):i fixed it already but i really appreciate your positive reply
Hello Tark!
We believe that this post does not fit the main topic of this site.
This is a question on bash. Please ask a Unix forum.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
i agree with you ram i apologize. but this is the most efficient site so i thought to post as i was tired of figuring the problem on my own. see jrj.healey has replied very fast but fortunately i just was done otherwise i would have saved my hours with his help thank you jrj.healey
Not a problem at all, @Tark. It's my job as a moderator to ensure questions are relevant to bioinformatics. Closing a question has nothing to do against the creator, it's just part of that attempt towards a coherent forum.
i truly understand :)
Agree with the closing of the thread, I just like answering
bashquestions :), and this was an easy/quick one! But you are welcome in any event.