Re: Help with a Bash script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am 08.04.2010 17:06, schrieb Michael Thompson:

Hi!

> I'm quite new to Bash scripting, and just need a little pointer on how
> to go through a file, and execute commands there in until the end of the
> file is reached.

Well, if your list of commands already is a script, then including it 
would be the most convenient method.

Let's say your list is called "script" then

. <path_to_script>

would do it...

In other case here is a small executor script which reads your file line 
by line and executes it:

#!/bin/bash
# file: executor
while read line; do
	echo Executing: "$line"
	eval "$line"
done < "$1"

If you start the executor with your file as the first parameter, it will 
execute the lines one by one.

# ./executor script

-- 
bye
Adalbert
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux