Vous êtes sur la page 1sur 3

#!

/bin/bash
opera=`/usr/bin/date +%d`
if [ `expr $opera % 2` -eq 0 ]; then
dirb=!/b"san/ba"up/dbexport!
e#se
dirb=!/b"san/ba"up2/dbexport!
fi
e"ho !$rear dire"torio /%o#nas&/ba"up'`date +%d'%('%)` !
(dir /%o#nas&/ba"up'`date +%d'%('%)`
e"ho !$opiando *ire"torio de ba"up $dirb a /%o#nas&/ba"up'`date +%d'%('%)`!
"p -+ $dirb /%o#nas&/ba"up'`date +%d'%('%)`
[root,isis-re"audos'bo.'sh( /root/s"ripts]/0-00-12 # bash -x "opia'b'%o#nas&2sh
++ /usr/bin/date +%d
+ opera=/3
++ expr /3 % 2
+ 4[4 / -eq 0 4]4
+ dirb=/b"san/ba"up2/dbexport
++ date +%d'%('%)
+ e"ho 4$rear dire"torio /%o#nas&/ba"up'/3'00'/& 4
$rear dire"torio /%o#nas&/ba"up'/3'00'/&
++ date +%d'%('%)
+ (dir /%o#nas&/ba"up'/3'00'/&
++ date +%d'%('%)
+ e"ho 4$opiando *ire"torio de ba"up /b"san/ba"up2/dbexport a /%o#nas&/ba"up'/3'00'/&4
$opiando *ire"torio de ba"up /b"san/ba"up2/dbexport a /%o#nas&/ba"up'/3'00'/&
++ date +%d'%('%)
+ "p -+ /b"san/ba"up2/dbexport /%o#nas&/ba"up'/3'00'/&

5+6789:;<
=f ar.u(ents re(ain after option pro"essin.> and neither the
-" nor the -s option has been supp#ied> the first ar.u(ent
is assu(ed to be the na(e of a fi#e "ontainin. she## "o(-
(ands2 =f bash is in%oed in this fashion> $0 is set to the
na(e of the fi#e> and the positiona# para(eters are set to
the re(ainin. ar.u(ents2 ?ash reads and exe"utes "o((ands
fro( this fi#e> then exits2 ?ash4s exit status is the exit
status of the #ast "o((and exe"uted in the s"ript2 =f no
"o((ands are exe"uted> the exit status is 02 5n atte(pt is
first (ade to open the fi#e in the "urrent dire"tor)> and>
if no fi#e is found> then the she## sear"hes the dire"tories
in @5;A for the s"ript2
=:BC$5;=C:
5 #o.in she## is one Dhose first "hara"ter of ar.u(ent Eero
is a -> or one started Dith the --#o.in option2
5n intera"ti%e she## is one started Dithout non-option ar.u-
(ents and Dithout the -" option Dhose standard input and
error are both "onne"ted to ter(ina#s Fas deter(ined b)
isatt)FGHH> or one started Dith the -i option2 @</ is set
and $- in"#udes i if bash is intera"ti%e> a##oDin. a she##
s"ript or a startup fi#e to test this state2
;he fo##oDin. para.raphs des"ribe hoD bash exe"utes its
startup fi#es2 =f an) of the fi#es exist but "annot be
read> bash reports an error2 ;i#des are expanded in fi#e
na(es as des"ribed be#oD under ;i#de 9xpansion in the 9I@5:-
<=C: se"tion2
Jhen bash is in%oed as an intera"ti%e #o.in she##> or as a
non-intera"ti%e she## Dith the --#o.in option> it first
reads and exe"utes "o((ands fro( the fi#e /et"/profi#e> if
6:7 ?ash-G22 Kast "han.e- 200L <epte(ber 2M G
7ser $o((ands ?5<AF/H
that fi#e exists2 5fter readin. that fi#e> it #oos for
N/2bash'profi#e> N/2bash'#o.in> and N/2profi#e> in that
order> and reads and exe"utes "o((ands fro( the first one
that exists and is readab#e2 ;he --noprofi#e option (a) be
used Dhen the she## is started to inhibit this beha%ior2
Jhen a #o.in she## exits> bash reads and exe"utes "o((ands
fro( the fi#e N/2bash'#o.out> if it exists2
Jhen an intera"ti%e she## that is not a #o.in she## is
started> bash reads and exe"utes "o((ands fro( N/2bashr"> if
that fi#e exists2 ;his (a) be inhibited b) usin. the --nor"
option2 ;he --r"fi#e fi#e option Di## for"e bash to read
and exe"ute "o((ands fro( fi#e instead of N/2bashr"2
Jhen bash is started non-intera"ti%e#)> to run a she##
s"ript> for exa(p#e> it #oos for the %ariab#e ?5<A'9:B in
the en%iron(ent> expands its %a#ue if it appears there> and
uses the expanded %a#ue as the na(e of a fi#e to read and
exe"ute2 ?ash beha%es as if the fo##oDin. "o((and Dere exe- "uted-
if [ -n !$?5<A'9:B! ]; then 2 !$?5<A'9:B!; fi
but the %a#ue of the @5;A %ariab#e is not used to sear"h for
the fi#e na(e2
=f bash is in%oed Dith the na(e sh> it tries to (i(i" the
startup beha%ior of histori"a# %ersions of sh as "#ose#) as
possib#e> Dhi#e "onfor(in. to the @C<=I standard as De##2
Jhen in%oed as an intera"ti%e #o.in she##> or a non-
intera"ti%e she## Dith the --#o.in option> it first atte(pts
to read and exe"ute "o((ands fro( /et"/profi#e and N/2pro-
fi#e> in that order2 ;he --noprofi#e option (a) be used to
inhibit this beha%ior2 Jhen in%oed as an intera"ti%e she##
Dith the na(e sh> bash #oos for the %ariab#e 9:B> expands
its %a#ue if it is defined> and uses the expanded %a#ue as
the na(e of a fi#e to read and exe"ute2 <in"e a she##
in%oed as sh does not atte(pt to read and exe"ute "o((ands
fro( an) other startup fi#es> the --r"fi#e option has no
effe"t2 5 non-intera"ti%e she## in%oed Dith the na(e sh
does not atte(pt to read an) other startup fi#es2 Jhen
in%oed as sh> bash enters posix (ode after the startup
fi#es are read2
Jhen bash is started in posix (ode> as Dith the --posix "o(-
(and #ine option> it fo##oDs the @C<=I standard for startup
fi#es2 =n this (ode> intera"ti%e she##s expand the 9:B
%ariab#e and "o((ands are read and exe"uted fro( the fi#e
Dhose na(e is the expanded %a#ue2 :o other startup fi#es
are read2
?ash atte(pts to deter(ine Dhen it is bein. run b) the
re(ote she## dae(on> usua##) rshd2 =f bash deter(ines it is

Vous aimerez peut-être aussi