LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to write a batch file in linux?and what are batch(.bat) file benefits? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-write-a-batch-file-in-linux-and-what-are-batch-bat-file-benefits-4175425732/)

karthilin 09-05-2012 04:18 AM

how to write a batch file in linux?and what are batch(.bat) file benefits?
 
I read lot of forums and others but I cant understand clearly.I want clear and short answer.

whansard 09-05-2012 04:21 AM

read about shell scripts instead. that's the appropriate linux talk.

acid_kewpie 09-05-2012 04:22 AM

you might want to say please / thank you next time.

you don't use ".bat" files under Linux, that's a DOS convention. the equivalent under Linux would usually be a bash script file, which you can learn to write from reading the bash scripting howto and using the editor of your choice.

pixellany 09-05-2012 04:33 AM

Quote:

what are batch file benefits?
If we read "batch" (AKA "script") as a generic term covering various operating systems, then a very old truism applies:

"If you don't know why you need it, then you probably don't need it."

Please tell us what problem you are trying to solve---e.g. do you need to write (or modify) a script on an existing system?

chrism01 09-05-2012 04:34 AM

See these links
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/

acid_kewpie 09-05-2012 04:35 AM

Quote:

Originally Posted by pixellany (Post 4773108)
Please tell us what problem you are trying to solve---e.g. do you need to write (or modify) a script on an existing system?

A need to get homework in on time?

karthilin 10-15-2012 08:51 AM

Thank You!
 
Thanks For all

malekmustaq 10-15-2012 01:40 PM

Quote:

I want clear and short answer.
NO .bat in Unix.
NO .bat in Gnu.

In your mind are but windows without doors.

Habitual 10-15-2012 02:10 PM

Quote:

Originally Posted by karthinila (Post 4773093)
I read lot of forums and others but I cant understand clearly.I want clear and short answer.

Short Answer to your problem is there isn't one.

http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html
http://www.gnu.org/software/bash/man...ode/index.html
http://www.grymoire.com/Unix/Sh.html
http://tldp.org/LDP/abs/abs-guide.pdf
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
http://rute.2038bug.com/index.html.gz

You don't write "batch files" in Linux.
(for the sake of simplicity here), they are called shell scripts, or perhaps just scripts and have a usual .sh extension.

.bat files cannot run in linux (except in Wine?)
Linux shell scripts can be run in cygwin on Windows, but not as "batch files".

They mostly do the same thing, process and accept supplied commands to the host's command interpreter.
Both environments process their respective script.sh or file.bat one line at a time.

Both Windows' batch files and Linux's shell scripts can be manipulated to behave in the desired manner, although the commands to achieve that 'desired manner' may differ from Linux to Windows and vice versa.

Example.
a Windows batch file that has "cls" to clear screen ...would be in a Linux shell script as "clear"

It is my advice and belief that where you read is as important as what you read.
Start with http://rute.2038bug.com/index.html.gz

Have a Great Day!


All times are GMT -5. The time now is 10:58 AM.