-
April 9th, 2009, 07:56 AM
#1
Deleting the garbage character ÿþ from a file
Hi,
I am having a flat file having comma separated values. The first two characters of the first field is some garbage ÿþ. I want to delete those two characters from the field.
sample data : - ÿþ1236934822~175
i want only 1236934822
I am using linux shellscript to do this
Code:
Data=`cat "${FILE_PATH}/${FILE_NAME}" |head -1| cut -d~ -f1`
Actual_Data=`echo | awk '{ print substr("'"$Data"'",3) }'`
its giving me only ÿþ1.
Also i want to replace the value ÿþ1236934822 with 1236934822 in the roiginal file for further processing.
Can anyone help me on this.
I dont know the actual forum to put this question so i put it here. Guide me.
Thanks
Ashwini
-
April 9th, 2009, 11:04 AM
#2
Re: Deleting the garbage character ÿþ from a file
Hi
Is the length of each line very unpredictable? If not then maybe this can help you.
Code:
cat "${FILE_PATH}/${FILE_NAME}" | cut -c 3-999 > temp.txt
mv temp.txt "${FILE_PATH}/${FILE_NAME}"
Not very good because of the 999. Im not sure whether there is a way to get the max length of each line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|