executing a text file one line at a time with bash?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
executing a text file one line at a time with bash? (solved)
i'm trying right a bash script so i can read a text file one line at a time to executed it with a music editor i have. here is an example of part of the script( i'm new at this script stuff). what am i doing wrong?
number=0
until [ $number -ge 100 ]; do
transcribe $(head -n $number save.txt | tail -n 1)&
number=$((number + 1))
Last edited by mivison; 05-23-2009 at 03:06 PM.
Reason: solved
sorry about the lack of info. yes i do put do put "done" in there. what happens is i get an endless loop. it keeps executing the last line over and over again.
!/bin/bash
number=0
until [[ $number -ge 20 ]]; do
echo $number
number=$(($number + 1))
done
Could it have something to do with the "&" at the end of the transcribe statement?
if i don't use the "&", i have to execute them one at at a time by the pressing enter key. is there a way i could read how many lines are in the text file so i can put the sum in a variable?
yes i did and there seems to be a problem with that command on my eeepc. i am running puppy 4.20 on that netbook. i wonder what the problem could be?
Again, you need to tell us WHAT problem.....
I recommend doing some tests with individual commands to confirm that they behave as expected. As soon as you find an anomaly, post exactly what happens.
It sounds like you have a list of records in save.txt that you want automatically processed, without human interaction:
Code:
IFS="
" # ie put a single <return> in between the quotes
for rec in `cat save.txt` # backquotes, not single quotes
do
nohup transcribe $rec & # nohup plus & enables you to logout of this session without breaking it
done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.