Hi,
My requirement is to read a file. Actually there will be a file in the ftp Common folder. We have a script that will take the file from there and keep it in our project folder. When I'm trying to do a view data...I'm unable to..... .
I did a VI and saw that there are some trailing spaces[^M] at the end of each line. I also tried by converting it to ascii mode and the ftp'd the file.....but still was helpless........
Please help me if u can suggest me any .........
Thanks in Advance
Purush...
Trailing Spaces in Unix
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
^M is not a space character. It is a carriage return, or Ctrl-M, or Char(13). It suggests that this file was generated on a Windows system.
Try using a filter command in the Sequential File stage that uses tr -d to remove the \r characters.
Try using a filter command in the Sequential File stage that uses tr -d to remove the \r characters.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 22
- Joined: Mon Apr 02, 2007 4:02 am
- Location: MUMBAI
- Contact:
This solution is already given.....
Hey ,
Use the below command :
when to save ur file in Unix do this :
:%s/ctrlv+m//
means colon then % ,then s then / ,then control v and controll m ,then double slash
enjoy
Use the below command :
when to save ur file in Unix do this :
:%s/ctrlv+m//
means colon then % ,then s then / ,then control v and controll m ,then double slash
enjoy
Smrutiranjan Nayak
Close. It's a command to remove the ^M characters. Problem is it's not quite right. To enter control characters, you first press Ctrl-V and then the character in question. To get a 'control M' you don't type an 'M' - you press ENTER after the Ctrl-V.
You would do this before saving. Best to get the Sequential File settings correct so the file can be read - there's nothing out of the ordinary here and is perfectly feasible to do. And an ASCII ftp to a UNIX box would have converted any <CR><LF> pairs to plain <LF> characters.
You would do this before saving. Best to get the Sequential File settings correct so the file can be read - there's nothing out of the ordinary here and is perfectly feasible to do. And an ASCII ftp to a UNIX box would have converted any <CR><LF> pairs to plain <LF> characters.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Re: Trailing Spaces in Unix
Hi Purush,
I had similer kind of issue, the following script helped me out to remove the carriage return.
if [ $UNAME = "SunOS" ]
then
dos2unix ${SRC_PATHNM}/$FILENM ${INT_PATHNM} $FILENM.dos2unix
grep -v "^$" ${INT_PATHNM}/$FILENM.dos2unix > ${INT_PATHNM}/$FILENM
rm -f ${INT_PATHNM}/$FILENM.dos2unix
exit 0
fi
Thanks,
snt_ds
I had similer kind of issue, the following script helped me out to remove the carriage return.
if [ $UNAME = "SunOS" ]
then
dos2unix ${SRC_PATHNM}/$FILENM ${INT_PATHNM} $FILENM.dos2unix
grep -v "^$" ${INT_PATHNM}/$FILENM.dos2unix > ${INT_PATHNM}/$FILENM
rm -f ${INT_PATHNM}/$FILENM.dos2unix
exit 0
fi
Thanks,
snt_ds
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: This solution is already given.....
Grammatical Notesmrutiranjannayak wrote:Hey ,
Use the below command :
when to save ur file in Unix do this :
:%s/ctrlv+m//
means colon then % ,then s then / ,then control v and controll m ,then double slash
enjoy
Ur was a city in ancient Babylon. Please use correct English pronouns such as "your" here. Would you use "ur" in your professional documentation? We believe that DSXchange is a community of professionals.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.