J'arrive a remplacer les espaces par des retour chariots en mode interactif en insérant un vrai retour chariot apres le \ d'échappement, mais visiblement il ne le comprend pas de la même manière en script...
Quelqu'un a une idée ? Je vous mets la tronche de mon script.
#!/bin/bash
#wordfreq : displays word frequencies in a given file and can give the frequency of one particular word as well
#usage : wordfreq filename [word]
#variable init
fileNotFoundError=1
syntaxError=1
fileToParse=
filter=
#as usual we check the options given
if [ $# = 0 ]
then
syntaxError=0
fi
#we know we have the right number of arguments, let's check whether the file exists or not
if [ ! -e 1ドル ]
then
fileNotFoundError=0
else
fileToParse=1ドル
if [ $# = 2 ]
then
filter=" grep "${2}
fi
fi
#let's handle the errors
if [ $syntaxError = 0 ]
then
echo Syntax error.
echo usage : wordfreq filename [word]
exit 1
else
if [ $fileNotFoundError = 0 ]
then
echo Error, the specified file was not found.
exit 1
fi
fi
#we build the command
command="cat "${fileToParse}" | sed 's/ /\
/g' | uniq -c"${filter}" | awk '{print \2,ドル \1ドル}'"
echo $command
[^] # Re: Hmm
Posté par David FRANCOIS . En réponse au message Encore.... Évalué à 1.
#!/bin/bash #wordfreq : displays word frequencies in a given file and can give the frequency of one particular word as well #usage : wordfreq filename [word] #variable init fileNotFoundError=1 syntaxError=1 fileToParse= filter= #as usual we check the options given if [ $# = 0 ] then syntaxError=0 fi #we know we have the right number of arguments, let's check whether the file exists or not if [ ! -e 1ドル ] then fileNotFoundError=0 else fileToParse=1ドル if [ $# = 2 ] then filter=" grep "${2} fi fi #let's handle the errors if [ $syntaxError = 0 ] then echo Syntax error. echo usage : wordfreq filename [word] exit 1 else if [ $fileNotFoundError = 0 ] then echo Error, the specified file was not found. exit 1 fi fi #we build the command command="cat "${fileToParse}" | sed 's/ /\ /g' | uniq -c"${filter}" | awk '{print \2,ドル \1ドル}'" echo $command