Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'how to use xargs correctly..' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
how to use xargs correctly..
Authored by: clith on Apr 30, '04 11:52:59AM
Rather than piping "ls" to "xargs", you should use "find". Something like this:

find . -type f -print0 | xargs -0 perl -pi 's/\r/\n/g;'

Note the -print0 flag for xargs and the -0 flag for xargs. What does this do? It delimits the filenames with zero rather than space or newline. This is extremely useful for files that have spaces, newlines and what-have-you in their names.

To restrict the search to just the current directory, use the flag -maxdepth 1 argument for find:

find . -type f -maxdepth 1 -print0 | xargs -0 perl -pi 's/\r/\n/g;'

[ Reply to This | # ]

Problems with importing from Netscape or Mozilla or Thunderbird
Authored by: araque on Jun 12, '04 12:22:22PM

First off a big warning: BACKUP your original mailboxes before you do this.

The correct command is

find . -type f -print0 | xargs -0 perl -pi -e's/\n/\r/g'

I used this command to "fix" my Mozilla mailboxes (folders). For reasons I can't explain about 20% of the messages were affected by the newline / carriage return problem. I thought it had to do with the date, maybe the origin... I have switched from Netscape to Mozilla to Thunderbird in the past seven years, and all Mail clients have been backward compatible with the mbox format.

When I ran this command, the "bad" messages were "fixed", but the other 80% of the messages lost their "From" fields. So I had to import twice and then merge the results. This was a nightmare, if you want my opinion.

Why did I do it? Because the Search function in Mozilla / Thunderbird under Panther performs horribly (slow). In retrospect I would say Apple's Mail app should have a more robust and/or lenient Import function. The newline/carriage return problem is well documented, I don't know why they didn't catch this before. Hopefully the Tiger will fix this.



[ Reply to This | # ]