The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remove first column of a space delimited txt ajp7701 Shell Programming and Scripting 1 04-18-2008 01:10 PM
remove space characters melanie_pfefer Shell Programming and Scripting 1 03-11-2008 10:45 AM
remove space in front or end of each field happyv Shell Programming and Scripting 6 03-21-2007 11:05 PM
string remove gundu Shell Programming and Scripting 1 03-16-2005 04:08 PM
remove files with 0 size, space and double qoute nongrad Shell Programming and Scripting 3 02-08-2002 12:32 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-26-2008
Registered User
 

Join Date: Jul 2006
Posts: 3
Unhappy Remove unregconized space from a string

Hi,

I need to unload some data from Informix database into text file.
But what happen is when i open the text file, some record split into 2 line, become uncomplete.
I had checked is due to some unregconized space in particular fields, i used many way to detect this unregconized space, but failed, because it is not null, not blank, not space, trim() also cannot help.
here is sample of the record in text file:

1337851|^M\
KAMPUNG SUNGAI SAMAK|
10000|NO 3 PRSN KLEDANG 12|

the 2nd column contain some funny character ^M, then direct goto 2nd line.

Need your guys help urgently.
Thanks

Regards
Eelyn
Reply With Quote
Forum Sponsor
  #2  
Old 02-27-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Put your sample record in a text file and enter this command:

Code:
od -t oC -An input_file
Each number represents the exact octal code of every character in the file, so you can determine which is the "blank" char.

You may also try:

Code:
od -t a input_file
In this manner you have a more readable visualization which could help you identifying the character in the previous output.
Reply With Quote
  #3  
Old 02-28-2008
Registered User
 

Join Date: Jul 2006
Posts: 3
Hi Robotronic,

Thanks a lot for your reply, by using the od command, i able to detect the octal code 012 is the one cause newline \n in my text file.

But how should i write my coding to detect this octal code and remove it in informix 4GL program?

Thanks

Regards
Eelyn
Reply With Quote
  #4  
Old 02-29-2008
robotronic's Avatar
Can I play with madness?
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Well, "\012" is nothing strange, it's a simple newline character (\n). I notice in your first post that there is a "^M"... Maybe is the symptom that the input file is in DOS format.
The first recommendation is trying to convert the input file into unix format and then look in the output if the unwanted newlines are gone:
Code:
dos2unix input_file converted_file.txt
For removing ALL the newlines from the input file you can try:
Code:
cat input_file | tr -d '\n'
But I think this is a too brutal solution for your purposes
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:11 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0