- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Weird Characters In My 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
Discussions
Discussions
Discussions
Forums
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
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
тАО05-29-2006 08:22 PM
тАО05-29-2006 08:22 PM
I have some scripts gathering information and then reading smaller files together into one larger file using cat. The original files have some strange characters in them. You don't see them if you do a more of the file, but when you vi or cat it, these little things show up at in the middle of each line...
╬ж
Trouble is, I can't recreate that character on the command line, nor can i copy paste it into my terminal session. I was originally going to use sed to do a global find / replace and replace it with nothing, but i cant find it in the first place because its a weird character I assume.
Any ideas? thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2006 08:35 PM
тАО05-29-2006 08:35 PM
Re: Weird Characters In My File...
if you want to know what the weird characters are, you could dump the file into a blank file via xd. (See man xd)
That would give you the codes for your characters.
You can use the Cntrl-V combination to create the control characters:
To enter Cntrl-E,ESC
Press 'i' for insert
Ctrl-V,E,Ctrl-V,ESC
ESC to finish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2006 10:06 PM
тАО05-29-2006 10:06 PM
Re: Weird Characters In My File...
it's kind of like this <|> but more rounded and one character on it's own rather than the three i've used to represent it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2006 10:17 PM
тАО05-29-2006 10:17 PM
Re: Weird Characters In My File...
You noted that "The original files have some strange characters in them. You don't see them if you do a more of the file, but when you vi or cat it, these little things show up at in the middle of each line...".
Ig the "starnage" character includes a "^M" then you are seeing a carriage-return. This suggests that you FTP'd the file from a Windows platform in binary mode. If this is the case, you can filter the file with 'dos2ux':
# dos2ux filein > fileout
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2006 10:56 PM
тАО05-29-2006 10:56 PM
Re: Weird Characters In My File...
xd -xc my_file
you'll see the actual hex code displayed. Ten look at the man page for ASCII:
man ascii
As mentioned, if there is just a single special character at the end of each file, it will likely show up as ^M which is vi's way of displaying the carriage return character. This character is part of DOS/Windows PC files and must be removed using the proper option (for ASCII files) in ftp, namely the ascii command. Or you can remove the characters with the HP-UX command: dos2ux
dos2ux my_file > my_newfile
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2006 12:56 AM
тАО05-30-2006 12:56 AM
Re: Weird Characters In My File...
I take the large file, binary FTP it onto my laptop, then open it in Excel. The characters show up as ├Г┬й and a little square in excel.
In a vi of the files on HP-UX, they show as a little squiggly thing and a ^H respectively.
I tried running dos2ux just on the off chance, but this made no difference. I also tried the xd -xc filename but the characters showed up, but I'm not sure what to do from that point on?
At the moment my easiest solution is to open the file up in notepad on my laptop and do a replace all finding the character and replacing it with nothing.
I'd like to be able to strip these characters out somehow on the HP-UX box though, cuz then I can script this to be automated.
I don't want to have to do it in Windows because I will feel like I have been defeated...and microsoft has won :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2006 01:58 AM
тАО05-30-2006 01:58 AM
Re: Weird Characters In My File...
if your source system is unix you need to run "ux2dos" command to converting in dos format. I think you need to ftp in "ascii" mode also.
Enrico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2006 02:01 AM
тАО05-30-2006 02:01 AM
Re: Weird Characters In My File...
Example:
ux2dos file1 file2 > file3
to convert file 1 and file2 to dos format and put them in file3.
Enrico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2006 02:38 AM
тАО05-30-2006 02:38 AM
Solutiontr -cd "[ -~\012]" < infile > outfile
and then FTP your file in ASCII mode to convert LF to CRLF pairs that the PC wants.
The tr command will strip anything that is not a space through tilde " -~" or a LF (octal 012).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2006 06:27 PM
тАО05-30-2006 06:27 PM