- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: I have created some document files with a ^M a...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 10:35 PM
03-10-2008 10:35 PM
I have created some document files with a ^M at the end of the file names ...
Yep, I'm an idiot. I uploaded a script to rename some document files on our HP UX box that were created in notepad, i forgot to do the dos2ux thing on them and as such each line ended with a ^M symbol.
The script worked, however it has done this...
apples.txt is now apples.txt.old^M
If i type 'view apples.txt.old' i am told by HP UX that there is no file by that name, which is correct.
If i type 'view apples.txt.old*' i can view the file happily and at the bottom of the VI viewer i am told that my file name is 'apples.txt.old^M'.
Here's my pickle... how the heck do I rename my files so that I can access them? I can work on them by being a bit careful with pattern matching but I would really like to rename these files (there's about a dozen of them) so that they can be accessed directly as needed.
Any advice?
Sorry for being such an idiot, i am normally so paranoid about checking this sort of thing but was being rushed last week and this got under the radar so to speak...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2008 10:47 PM
03-10-2008 10:47 PM
Re: I have created some document files with a ^M at the end of the file names ...
ls -b apples.txt.old*
I get a:
apples.txt.old\015
So there is an 'unprintable nonvisible' character appended to the file name.
I suppose what I need to do is work out how I can do a:
mv apples.txt.old\015 apples.txt.old
The above command doesn't work, is there a way i can do this?
If not, do i need to revert to the following?
cp apples.txt.old apples.txt.backup
rm -i apples.txt.old*
?? any help appreciated.
- Tags:
- unprintable chars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 12:51 AM
03-11-2008 12:51 AM
Re: I have created some document files with a ^M at the end of the file names ...
a 'mv apples.txt.old* apples.txt.old' should work.
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 01:08 AM
03-11-2008 01:08 AM
Re: I have created some document files with a ^M at the end of the file names ...
- Created files as you did
- Typed "cat apples.txt.old[Esc][Esc]" [Enter]
- Typed "mv apples.txt.old[Esc][Esc] apples.txt.old" [Enter]
* please set EDITOR=vi, before you type [Esc][Esc]
$ export EDITOR=vi
If you got a lot of files, then run the below script;
for xfile in *.txt.old*
do
tfile=`echo $xfile | awk -F. '{printf("%s%s%s",$1,FS,$2)}'`
tfile=${tfile}.old
echo "Rename file $xfile to $tfile"
mv $xfile $tfile
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 02:50 AM
03-11-2008 02:50 AM
Re: I have created some document files with a ^M at the end of the file names ...
strings apple.txt>apple.txt.1
and apple.txt1 is ur file.
Hope this help,
BR,
Kapil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 03:31 AM
03-11-2008 03:31 AM
Re: I have created some document files with a ^M at the end of the file names ...
Something like:
# perl -e 'foreach (<*>){ $old=$_; s/\r$//; rename $old,$_; print}"
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 03:59 AM
03-11-2008 03:59 AM
Re: I have created some document files with a ^M at the end of the file names ...
the easiest way maybe will be to run a windows client of any ftp software GUI and rename the file.
e.g. using Winscp (http://winscp.net/eng/download.php)
hope this helps too!
kind regards,
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 05:22 AM
03-11-2008 05:22 AM
Re: I have created some document files with a ^M at the end of the file names ...
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 05:29 AM
03-11-2008 05:29 AM
Re: I have created some document files with a ^M at the end of the file names ...
$> vi apples.txt.old*
And then in vi, just save the file
:w apples.txt.new
:q
$> ls apples.txt.*
And you'll see your new file.
To remove the old one:
$> rm -i apples.txt.old*
Say "y" to the one that is the old file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 05:35 AM
03-11-2008 05:35 AM
Re: I have created some document files with a ^M at the end of the file names ...
Use file name completion from a bash shell...
$> bash
$> mv apples.txt.o[esc esc] apples.txt.old
Another one:
Or, use visual mode from the shell (ksh)
$> mv apples.txt.old^V^M apples.txt.old
(that's ctrl-v,ctrlm)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 01:40 PM
03-11-2008 01:40 PM
Re: I have created some document files with a ^M at the end of the file names ...
All fixed, my files are now happy.
Much appreciated the very helpful responses I got and have allocated points accordingly :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2008 01:41 PM
03-11-2008 01:41 PM
Re: I have created some document files with a ^M at the end of the file names ...
:)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2008 11:16 PM
03-12-2008 11:16 PM
Re: I have created some document files with a ^M at the end of the file names ...
$> mv apples.txt.old^V^M apples.txt.old
I can't get this to work with ksh. I get control J for ^V^J, ^Venter or ^V^M.
Only with sh do I get control M for ^V^M and ^Venter.
The only easy way to get control M is to enter that ^V^M in vi.
>Volkmar: The easiest way - from my opinion - is to open the file manager
I'm not sure this is "easy" if you have more than a few of them. After one, two, three, many, you then write a script.
Which could be simple, ls the files into a file. Then for everyone with a ^M, strip the last char off:
for file in $(< list); do
filenew=${file%.}
mv $file $filenew
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2008 11:48 AM
03-20-2008 11:48 AM
Re: I have created some document files with a ^M at the end of the file names ...
That's funny, I created file just like that over here, and got it to work before posting.
I'm going to check to make sure I wasn't dreaming and that I was on a HPUX box running ksh...
Lessee here...
(re-running tests)
...
YUP.. works fine on my HPUX box...
$> uname -a
HP-UX xxxxxxxxx B.11.11 U 9000/800 xxxxxxxxx unlimited-user
$> echo $SHELL
/usr/bin/ksh
Could it be that your terminal def or tty settings get in your way? I've been doing the ctrl-v,ctrl-m trick on Unix boxes since 1929 (think Richard Pryor joke for that one).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2008 11:49 AM
03-20-2008 11:49 AM
Re: I have created some document files with a ^M at the end of the file names ...
Please excuse the crud in the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2008 12:02 PM
03-20-2008 12:02 PM
Re: I have created some document files with a ^M at the end of the file names ...
Very possible, except sh works.
>I've been doing the ctrl-v,ctrl-m trick
Sure in vi. I wouldn't usually use it in the shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:05 AM
03-21-2008 12:05 AM
Re: I have created some document files with a ^M at the end of the file names ...
There are two easiest way.
1). Open that file in vi as you told that you can able to open that file into the vi. and after that you can save this file to another name. Press Esc, after that press ":" then press "w" and file name whithout any space between w and file name. . .
2). cat apples.txt.old* > apples.txt.old
I think it works.
Regards,
Piyush Mathiya