Results 1 to 4 of 4
i have following line
test=^DIBM,7028-6E1^M^D
test1=YES
test2=AIX: nexec "$HOST" uname -M
trying to remove junk or non printable char doing following
echo $test|tr -cd [ rint:]
echo $test2|tr -cd [ ...
- 04-21-2008 #1Just Joined!
- Join Date
- Apr 2008
- Posts
- 19
remove junk char in shell?
i have following line
test=^DIBM,7028-6E1^M^D
test1=YES
test2=AIX: nexec "$HOST" uname -M
trying to remove junk or non printable char doing following
echo $test|tr -cd [
rint:]
echo $test2|tr -cd [
rint:]
echo $test3|tr -cd [
rint:]
but its giving me following
IBME
Y
Blank
instead of
IBM,7028-6E1
YES
AIX: nexec "$HOST" uname -M
Please help!!!
- 04-22-2008 #2Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
You could use tr to remove the garbage chars using the octal codes
\015 for ^M
\004 for ^D
and strip them that way. Just use tr the same way and single quote the octal codes.
Hope that helps
, Mike
- 04-22-2008 #3Just Joined!
- Join Date
- Apr 2008
- Posts
- 19
Thanks Mike,
I know that, but don't you think, we are hardcoding it for now. But if we get problem other than that then ??
- 04-22-2008 #4Just Joined!
- Join Date
- Apr 2008
- Posts
- 35
Hey There,
How about dos2unix / unix2dos (or an equivalent program) that's written to do that. Also, depending on what your version of tr can do, this might help also
echo $test|tr -sd [:cntrl:]
On mine the -sd deletes all instrances of characters that match [:cntrl:]
Hope that helps
, Mike


Reply With Quote