Re: Wie kann ich einfach Dateinamen überprüfen

Marcus Röckrath <[email protected]>
Newsgroups spline.fli4l.geschnatter
Message-ID <[email protected]>
Hallo Nelson,

Marcus Röckrath wrote:

>> Da / auch im String vorkommt, nimm als Trenner was anderes, z. B.:
>> 
>>    -e s#[!"$'*/:;<>?@\´`^°|]#_#g
> 
> Hier könnte man auch tr bemühen:
> 
> tr "[]\!$*/:;<>?@^°|\"\`\´\'" "_"

oder mal positiver angehen, also nach Erlaubtem suchen und das durchlassen:

#!/bin/sh

input="$1"
output=""

for i in $(seq 0 $((${#input}-1)))
do
    if echo ${input:$i:1} | grep -Eq "[+-_.,#~(){}§%[:alnum:]]"
    then
        output=${output}${input:$i:1}
    else
        output=${output}"_"
    fi
done
echo ${input}
echo ${output}

-- 
Gruß Marcus
[eisfair-Team]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.