I've got lots of files with the unix new line (CR) and need to convert them all to the dos new line (CR + LF).
Is there are batch utility to make it happen?
I know there are utilities to make such a conversion for an individual file e.g. dos2unix etc, but how about a batch utility?
Batch converter of new line characters from unix to dos?
Правила форума
Пожалуйста, ознакомьтесь с правилами данного форума
Пожалуйста, ознакомьтесь с правилами данного форума
- Demurrage
- Завсегдатай
- Сообщения: 248
- Зарегистрирован: 16 янв 2007, 12:47
-
- Маньяк
- Сообщения: 2063
- Зарегистрирован: 07 июл 2008, 11:58
- Откуда: Россия
Re: Batch converter of new line characters from unix to dos?
#!/bin/bashDemurrage писал(а):I've got lots of files with the unix new line (CR) and need to convert them all to the dos new line (CR + LF).
Is there are batch utility to make it happen?
I know there are utilities to make such a conversion for an individual file e.g. dos2unix etc, but how about a batch utility?
for i in $( ls ); do
unix2dos $i
done
Под CMD/DOS напиши крохотный скрипт с командой FOR.
- sobomax
- Маньяк
- Сообщения: 3699
- Зарегистрирован: 29 июн 2006, 22:53
- Откуда: Vancouver
Re: Batch converter of new line characters from unix to dos?
perl -pi -e 's|\n|\r\n|' /path/*.foo
-Maxim
-Maxim
- Demurrage
- Завсегдатай
- Сообщения: 248
- Зарегистрирован: 16 янв 2007, 12:47
Re: Batch converter of new line characters from unix to dos?
Thanks, but had to write a little java program, because forgot to mention that the file structure was quite complex and I needed to recursively process all the folder & subfolders and process only ASCII files i.e. exclude binary files, so the algorithm wasn't that straightforward.