The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Operating Systems > HP-UX
.
google unix.com



HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Binary or ascii file u263066 Shell Programming and Scripting 6 08-08-2008 12:19 PM
How to convert English text file to ASCII File? laknar Shell Programming and Scripting 1 07-23-2008 10:37 AM
Hex characters of ascii file budrito HP-UX 2 08-10-2005 11:26 PM
ASCII file sherbet808 UNIX Desktop for Dummies Questions & Answers 1 06-13-2003 10:46 PM
How to determine if a file is ASCII? popo UNIX for Dummies Questions & Answers 11 02-05-2002 05:00 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-22-2008
gyanusoni gyanusoni is offline
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 7
how to read ascii file in HP-UX

Hello All,

I need to read the data inside one file who's format is ascii text. I got the file format when I use file command on the file.

file <filename>
filename ascii text

please help me on this.

Thanks
  #2 (permalink)  
Old 10-22-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,773
Code:
#!/bin/ksh
while read line
do
 echo "$line"
 echo "this line has ${#line} characters"
done < inputfilename
  #3 (permalink)  
Old 10-22-2008
gyanusoni gyanusoni is offline
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 7
Thanks for your quick response.

I tried the script and it gives me the the information line wise like how many character are there in each line but the contents are not in readable format.
it gives me below output

] M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?M-^?
this line has 26 characters
]@
this line has 2 characters
^P
  #4 (permalink)  
Old 10-22-2008
DustBunny DustBunny is offline
Registered User
  
 

Join Date: Oct 2008
Location: Earth!
Posts: 53
Quote:
Hello All,

I need to read the data inside one file who's format is ascii text. I got the file format when I use file command on the file.

file <filename>
filename ascii text

please help me on this.

Thanks
Actually, I am not sure about your requirement. Do you want a command to read ascii files on hpux?

If that's the case, you can do

# more <filename> - Read the file page by page.
# vi <filename> - Edit the file using vi editor (However, it shows the content)
# cat <filename> - Would print the content of a file.

I'm sorry if am talking something irrelevant to situation here since Jim has given a mini script. I wasnt sure, however, if you want to read the content of a file using a command the above should work.

-DB
  #5 (permalink)  
Old 10-22-2008
alamitab alamitab is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 25
dos2ux <filename>
  #6 (permalink)  
Old 10-22-2008
gyanusoni gyanusoni is offline
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 7
Hi DustBunny

Thanks for your reply Yes I want to read file which is in ascii format and then I tried more, cat commands to read but it gives me o/p which is not understandable below is the o/p

^B^B^A^B^B^B^B^B^B^B^B^A^G^B^B^B^A^G^B^A^B^B^A^B^B^B^A^B
^A^B^B^B^B^B^B^B^B^B^B^A^B^B^B^B^B^B^B^B^B^B^B^B^B^B
^A^B^A^B^G^B^B^B^B^B^B^B^A^B^B^B^B^B^B^B^B^B^B^B^B
^B^G^B^A^B^B^B^B^A^B^B^B^B^B^A^B^B^A^B^F^A^B^B^B^B^A^A^A^B
^B^B^A^B^A^B^B^A^B^B^B^B^B^A^B^G^B^B^A^B^A^B^B^B^B^B^B^B
^B^B^A^B^B^B^B^B^A^B^B^B^B^A^B^B^B^B^B^B^B^A^B^A^A^B^B^B
^B^B^B^B^B^B^A^A^A^B^B^B^B^B^B^B^B^A^B^A^B^B^B^B^B^T^B
^G^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^B^A^B^B^B^B^B^B


And the same response from dos2ux command.

I tried the strings command too it gave me the some o/p but not all it chop up the contents while displaying as it reduces the file size.

Last edited by gyanusoni; 10-22-2008 at 08:55 AM..
  #7 (permalink)  
Old 10-22-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
This is a case of "garbage-in....garbage-out". Your file really is mostly gibberish. These commands are showing you what's there.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0