dos2unix?

ageldama의 이미지

# ~/.alias
alias dos2unix "tr '\r\n' '\n'"
alias unix2dos "tr '\n' '\r\n'"

다른분들은 어떻게하시고 계신가요?

Forums: 
cjh의 이미지

dg의 이미지

vim 에서 하는데요..

도스2유닉스
:set ff=unix
:w

유닉스2도스
:set ff=dos
:w

jemiro의 이미지

학교다닐때 만든걸 아직도 쓰고 있습니다.

/*
 * dos2unix.c
 */

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

int dos2unix(FILE *fromd);

int main(int argc, char *argv[])
{
    FILE	*fp;
    
    if (argc == 1)
	fp = stdin;
    else if (argc == 2)
	fp = fopen(argv[1], "r");
    else
	exit(1);
    
    if (!fp)
	exit(1);
    
    dos2unix(fp);
    fclose(fp);
    
    return 0;
}

int dos2unix(FILE *fp)
{
    int		ch;
    
    while ((ch = fgetc(fp)) != EOF) {
	if (ch == '\r')
	    continue;
	fputc(ch, stdout);
    }
    
    return 0;
}
ddt의 이미지