# Problems with escaped characters in file::stat

**URL:** <https://www.ruby-forum.com/t/problems-with-escaped-characters-in-file-stat/99264>\
**Category:** Ruby\
**Created:** [July 21, 2006, 11:00am UTC](https://www.ruby-forum.com/t/problems-with-escaped-characters-in-file-stat/99264 "2006-07-21T11:00:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tigerd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@tigerd](https://www.ruby-forum.com/u/tigerd)\
**Post date:** [July 21, 2006, 11:00am UTC](https://www.ruby-forum.com/t/problems-with-escaped-characters-in-file-stat/99264/1 "2006-07-21T11:00:46Z")

</div>

Hey.  
I hva got a really mindchrusher problem. I’ve made a program that  
somewhere goes through a list of files, picked with a tar command, and  
then collects the size and time of every single file/dirs. It goes  
something like this:

system(“tar --totals -cvf /dev/null -C #{@basedir} #{directory} \>  
#{@tempfile} 2\> /dev/null”)  
templist = File.new(tempfile)  
while file = templist.gets  
next if file == nil  
file = file.chop  
if file =~ /.\*?/$/  
stat\_d = File::Stat.new(File.join(TEMPDIR, file)) if  
(@mode[‘static’] == nil)  
stat\_d = File::Stat.new("#{@basedir}/#{file}") if  
(@mode[‘static’] != nil)  
end  
end

The problem now is that if a file has a special character, tar puts the  
filename like this

1. /…/path/bioligep\345.psd  
this file ruby cannot find, since the name in the unix-world is(its on  
a linux platfom)
2. /…/path/bioligep?.psd

My question is: Is there anyway I can translate the line no. 1 into  
line no 2? Ive looked at the File.fnmatch but havent really gotten  
anywere

Greeting, Allan

---

<div class="post-metadata">

**Author:** ![tigerd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@tigerd](https://www.ruby-forum.com/u/tigerd)\
**Post date:** [July 21, 2006, 11:32am UTC](https://www.ruby-forum.com/t/problems-with-escaped-characters-in-file-stat/99264/2 "2006-07-21T11:32:08Z")

</div>

ps. the ? is acutally a æ in the real world…but unix pukes on it…

---

<div class="post-metadata">

**Author:** ![tigerd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/73ab20/32.png) [@tigerd](https://www.ruby-forum.com/u/tigerd)\
**Post date:** [July 21, 2006, 4:05pm UTC](https://www.ruby-forum.com/t/problems-with-escaped-characters-in-file-stat/99264/3 "2006-07-21T16:05:48Z")

</div>

On Jul 21, 2006, at 5:00 AM, tigerd wrote:

> path/bioligep\345.psd

string\_to\_pass\_to\_stat = filename\_string.gsub(/\(\d{3})/){ $1.to\_i  
(8).chr }
