hi guys
i have this script
Doc_=/home/$USER/Documentos/*.odt || .doc
but in the code above, only .odt files are selected, all .doc none.
What is the error in the code?
thanks
hi guys
i have this script
Doc_=/home/$USER/Documentos/*.odt || .doc
but in the code above, only .odt files are selected, all .doc none.
What is the error in the code?
thanks
Try:
Doc_="home/$USER/Documentos/*.odt home/$USER/Documentos/*.doc"
But it will not work with file names with spaces and you need to call the variable without quotes...
This could help provided you don't have file extensions other than .doc and .odt for the below combination
Doc_="/home/$USER/Documentos/*.[od][do][tc]"
thanks for your time, it's works perfect
Note that the expansion is not done when the assignment is made, only when the variable is expanded (and not quoted). See the output of:
echo "$Doc_"
In ksh93 and bash with extglob set, you can use:
Doc_="+(*.doc|*.odt)"
Better might be to use an array (bash and ksh93):
Doc_=( +(*.doc|*.odt) )
printf "%s\n" "${Doc_[@]}"
I noticed that for some reason this works in bash but not in ksh93
$ Doc_=+(*.doc|*.odt)
$ ls $Doc_
ls: cannot access +(*.doc|*.odt): No such file or directory
$ ls +(*.doc|*.odt)
a.doc a.odt
$ ls @(*.doc|*.odt)
a.doc a.odt
It works without the variable and also when a variable contains regular globbing characters...
$ Doc_="*.doc *.odt"
$ ls $Doc_
a.doc a.odt
but there is any advantage over this code?
Doc_="/home/$USER/Documentos/*.[od][do][tc]" $Doc_
That will also match *.ooc, *.dot, etc..
i try this
Doc_="/home/$USER/Documentos/"*.doc *.odt"
but only first type of documents is devolved, in this case .doc files
�*.odt�: No such file or directory
probably is a restriction of my distro, i don't know
That line has unmatched quotes; it is not a complete command.
After filename expansion, this line:
Doc_="/home/$USER/Documentos/*.doc *.odt"
matches all .doc files in /home/$USER/Documentos/ and all .odt files in the current directory.
yes, i have an error on the quotes, but even correct quotes, the same occurs
Doc_="/home/$USER/Documentos/*.doc *.odt"
return: �*.odt�: No such file or directory
Of course it does. Re-read what I wrote.
Try this:
Doc_="/home/$USER/Documentos/*.doc /home/$USER/Documentos/*.odt"
#!/bin/bash
var="/path/*.{doc,odt}"
Doc_="/home/$USER/Documentos/*.doc /home/$USER/Documentos/*.odt"
yes it work's !! thanks for your patience, now i understand the reason of that occurs
if you permit another simple question, when i have a awk file (like example.awk), the header must be #!/bin/bash or #!/bin/awk -f ?
What is correct?
i really appreciate your help