shell Frequently-Asked Questions
Le shell d'unix et de linux peut être plein de surprise. La présente FAQ correspond aux versions courrantes bourn shell, korn shell etbash.
Pour plus d'information au sujet de cette faq, contactez Jean-Louis BICQUELET
FAQ Revised: dimanche 08 septembre 2013 22:18:46
#!/bin/sh
HELP_=false
MAN_=false
while getopts hm o
do case $o in
h) HELP_=true;;
m) MAN_=true;;
[?]) print >&2 "Usage: $0 [-s] [-d seplist] file ..."
exit 1;;
esac
done
echo $HELP_
echo $MAN_
shift $OPTIND-1
echo $#
#!/bin/bash
var=0
LIMITE=10
while [ "$var" -lt "$LIMITE" ]
do
echo "$var "
var=`expr $var + 1`
done
if [ -f $outfile ]
then
echo "Output file [$outfile] already exists"
echo "Okay to overwrite? ( y/n ) : \c"
read answer
if [ "$answer" = "n" ] || [ "$answer" = "N" ]
then
echo "Aborting"
exit
fi
fi
a=`bc << quit
24544 / 1024
quit
`
printf "%-7s - %02d - %-10s - %-10s\n" 'STEP01' '01' `date +%d/%m/%Y` `date +%HH%MM%SS`
chaineZ=abcABC123ABCabc echo `expr index "$chaineZ" C12`
(d=`date +%y%m%d`;echo "machine_$d.nmon")
i
Pour un format year/nb of day since the beginning of the year
(d=`date +%Y%j`;n=`uname` -u;echo "`$n_$d.nmon")
printf "%s;" "$(date "+%Y/%m/%d %H:%M:%S")"
a=`perl -e "use Time::Local;print timelocal(0,10,9,13,8,2006);"`
perl -e "use Time::Local;print scalar localtime($a);"
,,__
.. .. / o._) .---.
/--'/--\ \-'|| .----. .' '.
/ \_/ / | .' '..' '-.
.'\ \__\ __.'.' .' ._
)\ | )\ | _.'
// \\ // \\
||_ \\|_ \\_
'--' '--'' '--'
#cal 6 2007
June 2007
Sun Mon Tue Wed Thu Fri Sat
1 2 22
3 4 5 6 7 8 9 23
10 11 12 13 14 15 16 24
17 18 19 20 21 22 23 25
24 25 26 27 28 29 30 26
ls -d */
% some-command `find . -name '*.c' -print`
if [ ! -f $FILE ]; then
echo "File \"$FILE\" does not exist."
exit $E_BADARGS
fi
for f in *.foo; do
base=`basename $f .foo`
mv $f $base.bar
done
ls -R | sed -e 's/://'
Utilisez exec avec une redirection vers un file descriptor (de 3 a 99), combinéeacute; avec read -unumber var.
cd ./-1701931229
rm -i list* rm: Remove list_cat? n rm: Remove list_? y rm: Remove list_quest? n
cat fichier
cat -s fichier
#cat -b script
1 #!/usr/bin/ksh -x
2 #
3 # Script
4 #
5 ## variables #################################################################
6 # Global Variables
7 log="/tmp/log"
a=56 perl -e "print `sin($a) * 3;" -1.56465300626074 cou encore
b=`perl -e "print `sin($a) * 3;"`
Copyright (c) 2004-2013 Jean-Louis BICQUELET
This list of questions and answers was generated by makefaq.