Operating System - HP-UX
1846598 Members
1747 Online
110256 Solutions
New Discussion

Re: how to change the latest character of the filename from 0 --> ?

 
Ho_5
Advisor

how to change the latest character of the filename from 0 --> ?

Hi all,

I have a filename like:
2003-11-10_235900, but I want to translate it to 2003-11-10_235900?. The question is how??
I just want to change the latest character from 0 to ?

Thanks.

//john
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: how to change the latest character of the filename from 0 --> ?

john,

mv 2003-11-10_235900 "2003-11-10_235900?"


Pete

Pete
Mark Grant
Honored Contributor

Re: how to change the latest character of the filename from 0 --> ?

John,

It's a bad idea to have a "?" in your filename because "?" is a shell meta-character. This means that things like "ls *?*" won't give you the results you were expecting. Also, "rm 2003-11-10_23590?" would actually remove all files that begin with 2003-11-10_23590 and have one other character after them, not just the one file you meant.

Never preceed any demonstration with anything more predictive than "watch this"
Hoefnix
Honored Contributor

Re: how to change the latest character of the filename from 0 --> ?

you must exclude the ?
just use:
mv 2003-11-10_235900 2003-11-10_235900\?

the result will be
2003-11-10_235900?

Victor BERRIDGE
Honored Contributor

Re: how to change the latest character of the filename from 0 --> ?

mv 2003-11-10_235900 2003-11-10_23590\?

if you use ksh, make use of name competion then just replace the last char by \?

All the best
Victor