Fixing corrupted vcard files.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Fixing corrupted vcard files.
# 8  
Old 10-16-2008
The ^M characters are carriage returns, which means this file is in Windows/DOS format, which uses Carriage Return and Line Feed characters at the end of each line. Unix and Unix-like operating systems just use Line Feed. My original solution was removing the Line Feed only, leaving you with a carriage return, which meant that when you catted the file it was returning to the beginning of the line at each CR and overwriting the previous line's text on your terminal.

Do VCF files need to be in DOS format? If so, use the following to only remove the ones as you originally described:

Code:
perl -pi.bak -e 'BEGIN { $/=""; } s/\r\n //g;' *.vcf

Otherwise, if you want to convert the files to Unix format in the process, add an extra search and replace to remove the CRs:

Code:
perl -pi.bak -e 'BEGIN { $/=""; } s/\r//g; s/\n //g;' *.vcf

I also removed the m from the s/// operators since it seems to be unnecessary when you have "slurped" the input data.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Hardware

Files getting corrupted

$ uname -a Linux darksun 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:45 UTC 2014 i686 athlon i686 GNU/Linux My files are getting corrupted on a frequent basis. $ sudo fdisk -l /dev/sda Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total... (10 Replies)
Discussion started by: rlopes
10 Replies

2. Shell Programming and Scripting

help fixing awk statement

awk "BEGIN {if($MessageREAD<$ThresholdW) {print \"OK\" ; exit 0} else if(($MessageREAD>=$ThresholdW) && ($MessageREAD<$ThresholdC)) {print \"WARNING\" ; exit 1}" else if($MessageREAD<=$ThresholdC) {print \"CRITICAL\" ;... (4 Replies)
Discussion started by: SkySmart
4 Replies

3. Shell Programming and Scripting

Help fixing awk code to print values from 2 files

Hi everyone, Please help on this: I have file1: <file title="Title 1 and 2"> <report> <title>Title 1</title> <number>No. 1234</number> <address>Address 1</address> <date>October 07, 2009</date> <description>Some text</description> </report> ... (6 Replies)
Discussion started by: Ophiuchus
6 Replies

4. HP-UX

WinRAR files are corrupted after FTP

In my Windows 2003 server machine I have a winrar or winzip file that i around 3GB. This zip/rar file is ftped to a unix mahine (HPUX) . FTP is successful. But when it get this file to check if its has been ftped correctly, the file is corrupted. Is there something wrong that i am doing while... (4 Replies)
Discussion started by: maroli
4 Replies

5. Solaris

PAM login library files corrupted, have ILOM, can I get root?

I was installing sfw sudo and its dependencies (libiconv, libintl, libgcc)on Solaris 10, running on an x86 x4200 and I corrupted some PAM library files. It's a standard Solaris 10 base install, with some added software & libraries from a vendor. I am on console trying to get root access back,... (1 Reply)
Discussion started by: Mariognarly
1 Replies

6. Linux

fixing with sed

I am trying to replace the value of $f3 but its not working . I don't know what I am missing here . cat dim_copy.20080516.sql | grep -i "create view" | grep -v OPSDM002 | while read f1 f2 f3 f4 f5 f6 f7 f8 f9 do echo " $f3 " sed -e... (13 Replies)
Discussion started by: capri_drm
13 Replies

7. UNIX for Dummies Questions & Answers

Extracting files from corrupted tape

I've got a backuptape in cpio format that was accidentally overwritten with a very small batch file. As I assume that the cpio header has been overwritten, I cannot extract files from the backup in the conventional manner: ( cpio -itv </dev/rct0 cpio: this is not a cpio file, bad header) ... (0 Replies)
Discussion started by: mart4179
0 Replies

8. UNIX for Dummies Questions & Answers

Corrupted files from Windows to Unix Sco

I downloaded some applications from CD on a windows2000 PC to a Unix Sco machine using the WS-FTP program. When I tried to run the applications on the Unix machines I got an error. The files must have been corrupted in the process of transferring files from a Windows 2000 to a Unix Sco... (9 Replies)
Discussion started by: BAM
9 Replies
Login or Register to Ask a Question
synce-partnership(1)					   http://synce.sourceforge.net/				      synce-partnership(1)

NAME
rra-appointment-from-vevent, rra-appointment-to-vevent, rra-contact-from-vcard, rra-contact-to-vcard, rra-decode, rra-delete, rra-get-data, rra-get-ids, rra-get-recurring-appointments, rra-get-types, rra-put-data, rra-subscribe, rra-task-from-vtodo, rra-task-to-vtodo, rra-time- zone - Tools for manipulating the WinCE Database SYNOPSIS
rra-appointment-from-vevent [-d LEVEL] [-c CODEPAGE] [-u] [-t TZFILE] VEVENT_FILE APPOINTMENT_FILE rra-appointment-to-vevent [-d LEVEL] [-c CODEPAGE] [-u] [-t TZFILE] APPOINTMENT_FILE [VEVENT_FILE] rra-contact-from-vcard [-d LEVEL] [-c CODEPAGE] [-u] VCARD_FILE CONTACT_FILE rra-contact-to-vcard [-d LEVEL] [-c CODEPAGE] [-u] CONTACT_FILE [VCARD_FILE] rra-decode FILE rra-delete [-d LEVEL] TYPE-ID OBJECT-ID ... rra-get-data [-d LEVEL] TYPE-ID OBJECT-ID FILENAME rra-get-ids [-d LEVEL] TYPE-ID ... rra-get-recurring-appointments rra-get-types [-d LEVEL] rra-put-data TYPE-ID OBJECT-ID FLAGS FILENAME rra-subscribe [-d LEVEL] [TYPE-ID] [TYPE-ID] ... rra-task-from-vtodo [-d LEVEL] [-c CODEPAGE] [-u] [-t TZFILE] VTODO_FILE TASK_FILE rra-task-to-vtodo [-d LEVEL] [-c CODEPAGE] [-u] [-t TZFILE] TASK_FILE [VTODO_FILE] rra-timezone [-d LEVEL] [-h] [-i INPUT-FILE] [-o OUTPUT-FILE] [-b] [-r] [-v] DESCRIPTION
This small tools could be used to manipulate the database of a WinCE device. AUTHOR
This manual page was written by Jonathan McDowell <noodles@earth.li> SEE ALSO
synce(1) The SynCE project September 2003 synce-partnership(1)