[wplug] *.bat files
David Ostroske
eksortso at linuxmail.org
Wed May 19 11:24:13 EDT 2004
On Tue, 2004-05-18 at 09:23, Embery, Nathan wrote:
> If you require that *your* shell be cded, then what you want is a function
[...]
> For ksh try this
>
> # function make_and_move_into_dir {
> > mkdir $1
> > cd $1
> > clear
> > ls
> > }
Here's the equivalent for the bash shell, which is standard on most
LInux distros. (I left out the line continuation ">" characters. They
only appear when you key in the function definition at the prompt.)
# In bash, the "function" word is optional, but the "()" is not.
function make_and_move_into_dir() {
mkdir $1
cd $1
clear
ls
}
(Don't know why the "ls" is there, since the directory is brand-new. But
what the heck.)
Then to run it, just type the function name at the prompt (you can use
TAB to auto-complete it) and give it a directory name, like "mynewdir"
for instance.
$ make_and_move_into_dir mynewdir
I would put this function definition in ~/.bashrc, and make certain that
~/.bash_profile sources ~/.bashrc as well. (Red Hat and Fedora have this
set up by default.) If all this is done, then you should be able to
invoke make_and_move_into_dir (or whatever you decide to call it) from
any interactive bash shell.
Maybe too much info, but too much is always better than not enough!
> Nate
--
David Ostroske <eksortso at linuxmail.org>
> -----Original Message-----
> From: Weber, Larry A [mailto:laweber at switch.com]
> Sent: Tuesday, May 18, 2004 8:55 AM
> To: 'General user list'
> Subject: RE: [wplug] *.bat files
>
> Tried this batch file and found that it created a new directory and cleared
> the terminal. Would not cd to the new directory????
>
> > -----Original Message-----
> > From: wplug-bounces+laweber=switch.com at wplug.org
> > [SMTP:wplug-bounces+laweber=switch.com at wplug.org] On Behalf Of Jason Carr
> > Sent: Tuesday, May 18, 2004 8:06 AM
> > To: 'General user list'
> > Subject: RE: [wplug] *.bat files
> >
> > 1. Create a file called 'test.sh' and edit that file.
> > 2. The first line should say #!/bin/sh
> > 3. Put the rest of the commands on their own lines
> > 4. The result should be as follows:
> >
> > #!/bin/sh
> > mkdir newfile
> > cd newfile
> > clear
> >
> > The #!/bin/sh is which shell interpreter is used so you may need to change
> > that depending on which Linux distro you use.
> >
> > 5. To make it executable, type chmod u+x test.sh
> > 6. Now you can type /home/jason/test.sh (or where ever it might be.
> >
> > Any more questions, feel free to ask :)
> >
> > - Jason
> >
> >
> > -----Original Message-----
> > From: wplug-bounces+jason=flacid.org at wplug.org
> > [mailto:wplug-bounces+jason=flacid.org at wplug.org] On Behalf Of Amjed Ben
> > Salah
> > Sent: Tuesday, May 18, 2004 7:59 AM
> > To: wplug at wplug.org
> > Subject: [wplug] *.bat files
> >
> > Hello,
> > can someone tell me how to create files in linux like *.bat files in
> > MSDOS?
> > for example I want to create a program who does this:
> >
> > 1 $> mkdir newfile
> > 2 $>cd newfile
> > 3 $>clear
> >
> > regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://penguin.wplug.org/pipermail/wplug/attachments/20040519/01aa014b/attachment-0001.html
More information about the wplug
mailing list