- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Remove ^M character from file
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
01-12-2004 06:55 PM
01-12-2004 06:55 PM
I ftp'ed few files from my Windows machine to HP-UX machine. But, the *.ksh files contain
^M character. How can I get rid of the characters ? Is there a software that can be installed on UX box to convert all the files ?
Regards,
Nameesh.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 06:57 PM
01-12-2004 06:57 PM
Re: Remove ^M character from file
There's a Utility which is called dos2unix which is able to convert these Files.
regards
oliver
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 06:58 PM
01-12-2004 06:58 PM
Re: Remove ^M character from file
# dos2ux uncoverted_file > converted_file
There is a man page for this as well
# man dos2ux
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 07:01 PM
01-12-2004 07:01 PM
Re: Remove ^M character from file
Can you send me the link from where I can download the utility ?
Regards,
Nameesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 07:05 PM
01-12-2004 07:05 PM
Re: Remove ^M character from file
How else to find it:
# whereis dos2ux
# whence dos2ux
# find /usr -name dos2ux -print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 07:20 PM
01-12-2004 07:20 PM
Re: Remove ^M character from file
ftp hostname
user password
ascii
put ascii.txt
quit
Hope this helps,
Regards,
Peter Geluk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 07:20 PM
01-12-2004 07:20 PM
Re: Remove ^M character from file
Thnx for the input. But, the problem with the do2ux is that we need to copy the file into another file ie.,
dos2ux file1 > file2
file2 has got all the ^M character removed. So, need to perfomr one more step of copying file2 to file1 to have the original file with no ^M.
Please advice script for same.
Regards,
Nameesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 07:28 PM
01-12-2004 07:28 PM
Re: Remove ^M character from file
# dos2ux myfile >myfile
will convert the original file and not save a copy.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 08:17 PM
01-12-2004 08:17 PM
Re: Remove ^M character from file
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 08:58 PM
01-12-2004 08:58 PM
Re: Remove ^M character from file
When I do the operation as :
dos2ux file1 > file1
Size of "file1" becomes "0" and there is nothing in file1.
Regards,
Nameesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 09:36 PM
01-12-2004 09:36 PM
Re: Remove ^M character from file
dos2ux file1 > file2
sks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 09:36 PM
01-12-2004 09:36 PM
Re: Remove ^M character from file
vi /tmp/file1
:1,$s/
This replaces all special character(
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 09:47 PM
01-12-2004 09:47 PM
Re: Remove ^M character from file
Regards,
Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 09:54 PM
01-12-2004 09:54 PM
Re: Remove ^M character from file
yes, 'dos2ux file1 > file1' doesn't work proper.
Do 'dos2ux file1 > file2' and 'mv file2 file1' - tested ;-)
Volkmar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 09:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 10:03 PM
01-12-2004 10:03 PM
Re: Remove ^M character from file
Peter and Sanjay are right!!!
Sure, it is a text file and your problem just is that you transferred it in a type different than ASCII.
Anyway now you can use sed command to solve your problem, here like to do it by one command:
# sed 's/^M/ /'
I hope this helps you.
Best regards,
Ettore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 10:18 PM
01-12-2004 10:18 PM
Re: Remove ^M character from file
Michael:ouch.. the shell creates an outfile always before starting the command. So indeed the command saves nothing. ;-))
Otherwise ascii ftp or sed or use another outfile and then rename as already posted.
BTW: are the ^M allways at the end?
greetings,
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2004 10:35 PM
01-12-2004 10:35 PM
Re: Remove ^M character from file
you have 2 ways to get rid of this
1. open the file using vi
press
:1,$s/ctrl+v ctrl+M//
:wq (to save the file)
2. using sed
sed 's/^M//g'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2004 12:01 AM
01-13-2004 12:01 AM
Re: Remove ^M character from file
Thanx for the inputs. I wrote a script which I used to solve the problem :
dos2ux $1 > tmp
mv tmp $1
As suggested many of you, while ftp'g the file from the Windows box we can set "transfer type as ascii" and ^M character wouldn't be there.
Regards,
Nameesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2004 07:21 PM
01-13-2004 07:21 PM
Re: Remove ^M character from file
cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 03:45 AM
01-14-2004 03:45 AM
Re: Remove ^M character from file
You can find de program with:
# find . -name dos2ux -print
Groetjes.
Jos de Ruiter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2004 11:45 AM
01-14-2004 11:45 AM
Re: Remove ^M character from file
Their are many ways to do this. more than 3 that were shown. some better than others
The best way is to ftp the files correctly
OK here is MYLIST OF POSSIBLE solutions:
for arg in files*
do
strings $arg $arg.tmp
or
cat $arg |tr -d "\r" > $arg.tmp
or
dos2ux $arg > $arg.tmp
or
awk 'gsub(/\r$/,"")' $arg > $arg.tmp
or
sed 's/^M$//' $arg > $arg.tmp
# thats s/ctrl+v ctrl+M$//
mv $arg.tmp $arg
done
or
ed, ex and vi
for arg in files
do
echo "1,$ s/\r$//g\n.\nw\nq" |ed $arg
or
echo "1,$ s/\r$//g\nwq" |ex $arg
or
echo "^\1,$ s/\r$//g\nwq" |vi $arg
done
Some of the above deletes ^M at the end of line ignoring ^M that could be embeded in the middle (unlikely with text files)
to delete all ^M change \r$ to \r
Thanks that was fun!
Rory