Added Cyg-Win
This commit is contained in:
parent
82cbc206eb
commit
413c315806
10586 changed files with 3806249 additions and 0 deletions
19
Agent-Windows/OGP64/usr/share/doc/dos2unix/BUGS.txt
Normal file
19
Agent-Windows/OGP64/usr/share/doc/dos2unix/BUGS.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
KNOWN BUGS
|
||||
|
||||
querycp.c: query_con_codepage()
|
||||
The DOS 16 and 32 bit versions compiled with OpenWatcom report
|
||||
a wrong active code page under Windows 98.
|
||||
A correct code page is reported under FreeDOS.
|
||||
|
||||
|
||||
REPORTING BUGS
|
||||
|
||||
Report bugs at the dos2unix SourceForge page
|
||||
https://sourceforge.net/projects/dos2unix/
|
||||
|
||||
Bugs tracker: https://sourceforge.net/p/dos2unix/bugs/
|
||||
|
||||
Also patches and feature requests can be entered under the
|
||||
"Tickets" tab.
|
||||
|
||||
or send an email to Erwin Waterlander <waterlan@xs4all.nl>
|
||||
30
Agent-Windows/OGP64/usr/share/doc/dos2unix/COPYING.txt
Normal file
30
Agent-Windows/OGP64/usr/share/doc/dos2unix/COPYING.txt
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
The dos2unix package is distributed under FreeBSD style license.
|
||||
See also https://www.freebsd.org/copyright/freebsd-license.html
|
||||
--------
|
||||
|
||||
Copyright (C) 2009-2026 Erwin Waterlander
|
||||
Copyright (C) 1998 Christian Wurll
|
||||
Copyright (C) 1998 Bernd Johannes Wuebben
|
||||
Copyright (C) 1994-1995 Benjamin Lin.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice in the documentation and/or other materials provided with
|
||||
the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
||||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
||||
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
1693
Agent-Windows/OGP64/usr/share/doc/dos2unix/ChangeLog.txt
Normal file
1693
Agent-Windows/OGP64/usr/share/doc/dos2unix/ChangeLog.txt
Normal file
File diff suppressed because it is too large
Load diff
387
Agent-Windows/OGP64/usr/share/doc/dos2unix/INSTALL.txt
Normal file
387
Agent-Windows/OGP64/usr/share/doc/dos2unix/INSTALL.txt
Normal file
|
|
@ -0,0 +1,387 @@
|
|||
PREREQUISITES
|
||||
|
||||
Using GCC:
|
||||
Required
|
||||
* gcc : GNU C compiler
|
||||
* GNU binutils : A collection of binary tools
|
||||
* GNU make : make
|
||||
* sh : POSIX type shell
|
||||
* GNU coreutils: Core utilities package (chmod, install, mkdir,
|
||||
mv, rm, uname)
|
||||
|
||||
Optional (depending on build targets):
|
||||
* perl : Practical Extraction and Report Language
|
||||
perl >= 5.10.1 is required for rebuilding the
|
||||
manual pages with pod2man.
|
||||
perl >= 5.18 is required for rebuilding the
|
||||
international manual pages correctly in HTML with pod2html.
|
||||
Self-tests require module perl-Test-Simple.
|
||||
* gettext : Framework to help GNU packages produce multi-
|
||||
lingual messages.
|
||||
* po4a : PO for anything, for rebuilding manuals.
|
||||
version >= 0.70 required.
|
||||
* groff : GNU troff text formatting system, for
|
||||
international messages and manuals.
|
||||
* ghostscript : An interpreter for the PostScript language and
|
||||
for PDF (ps2pdf)
|
||||
|
||||
|
||||
Using LLVM CLANG:
|
||||
Clang can be used as a drop-in replacement for gcc. Just add CC=clang to the make
|
||||
command line.
|
||||
|
||||
|
||||
Using Watcom C:
|
||||
Required
|
||||
* Open Watcom : https://sourceforge.net/projects/openwatcom/
|
||||
: https://github.com/open-watcom/open-watcom-1.9
|
||||
* Open Watcom V2 : https://github.com/open-watcom/open-watcom-v2
|
||||
|
||||
|
||||
Using Microsoft Visual C++:
|
||||
Required
|
||||
* Visual C++ : You can get a free community version via this web page:
|
||||
https://visualstudio.microsoft.com/vs/community/
|
||||
Download Visual Studio for Windows Desktop. Visual C++ is part
|
||||
of Visual Studio. Out of the box compilation for 64-bit
|
||||
applications is supported since version 2012.
|
||||
|
||||
|
||||
|
||||
BASIC INSTALLATION
|
||||
|
||||
To build the program type:
|
||||
|
||||
make
|
||||
|
||||
|
||||
To run the self-tests type:
|
||||
|
||||
make check
|
||||
|
||||
|
||||
To strip the executables:
|
||||
|
||||
make strip
|
||||
|
||||
|
||||
To install:
|
||||
|
||||
make install
|
||||
|
||||
|
||||
Clean:
|
||||
|
||||
make clean
|
||||
|
||||
|
||||
SELF-TESTS
|
||||
|
||||
To run the self-tests you need a Perl installation including
|
||||
modules perl-Test-Harness and perl-Test-Simple.
|
||||
|
||||
To check the native Windows ports you need to run the tests in
|
||||
the MSYS2 shell.
|
||||
|
||||
To run the tests in a DJGPP environment you need to make sure
|
||||
that the bash shell is available (sh.exe). And you need to be
|
||||
in an environment that supports long file names (LFN), e.g. on
|
||||
32 bit Windows.
|
||||
|
||||
|
||||
To run the tests:
|
||||
|
||||
make test
|
||||
|
||||
|
||||
Via the make variable PROVE_OPT extra arguments can be given to
|
||||
the prove command. E.g.:
|
||||
|
||||
make test PROVE_OPT=--color
|
||||
|
||||
|
||||
INSTALLATION NAMES
|
||||
|
||||
By default the 'install' target will install the program in
|
||||
/usr/bin, the language files in /usr/share/locale
|
||||
and the man page in /usr/share/man. You can specify an
|
||||
installation prefix other than /usr by modifying the
|
||||
'prefix' variable. An Example:
|
||||
|
||||
make prefix=$HOME clean all
|
||||
make prefix=$HOME install
|
||||
|
||||
|
||||
DEBUG
|
||||
|
||||
A debug enabled build can be made by adding DEBUG=1
|
||||
to the make command. Example:
|
||||
|
||||
make clean install DEBUG=1
|
||||
|
||||
With debug enabled you can debug the source code in gdb.
|
||||
|
||||
|
||||
DEBUG MESSAGES
|
||||
|
||||
Extra debug messages can be enabled by adding DEBUGMSG=1
|
||||
to the make command. Example:
|
||||
|
||||
make clean install DEBUGMSG=1
|
||||
|
||||
With debug messages enabled dos2unix will print extra information
|
||||
about accessing the file system.
|
||||
|
||||
|
||||
NATIVE LANGUAGE SUPPORT
|
||||
|
||||
Native Language Support (NLS) is by default enabled.
|
||||
To disable NLS add ENABLE_NLS=. Example:
|
||||
|
||||
make clean install ENABLE_NLS=
|
||||
|
||||
|
||||
INTERNATIONAL MAN PAGES
|
||||
|
||||
Since dos2unix 6.0.5 all man pages are encoded in UTF-8, because even
|
||||
Western-European man pages may contain Unicode characters not supported by
|
||||
the Latin-1 (ISO-8859-1) character set.
|
||||
|
||||
Originally the Unix man system supported only man pages in Latin1 format.
|
||||
Although the world is moving to Unicode format (UTF-8) there is still a lot
|
||||
of Latin1 legacy around.
|
||||
|
||||
The English man page is a pure ASCII file and is readable on all platforms.
|
||||
|
||||
Non-English man pages are encoded in UTF-8. These do not show properly on
|
||||
old systems. Man pages in UTF-8 format are shown properly on Linux. Not
|
||||
all roff implementations support UTF-8.
|
||||
|
||||
In order to show UTF-8 man pages properly on Cygwin with traditional man
|
||||
you need to do the following:
|
||||
|
||||
In /etc/man.conf, change the NROFF definition to use 'preconv'.
|
||||
|
||||
NROFF /usr/bin/preconv | /usr/bin/nroff -c -mandoc 2>/dev/null
|
||||
|
||||
To view the man page set the correct locale. E.g. for Ukrainian:
|
||||
|
||||
export LANG=uk_UA.UTF-8
|
||||
man dos2unix
|
||||
|
||||
With man-db the manpages show correctly out of the box. Cygwin changed to
|
||||
use man-db in June 2014.
|
||||
Man-db is the default man system on the major Linux distributions.
|
||||
|
||||
|
||||
LARGE FILE SUPPORT
|
||||
|
||||
Large File Support (LFS) is by default enabled. This enables
|
||||
the use of 64 bit file system interface on 32 bit systems.
|
||||
This makes it possible to open files larger than 2GB on 32 bit
|
||||
systems, provided the OS has LFS support builtin.
|
||||
To disable LFS make the LFS variable empty. Example:
|
||||
|
||||
Disable LFS:
|
||||
make clean install LFS=
|
||||
|
||||
The gcc compiler from the MinGW project does not support LFS.
|
||||
It is advised to use the MinGW-w64 compiler tool chain for LFS on
|
||||
32 bit Windows.
|
||||
|
||||
|
||||
UNICODE SUPPORT
|
||||
|
||||
Unicode UTF-16 support is by default enabled for Windows and Unix. To
|
||||
disable make the UCS variable (Universal Character Set) empty.
|
||||
|
||||
Disable Unicode:
|
||||
make clean install UCS=
|
||||
|
||||
Unicode UTF-16 is not supported by the DOS and OS/2 versions.
|
||||
|
||||
|
||||
UNICODE FILE NAME SUPPORT ON WINDOWS
|
||||
|
||||
Since version 7.3 dos2unix can read and write on Windows file names
|
||||
with Unicode characters. Prior to version 7.3 dos2unix could only open
|
||||
files with characters in the system ANSI code page.
|
||||
|
||||
To see if dos2unix on Windows has unicode file name support type dos2unix -V.
|
||||
|
||||
Unicode file name support on Windows is enabled by setting UNIFILE=1 in
|
||||
the makefile or on the make command line.
|
||||
|
||||
To disable Unicode file name support, make UNIFILE empty:
|
||||
|
||||
make UNIFILE=
|
||||
|
||||
Unicode file name support is by default enabled.
|
||||
|
||||
Dos2unix built with Watcom C is not able to display foreign characters
|
||||
correctly, even when option -D unicode is used. The correct file names
|
||||
are written though.
|
||||
|
||||
|
||||
DOCUMENTATION
|
||||
|
||||
Manual pages are generated from Perl POD files.
|
||||
To rebuild the man pages from POD type:
|
||||
|
||||
make maintainer-clean
|
||||
make man
|
||||
|
||||
Manuals in PDF format are by default not created.
|
||||
To create manuals in PDF format type:
|
||||
|
||||
make pdf
|
||||
|
||||
PDF generation requires GhostScript to be installed.
|
||||
|
||||
|
||||
WINDOWS 32 BIT PORT
|
||||
|
||||
Using Mingw <https://osdn.net/projects/mingw/>,
|
||||
or MinGW-w64 <https://www.mingw-w64.org/>.
|
||||
|
||||
I advise to use MinGW-w64, because MinGW-w64 has support for
|
||||
Large File Support (LFS), and MinGW doesn't. LFS is the ability to
|
||||
read/write files larger than 2GB or 4GB on a 32 bit operation system.
|
||||
LFS also makes processing files on network drives more reliable. I have
|
||||
had a problem report that output files were not always written when files
|
||||
on a network drive were concurrently processed. By switching from
|
||||
MinGW to MinGW-w64 the problem was solved.
|
||||
Earlier I got a problem report of accessing small files on a Windows
|
||||
network drive from Debian Linux. Here also the solution was LFS.
|
||||
Since dos2unix 6.0.4 (2013-12-30) I build the binary win32 packages
|
||||
with MinGW-w64.
|
||||
|
||||
I am using the MSYS2 project <https://www.msys2.org/>
|
||||
which includes the MinGW-w64 compiler.
|
||||
|
||||
The MSYS(2) environment is required for building dos2unix with MinGW(-w64).
|
||||
|
||||
|
||||
Type these commands to build with MinGW(-w64):
|
||||
|
||||
make clean
|
||||
make
|
||||
make strip
|
||||
make install
|
||||
|
||||
Using Open Watcom:
|
||||
|
||||
wmake -f wccwin32.mak clean
|
||||
wmake -f wccwin32.mak
|
||||
wmake -f wccwin32.mak install
|
||||
|
||||
Using Microsoft Visual C++:
|
||||
|
||||
nmake /f vc.mak clean
|
||||
nmake /f vc.mak
|
||||
nmake /f vc.mak install
|
||||
|
||||
|
||||
The win32 binaries built with MinGW32 are packed with a patched version of
|
||||
MinGW's libintl-8.dll that has builtin support for relocation. See also
|
||||
https://waterlander.net/libintl/ and
|
||||
https://sourceforge.net/p/mingw/bugs/1808/
|
||||
The MSYS2 project has the relocation patch already included.
|
||||
|
||||
|
||||
WINDOWS 64 BIT PORT
|
||||
|
||||
To compile a version for 64 bit Windows, get the Mingw-w64 compiler
|
||||
<https://www.mingw-w64.org/>.
|
||||
I am using the MSYS2 project <https://www.msys2.org/>
|
||||
which includes the MinGW-w64 compiler.
|
||||
|
||||
The MSYS2 environment is required for building dos2unix with MinGW-w64.
|
||||
|
||||
make clean
|
||||
make
|
||||
make strip
|
||||
make install
|
||||
|
||||
Or use Microsoft Visual C++. Visual Studio Express supports
|
||||
out of the box C/C++ compilation for 64-bit applications since
|
||||
version 2012. Start an "x64 Cross Tools Command Prompt" and
|
||||
type:
|
||||
|
||||
nmake /f vc.mak clean
|
||||
nmake /f vc.mak
|
||||
nmake /f vc.mak install
|
||||
|
||||
|
||||
DOS PORT, 32 BIT
|
||||
|
||||
To compile a version for DOS, get the DJGPP compiler
|
||||
<https://www.delorie.com/djgpp/>, and use makefile djgpp.mak.
|
||||
|
||||
DJGPP 2.03 gcc >= 4.6 seems to cause problems. Crashes of gcc itself,
|
||||
or crashing dos2unix binaries (seen in DOSBox and DOSEMU).
|
||||
Use DJGPP 2.03 gcc <= 4.5.3.
|
||||
|
||||
DJGPP 2.05 produces correct binaries.
|
||||
|
||||
|
||||
make -f djgpp.mak clean
|
||||
make -f djgpp.mak
|
||||
make -f djgpp.mak strip
|
||||
make -f djgpp.mak install
|
||||
|
||||
|
||||
Run DJGPP on a DOS version that supports long file names. That is on
|
||||
Windows 95, 98, ME, XP, Vista, or 7.
|
||||
Or run DJGPP in DOSBox-X (https://dosbox-x.com/) with DOS version 7.0 or
|
||||
7.1 in a FAT32 formatted image file. You need to unpack the dos2unix source zip
|
||||
package with long file names. E.g. with the DJGPP supplied unzip32.exe. The
|
||||
file names should not be chopped to 8.3 length.
|
||||
|
||||
Cross compilation with djgpp.mak works out-of-the-box in Cygwin if
|
||||
you have djgpp-gcc-core installed:
|
||||
|
||||
make -f djgpp.mak
|
||||
|
||||
On Linux you can add CROSS_COMP=1 to the command line:
|
||||
|
||||
make -f djgpp.mak CROSS_COMP=1
|
||||
|
||||
|
||||
Or use Open Watcom
|
||||
Cross compiling from Windows. This works:
|
||||
|
||||
wmake -f wccdos32.mak clean
|
||||
wmake -f wccdos32.mak
|
||||
wmake -f wccdos32.mak install
|
||||
|
||||
|
||||
DOS PORT, 16 BIT
|
||||
|
||||
Borland C version 4.0 or higher:
|
||||
(You can run the Borland C 4.0 command line tools in DOSBox-X.)
|
||||
|
||||
make -f bcc.mak clean
|
||||
make -f bcc.mak
|
||||
|
||||
Open Watcom:
|
||||
|
||||
wmake -f wccdos16.mak clean
|
||||
wmake -f wccdos16.mak
|
||||
wmake -f wccdos16.mak install
|
||||
|
||||
|
||||
OS/2 PORT
|
||||
|
||||
Using EMX
|
||||
|
||||
make -f emx.mak clean
|
||||
make -f emx.mak
|
||||
make -f emx.mak strip
|
||||
make -f emx.mak install
|
||||
|
||||
Open Watcom
|
||||
|
||||
wmake -f wccos2.mak clean
|
||||
wmake -f wccos2.mak
|
||||
wmake -f wccos2.mak install
|
||||
324
Agent-Windows/OGP64/usr/share/doc/dos2unix/NEWS.txt
Normal file
324
Agent-Windows/OGP64/usr/share/doc/dos2unix/NEWS.txt
Normal file
|
|
@ -0,0 +1,324 @@
|
|||
2026-05-28: Version 7.5.6
|
||||
|
||||
* New homepage https://waterlander.net/dos2unix/
|
||||
* Updated translations of the manual.
|
||||
|
||||
2026-04-06: Version 7.5.5
|
||||
|
||||
* New option --error-binary: Return an error if a
|
||||
binary file is skipped.
|
||||
* Fix: dos2unix error on empty input. The problem was introduced
|
||||
in version 7.5.4.
|
||||
|
||||
2026-01-30: Version 7.5.4
|
||||
|
||||
* Don't return an error code if a binary file is skipped.
|
||||
Reverting change in 7.5.3.
|
||||
* Refactored code.
|
||||
|
||||
2025-10-14: Version 7.5.3
|
||||
|
||||
* Fix: Exit with non-zero code if the conversion is aborted
|
||||
due to a binary file.
|
||||
* Fix: Exit with zero code when an unicode conversion error
|
||||
occurs in quiet mode.
|
||||
* Updated Brazilian Portuguese, Catalan, Chinese (traditional), Dutch,
|
||||
Friulian, Georgian, and Serbian translations.
|
||||
|
||||
2024-01-22: Version 7.5.2
|
||||
|
||||
* Dos2unix can print info about the line break type of the last line,
|
||||
or indicate there is none.
|
||||
* Updated documentation about ASCII mode conversion.
|
||||
|
||||
2023-08-29: Version 7.5.1
|
||||
|
||||
* Fixed problem of converting a symbolic link target
|
||||
that is on another file system.
|
||||
* Updated Chinese and Serbian translations.
|
||||
|
||||
2023-05-17: Version 7.5.0
|
||||
|
||||
* New option -e, --add-eol to add a line break to the last
|
||||
line if there isn't one. Option --no-add-eol disables the
|
||||
feature.
|
||||
* New option -O, --to-stdout to write to standard output.
|
||||
|
||||
2023-02-11: Version 7.4.4
|
||||
|
||||
* New Catalan, Georgian, Romanian, and Korean translations of the
|
||||
UI messages.
|
||||
* New Korean and Romanian translations of the manual.
|
||||
* Several translation updates.
|
||||
|
||||
2022-06-05: Version 7.4.3
|
||||
|
||||
* New Serbian translation of the manual.
|
||||
* Updated Esperanto translation.
|
||||
* Skip GB18030 tests on Darwin.
|
||||
|
||||
2020-10-12: Version 7.4.2
|
||||
|
||||
* New Friulian translation of the messages.
|
||||
* Updated Dutch, German, Serbian, Traditional Chinese, and Ukrainian
|
||||
translations.
|
||||
|
||||
2019-09-24: Version 7.4.1
|
||||
|
||||
* Updated Danish, German, Hungarian, Japanese and Ukrainian translations.
|
||||
* Code cleanup.
|
||||
|
||||
2017-10-10: Version 7.4.0
|
||||
|
||||
* New option --allow-chown to allow file ownership change
|
||||
in old file mode. Option --no-allow-chown does the opposite.
|
||||
* Code cleanup.
|
||||
|
||||
2017-07-04: Version 7.3.5
|
||||
|
||||
* New flag 0 for option -i, --info. End information lines with a null
|
||||
character instead of a newline character, enabling correct file name
|
||||
interpretation when flag c is used.
|
||||
* Don't print leading spaces when option -i with flag c is used.
|
||||
* Code cleanup.
|
||||
* Manual update.
|
||||
* Translation updates.
|
||||
|
||||
2016-05-24: Version 7.3.4
|
||||
|
||||
* Safer temporary file creation on Windows.
|
||||
* Code cleanup.
|
||||
* Updated translations.
|
||||
|
||||
2016-02-13: Version 7.3.3
|
||||
* Fixed printing of East-Asian text on Windows with an East-Asian regional
|
||||
setting.
|
||||
* Fixed printing text in unicode UTF-16 mode on Windows, so that when
|
||||
it is redirected to a file, a correct UTF-16 file is created.
|
||||
* New flags h (print header) and p (show file names without path) for
|
||||
option -i, --info
|
||||
|
||||
2015-11-20: Version 7.3.2
|
||||
|
||||
* New: Swedish translation of messages and manual.
|
||||
* Updated: Danish and Brazilian Portuguese translations.
|
||||
* Fix: The -iso option was misinterpreted as a corrupted -i option.
|
||||
* Fix: Compilation for MSYS 1.
|
||||
|
||||
2015-09-30: Version 7.3.1
|
||||
|
||||
* New: Simplified Chinese translation of messages and manual.
|
||||
* Fix: Compilation error "'wchar_t' undeclared" when Unicode support is disabled.
|
||||
* Fix: Compilation errors when MinGW compiler was used (MinGW-w64 was OK).
|
||||
|
||||
2015-08-24: Version 7.3
|
||||
|
||||
* New: Unicode file name support on Windows.
|
||||
* Fix: Options -ul and -ub caused option -i to report wrong BOM for no_bom.
|
||||
|
||||
2015-07-01: Version 7.2.3
|
||||
|
||||
* Fix: Check for file I/O errors while reading input files, and added
|
||||
a few missing checks while writing output files.
|
||||
* Fix: Compilation for msys.
|
||||
|
||||
2015-05-22: Version 7.2.2
|
||||
|
||||
* Fix: Fixed symlink support on FreeBSD.
|
||||
* Fix: Skip GB18030 test on FreeBSD.
|
||||
* Fix: When conversion of an UTF-16 file with binary symbols was forced,
|
||||
null characters were not written in the output.
|
||||
* Fix: Check UTF-16 input for invalid surrogate pairs.
|
||||
|
||||
2015-04-01: Version 7.2.1
|
||||
|
||||
* Fix: Skip the GB18030 tests when the system does not support the
|
||||
Chinese locale with GB18030 character encoding.
|
||||
* Fix: Small corrections in the manual in section GB18030 and OPTIONS -m.
|
||||
|
||||
2015-02-11: Version 7.2
|
||||
|
||||
* New: Japanese translation of the UI messages.
|
||||
* New: Support Chinese GB18030 locale.
|
||||
* Change: On Unix/Linux convert UTF-16 to the locale encoding. It is
|
||||
no longer required that the locale encoding is UTF-8.
|
||||
|
||||
2014-10-06: Version 7.1
|
||||
|
||||
* New: Option -i, --info to print file information.
|
||||
This new option prints number of DOS, Unix, and Mac line breaks, the byte
|
||||
order mark, and if the file is text or binary. And it can print the names
|
||||
of files that would be converted.
|
||||
|
||||
2014-09-09: Version 7.0
|
||||
|
||||
* New: automated self-tests.
|
||||
* New: option -u to keep UTF-16 encoding.
|
||||
* New: option -v to print information about BOMs and converted line breaks.
|
||||
* Change: stdio mode does not automatically set quiet mode.
|
||||
* Change: stdio mode does not automatically force conversion of binaries.
|
||||
An error is returned when the stdin stream contains a binary symbol.
|
||||
* Bugfix: dos2unix -l created DOS line breaks from Mac line breaks.
|
||||
* Bugfix: system error number was not always returned.
|
||||
* Bugfix: an Unicode input file disabled 7bit and iso mode for next input files.
|
||||
* Bugfix: mac2unix help text, options -b and -r.
|
||||
* The code has been cleaned up.
|
||||
|
||||
2014-08-03: Version 6.0.6
|
||||
|
||||
* Bugfix: mac2unix conversion produced corrupted output from UTF-16 input file.
|
||||
* New options -b (keep BOM) and -r (remove BOM).
|
||||
* New translation of the UI messages: Norwegian Bokmaal.
|
||||
|
||||
2014-04-17: Version 6.0.5
|
||||
|
||||
* Dos2unix is part of the Translation Project (TP).
|
||||
All translations go via the Translation Project.
|
||||
See https://translationproject.org/
|
||||
* New translations of UI messages: Brazilian Portuguese, Chinese (traditional),
|
||||
Danish, French, Hungarian, Polish, Serbian, Ukrainian, Vietnamese.
|
||||
* New translations of the manual: Brazilian Portuguese, French, German,
|
||||
Polish, Ukrainian.
|
||||
* Generated man pages are included in the source package to prevent
|
||||
compilation problems with very old or very new perl/pod2man versions.
|
||||
* Manuals are now generated from gettext PO files with po4a for easier
|
||||
translation.
|
||||
* All manuals are now in UTF-8 encoding.
|
||||
* Skip symbolic links on Windows by default (same as on Unix).
|
||||
|
||||
2013-12-30: Version 6.0.4
|
||||
|
||||
* New options -ul and -ub to convert UTF-16 files without BOM.
|
||||
* New Russian translation of the messages.
|
||||
* Build 32 bit Windows binaries with Large File Support (LFS)
|
||||
by using mingw-w64 for 32 bit Windows.
|
||||
* When a binary symbol is encountered the value is printed.
|
||||
|
||||
2013-01-25: Version 6.0.3
|
||||
|
||||
* Source code compiles with Microsoft Visual C.
|
||||
* Print system error when writing output fails.
|
||||
|
||||
2012-09-06: Version 6.0.2
|
||||
|
||||
* The locale encoding detection has been fixed when NLS was disabled.
|
||||
* Print line number when a binary symbol is found.
|
||||
* Updated makefiles for Watcom C, and added a new one for OS/2.
|
||||
|
||||
2012-07-25: Version 6.0.1
|
||||
|
||||
* Update Spanish translations.
|
||||
* Update manual.
|
||||
|
||||
2012-05-06: Version 6.0
|
||||
|
||||
* Conversion of Windows UTF-16 files to Unix UTF-8 files.
|
||||
* Conversion of Unix UTF-8 files to Windows UTF-8 files with byte
|
||||
order mark.
|
||||
|
||||
2012-03-10: Version 5.3.3
|
||||
|
||||
* Enabled wildcard expansion for all versions.
|
||||
* Fixed a compilation error when debug was enabled.
|
||||
|
||||
2012-01-27: Version 5.3.2
|
||||
|
||||
* New homepage URL: https://waterlan.home.xs4all.nl/dos2unix.html
|
||||
* Compiles for native MSYS.
|
||||
* Compile with OpenWatcom for DOS32 and Win32.
|
||||
* Detect code page on OS/2.
|
||||
* Support wild cards on OS/2.
|
||||
|
||||
2011-08-09: Version 5.3.1
|
||||
|
||||
* Spanish translation of messages and manual.
|
||||
* File ownership is maintained in old file mode (Unix only).
|
||||
* Dos2unix and Unix2dos share the same language files.
|
||||
* Code cleanup.
|
||||
|
||||
2011-04-26: Version 5.3
|
||||
|
||||
* Improved handling of symbolic links. New options -F, -R, -S.
|
||||
* Improved handling and reporting of errors.
|
||||
* Source code improvements for Cygwin. Behave exactly as on Linux.
|
||||
* New option --. Treat all following options as file names.
|
||||
|
||||
2011-03-04: Version 5.2.1
|
||||
|
||||
* PDF and PostScript generation is optional. No default dependency on
|
||||
GhostScript and Groff.
|
||||
* Enable optional Large File Support (LFS).
|
||||
* Esperanto x-notation is optional. No longer installation of non-standard
|
||||
locale 'eo-x'.
|
||||
* Improved error messages.
|
||||
|
||||
2011-01-31: Version 5.2
|
||||
|
||||
* ISO conversion mode supports same DOS code pages as SunOS dos2unix does:
|
||||
CP437 (US), CP850 (Western European), CP860 (Portuguese),
|
||||
CP863 (French Canadian), and CP865 (Nordic).
|
||||
* ISO conversion mode supports Windows code page CP1252 (Western).
|
||||
* SunOS compatible options -ascii, -iso, -7, -437, -850, -860, -863, and -865.
|
||||
* Active code page detection for ISO mode.
|
||||
* Fixed ISO conversion of non-breaking space (NBSP).
|
||||
* ISO and 7bit mode can be used in Mac mode.
|
||||
* Treat ASCII Form Feed control characters as valid text.
|
||||
* Update manual pages.
|
||||
* Don't include generated documentation files in Unix source package.
|
||||
* Create a source package in DOS text format.
|
||||
|
||||
2010-08-18: Version 5.1.1
|
||||
|
||||
* Added Dutch translation of the manual.
|
||||
* Win64 port.
|
||||
* Win32 binary package uses patched MinGW's libintl, with builtin
|
||||
* relocation support.
|
||||
* Support compilation in DOSBox (8.3 file names where needed).
|
||||
* Fixed compilation on Darwin OS.
|
||||
|
||||
2010-04-03: Version 5.1
|
||||
|
||||
* Esperanto translations have been added.
|
||||
* Ports to 16 bit DOS have been made.
|
||||
* Command-line options can be set in stdio mode.
|
||||
* Bugfix dos2unix MAC mode: Don't change DOS line endings.
|
||||
* Create stubs for DOS32 versions of mac2unix and unix2mac.
|
||||
* Localization information has been added to the manual.
|
||||
* Man pages have been merged.
|
||||
* Man page generation from Perl POD file.
|
||||
|
||||
|
||||
2010-02-16: Version 5.0
|
||||
|
||||
* Dos2unix and Unix2dos have been bundled in a single package.
|
||||
* German translations have been added.
|
||||
* Dos2unix -l --newline also works in MAC mode.
|
||||
* Unix2dos also got option -l, --newline.
|
||||
* Added MAC mode to Unix2dos: Convert Unix line endings to Mac line endings.
|
||||
* Cleanup of messages and manual.
|
||||
|
||||
2010-01-24: Version 4.1.2
|
||||
|
||||
* Preserves file modes in new file mode.
|
||||
|
||||
2010-01-21: Version 4.1.1
|
||||
|
||||
* Fixes a compilation problem on FreeBSD.
|
||||
|
||||
2009-12-28: Version 4.1
|
||||
|
||||
Automatically skips binary and non-regular files,
|
||||
and the ISO mode has been cleaned up (see ChangeLog).
|
||||
|
||||
2009-12-21: Version 4.0.1
|
||||
|
||||
Adds a port to OS/2 Warp. Two wrong conversions in ISO mode
|
||||
have been fixed. The manual page has been updated.
|
||||
|
||||
2009-12-15: Version 4.0
|
||||
|
||||
Adds internationalisation (Native Language Support, NLS). A Dutch
|
||||
translation has been added. Ports to Windows and DOS have been made.
|
||||
The problem in DOS/Windows stdio mode has been fixed. The manual has
|
||||
been updated.
|
||||
|
||||
231
Agent-Windows/OGP64/usr/share/doc/dos2unix/README.txt
Normal file
231
Agent-Windows/OGP64/usr/share/doc/dos2unix/README.txt
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
|
||||
dos2unix - DOS/Mac to Unix and vice versa text file format converter.
|
||||
|
||||
|
||||
FILE LIST
|
||||
|
||||
README.txt : This file.
|
||||
INSTALL.txt : How to build and install.
|
||||
COPYING.txt : distribution license.
|
||||
NEWS.txt : Basic change log for users.
|
||||
ChangeLog.txt : Detailed change log for programmers.
|
||||
TODO.txt : Things to do.
|
||||
BUGS.txt : Known bugs and instructions on reporting new ones.
|
||||
DEVEL.txt : Information about dos2unix' implementation choices.
|
||||
man/man1/dos2unix.txt : Dos2unix manual, text format.
|
||||
man/man1/dos2unix.htm : Dos2unix manual, HTML format.
|
||||
|
||||
|
||||
PROJECT HOME PAGE
|
||||
|
||||
https://waterlander.net/dos2unix/
|
||||
https://dos2unix.sourceforge.io/
|
||||
|
||||
|
||||
HISTORY
|
||||
|
||||
This is an update of Benjamin Lin's implementations of dos2unix and
|
||||
unix2dos. Benjamin Lin's implementations of dos2unix and unix2dos were
|
||||
distributed via SunSITE.unc.edu (later MetaLab.unc.edu, now ibiblio)
|
||||
and became part of several Linux distributions such as RedHat, Suse,
|
||||
Gentoo, and others. This update includes all RedHat patches and fixes
|
||||
several other problems. Internationalization has been added and ports
|
||||
to DOS, Windows, Cygwin and OS/2 Warp have been made.
|
||||
|
||||
These implementations of dos2unix and unix2dos have been modelled after
|
||||
dos2unix/unix2dos under SunOS/Solaris. The first versions were made by
|
||||
John Birchfield in 1989, and in 1995 rewritten from scratch by Benjamin
|
||||
Lin. Mac to Unix conversion was added by Bernd Johannes Wuebben in
|
||||
1998, Unix to Mac conversion by Erwin Waterlander in 2010.
|
||||
|
||||
In 2010 the two separate dos2unix and unix2dos packages have been
|
||||
bundled into a single dos2unix package (version 5.0). Support for
|
||||
Unicode UTF-16 was added in 2012 (version 6.0). Version 7.0, in 2014,
|
||||
was a major code cleanup and added a test suite.
|
||||
|
||||
|
||||
Features
|
||||
|
||||
* Native language support.
|
||||
* Automatically skips binary and non-regular files.
|
||||
* In-place, paired, or stdio mode conversion.
|
||||
* Keep original file dates option.
|
||||
* 7-bit and iso conversion modes like SunOS dos2unix.
|
||||
* Conversion of Unicode UTF-16 files.
|
||||
* Handles Unicode Byte Order Mark (BOM).
|
||||
* Display file information.
|
||||
* Secure.
|
||||
|
||||
|
||||
AUTHORS
|
||||
|
||||
Erwin Waterlander version 3.2 - 7.5.6 2009-2026
|
||||
Christian Wurll version 3.1 1998
|
||||
Bernd Johannes Wuebben version 3.0 1998
|
||||
Benjamin Lin version 1.1 - 2.3 1994-1995
|
||||
John Birchfield version 1.0 1989
|
||||
|
||||
TRANSLATORS
|
||||
|
||||
Since version 6.0.5 dos2unix is part of the Translation Project (TP).
|
||||
All translations go via the Translation Project.
|
||||
|
||||
Translation of the messages.
|
||||
See https://translationproject.org/domain/dos2unix.html
|
||||
|
||||
Brazilian Portuguese Enrico Nicoletto Version 6.0.5
|
||||
Brazilian Portuguese Rafael Ferreira Version 6.0.6 - 7.2
|
||||
Brazilian Portuguese Rafael Fontenelle Version 7.3.2 - 7.5.5
|
||||
Catalan Jordi Mas i Hernàndez Version 7.4.4 - 7.5.2
|
||||
Chinese (simplified) Tianze Wang Version 7.3.1 - 7.4.0,
|
||||
7.5.1
|
||||
Chinese (simplified) Boyuan Yang Version 7.5.0 - 7.5.3
|
||||
Chinese (traditional) mail6543210 Version 6.0.5
|
||||
Chinese (traditional) Yi-Jyun Pan Version 7.4.2 - 7.5.2
|
||||
Danish Thomas Pryds Version 6.0.5 - 6.0.6
|
||||
Danish Joe Hansen Version 7.2.3 - 7.4.1
|
||||
Dutch Erwin Waterlander Version 4.0 - 6.0.4
|
||||
Dutch Benno Schulenberg Version 6.0.5 - 7.5.3
|
||||
Esperanto Rugxulo Version 5.1 - 6.0.4
|
||||
Esperanto Benno Schulenberg Version 6.0.5 - 7.3
|
||||
Esperanto Felipe Castro Version 7.4.3
|
||||
French Frédéric Marchal Version 6.0.5 - 7.5.5
|
||||
Friulian Fabio Tomat Version 7.4.2 - 7.5.2
|
||||
Georgian Temuri Doghonadze Version 7.4.4 - 7.5.3
|
||||
German Philipp Thomas Version 5.0 - 6.0.3, 7.0,
|
||||
7.2.2 - 7.4.1
|
||||
German Lars Wendler Version 6.0.4
|
||||
German Mario Blättermann Version 6.0.6, 7.1 - 7.2,
|
||||
7.5.5
|
||||
German Roland Illig Version 7.4.2 - 7.5.3
|
||||
Hungarian Balázs Úr Version 6.0.5 - 7.2.3,
|
||||
7.4.0 - 7.4.1
|
||||
Hungarian Gabor Kelemen Version 7.3.4
|
||||
Japanese Yasuaki Taniguchi Version 7.1.1
|
||||
Japanese Takeshi Hamasaki Version 7.3.4 - 7.4.1
|
||||
Korean Seong-ho Cho Version 7.4.4 - 7.5.5
|
||||
Norwegian Bokmaal Åka Sikrom Version 6.0.6 - 7.4.0
|
||||
Norwegian Bokmaal Johnny A. Solbu Version 7.5.0 - 7.5.5
|
||||
Polish Jakub Bogusz Version 6.0.5 - 7.5.5
|
||||
Romanian Remus-Gabriel Chelu Version 7.4.4 - 7.5.5
|
||||
Russian Андрей Углик (Andrei Uhlik) Version 6.0.4
|
||||
Russian Yuri Kozlov Version 6.0.6 - 7.5.2
|
||||
Serbian Мирослав Николић Version 6.0.5 - 7.5.5
|
||||
Spanish Julio A. Freyre-Gonzalez Version 5.3.1 - 6.0.4
|
||||
Spanish Enrique Lazcorreta Puigmartí Version 6.0.6 - 7.3.1
|
||||
Swedish Sebastian Rasmussen Version 7.3.2 - 7.5.2
|
||||
Swedish Luna Jernberg Version 7.5.2
|
||||
Ukrainian Yuri Chornoivan Version 6.0.5 - 7.5.5
|
||||
Vietnamese Trần Ngọc Quân Version 6.0.5 - 7.5.2
|
||||
|
||||
Translation of the manual.
|
||||
See https://translationproject.org/domain/dos2unix-man.html
|
||||
|
||||
Brazilian Portuguese Rafael Ferreira Version 6.0.5 - 7.2
|
||||
Brazilian Portuguese Rafael Fontenelle Version 7.3.2 - 7.5.5
|
||||
Chinese (simplified) Tianze Wang Version 7.3.1 - 7.4.0,
|
||||
7.5.1
|
||||
Chinese (simplified) Boyuan Yang, Tianze Wang Version 7.4.4
|
||||
Chinese (simplified) Boyuan Yang Version 7.5.0 - 7.5.3
|
||||
Dutch Erwin Waterlander Version 5.1.1 - 6.0.4,
|
||||
7.5.2
|
||||
Dutch Benno Schulenberg Version 6.0.5 - 7.4.0,
|
||||
7.5.2 - 7.5.6
|
||||
French Frédéric Marchal Version 6.0.5 - 7.5.6
|
||||
German Mario Blättermann Version 6.0.5 - 7.5.6
|
||||
German Roland Illig Version 7.4.2
|
||||
Korean Seong-ho Cho Version 7.4.4 - 7.5.6
|
||||
Polish Jakub Bogusz Version 6.0.5 - 7.5.6
|
||||
Romanian Remus-Gabriel Chelu Version 7.4.4 - 7.5.6
|
||||
Serbian Мирослав Николић Version 7.4.3 - 7.5.5
|
||||
Spanish Julio A. Freyre-Gonzalez Version 5.3.1 - 6.0.4
|
||||
Spanish Enrique Lazcorreta Puigmartí Version 6.0.6 - 7.2.1
|
||||
Swedish Sebastian Rasmussen Version 7.3.2 - 7.5.2
|
||||
Ukrainian Yuri Chornoivan Version 6.0.5 - 7.5.6
|
||||
|
||||
|
||||
ACKNOWLEDGEMENTS
|
||||
|
||||
Rugxulo query_con_codepage(), code page detection in DOS.
|
||||
Rugxulo DJGPP stubs for mac2unix and unix2mac.
|
||||
Jari Aalto Improvements man page.
|
||||
Jari Aalto Improvements Makefile.
|
||||
Ben Pfaff Treat form feeds as valid text.
|
||||
Marc Gianzero Darwin OS port.
|
||||
Elbert Pol OS/2 port.
|
||||
Tim Waugh Various patches.
|
||||
Mike Harris Man page update.
|
||||
Bernard RosenKraenzer segfault patch.
|
||||
Tim Powers mkstemp patch.
|
||||
Miloslav Trmac safeconv patch.
|
||||
Charles Wilson Follow symbolic links.
|
||||
Charles Wilson Makefile and code cleanup for Cygwin.
|
||||
Christopher Williams Maintain file ownership in old file mode.
|
||||
Steven H. Levine Support wildcard expansion on OS/2.
|
||||
Steve Hay Support wildcard expansion on win64.
|
||||
Michael Schindler Fixed compiler warning.
|
||||
Somsak Pattanaprateep Print line number when binary symbol is found.
|
||||
Justin Lecher Makefile improvement.
|
||||
F.J. Brandelik Reported problems when win32 version processes
|
||||
huge files on a network drive.
|
||||
Benno Schulenberg Cleaning up the UI messages.
|
||||
Mario Blättermann Generate pod files from gettext po files with po4a.
|
||||
Daniel Macks Reported dependency on GNU sed.
|
||||
Alan S. Jones Reported bug in UTF-16 conversion by mac2unix.
|
||||
Alan S. Jones Idea for an info option, to list file statistics
|
||||
about line breaks and byte order marks.
|
||||
Alan S. Jones New flags h (print header) and p (show file names
|
||||
without path) for option -i, --info
|
||||
Gary Johnson Idea for an info option, to list only files which have
|
||||
DOS line breaks, or only files with Unix line breaks.
|
||||
Helmut Karlowski Makefile and PrintVersion() update for freeMiNT.
|
||||
Tom Christiansen Fix for wrong title in HTML manuals.
|
||||
Armin Müller Fixed typo in if condition in write_bom().
|
||||
Philip Rowlands Reported that dos2unix was not checking for file I/O
|
||||
errors while reading the input.
|
||||
Baruch Siach Fix compilation error "'wchar_t' undeclared"
|
||||
when Unicode support is disabled.
|
||||
Ulf-Dietrich Braumann Reported that the -iso option was misinterpreted
|
||||
as a corrupted -i option.
|
||||
Hans Passant Correct redirection of unicode UTF-16 screen output.
|
||||
anonymous Don't install international man pages when NLS
|
||||
is disabled.
|
||||
Beep6581 Improved example for recursive conversion.
|
||||
kirowata Fixed a minor memory leak.
|
||||
Than Ngo Fixed issues reported by Coverity Scan.
|
||||
Vladislav Glinsky Reported typo in Ukrainian translation.
|
||||
Philipp Klaus Krause Assign strerror return value to const char.
|
||||
Victor Reported that GB18030 conversion is not working on Darwin.
|
||||
Victor Idea for 'to standard output' mode (option -O).
|
||||
anonymous Idea for adding a newline to the last line if there isn't
|
||||
one (option -e).
|
||||
fdamien12 Reported problem of converting a symbolic link target
|
||||
that is on another file system.
|
||||
Dimitry Andric Aligned Dutch help text.
|
||||
Joao ERIBERTO Mota Filho Reported dos2unix exits with zero code when it
|
||||
aborts conversion due to a binary file.
|
||||
quyse Reported problem with empty input.
|
||||
|
||||
|
||||
FINDUTILS
|
||||
|
||||
Windows users who are looking for the Unix 'find' and 'xargs' commands
|
||||
can find them in the findutils package for Windows at the ezwinports
|
||||
project page at: https://sourceforge.net/projects/ezwinports/files/
|
||||
|
||||
A DOS version of the findutils package can be obtained from the DJGPP
|
||||
project (https://www.delorie.com/djgpp/) at
|
||||
ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/
|
||||
|
||||
CONTACT INFORMATION
|
||||
|
||||
Project home page : https://waterlander.net/dos2unix/
|
||||
SourceForge project page : https://sourceforge.net/projects/dos2unix/
|
||||
|
||||
Erwin Waterlander
|
||||
waterlan@xs4all.nl
|
||||
https://waterlander.net/
|
||||
|
||||
If you need support you can email me directly or make a ticket on the
|
||||
SourceForge project page. Help in any form is appreciated. A problem
|
||||
report, a fix, or just a remark.
|
||||
20
Agent-Windows/OGP64/usr/share/doc/dos2unix/TODO.txt
Normal file
20
Agent-Windows/OGP64/usr/share/doc/dos2unix/TODO.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
TO DO
|
||||
=====
|
||||
|
||||
* Translations.
|
||||
|
||||
All translations are going via the Translation Project.
|
||||
|
||||
User interface messages:
|
||||
See https://translationproject.org/domain/dos2unix.html
|
||||
|
||||
Manual:
|
||||
See https://translationproject.org/domain/dos2unix-man.html
|
||||
|
||||
|
||||
* Support writing to symbolic link targets of Windows native
|
||||
symbolic links (Windows Vista and up).
|
||||
|
||||
* Keep original owner in old file mode, on Windows.
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/de/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/de/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - Formatumwandlung für Textdateien von DOS/Mac nach Unix und umgekehrt</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#BEZEICHNUNG">BEZEICHNUNG</a></li>
|
||||
<li><a href="#BERSICHT">ÜBERSICHT</a></li>
|
||||
<li><a href="#BESCHREIBUNG">BESCHREIBUNG</a></li>
|
||||
<li><a href="#OPTIONEN">OPTIONEN</a></li>
|
||||
<li><a href="#MAC-MODUS">MAC-MODUS</a></li>
|
||||
<li><a href="#UMWANDLUNGSMODI">UMWANDLUNGSMODI</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Zeichenkodierungen">Zeichenkodierungen</a></li>
|
||||
<li><a href="#Umwandlung">Umwandlung</a></li>
|
||||
<li><a href="#Markierung-der-Bytereihenfolge">Markierung der Bytereihenfolge</a></li>
|
||||
<li><a href="#Unicode-Dateinamen-unter-Windows">Unicode-Dateinamen unter Windows</a></li>
|
||||
<li><a href="#Unicode-Beispiele">Unicode-Beispiele</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#BEISPIELE">BEISPIELE</a></li>
|
||||
<li><a href="#REKURSIVE-UMWANDLUNG">REKURSIVE UMWANDLUNG</a></li>
|
||||
<li><a href="#LOKALISIERUNG">LOKALISIERUNG</a></li>
|
||||
<li><a href="#R-CKGABEWERT">RÜCKGABEWERT</a></li>
|
||||
<li><a href="#STANDARDS">STANDARDS</a></li>
|
||||
<li><a href="#AUTOREN">AUTOREN</a></li>
|
||||
<li><a href="#SIEHE-AUCH">SIEHE AUCH</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="BEZEICHNUNG">BEZEICHNUNG</h1>
|
||||
|
||||
<p>dos2unix - Formatumwandlung für Textdateien von DOS/Mac nach Unix und umgekehrt</p>
|
||||
|
||||
<h1 id="BERSICHT">ÜBERSICHT</h1>
|
||||
|
||||
<pre><code>dos2unix [Optionen] [DATEI …] [-n EINGABEDATEI AUSGABEDATEI …]
|
||||
unix2dos [Optionen] [DATEI …] [-n EINGABEDATEI AUSGABEDATEI …]</code></pre>
|
||||
|
||||
<h1 id="BESCHREIBUNG">BESCHREIBUNG</h1>
|
||||
|
||||
<p>Das Paket dos2unix enthält die Werkzeuge <code>dos2unix</code> und <code>unix2dos</code> zum Umwandeln einfacher Textdateien aus dem DOS- oder Mac-Format in das Unix-Format und umgekehrt.</p>
|
||||
|
||||
<p>In Textdateien unter DOS/Windows sind Zeilenumbrüche, auch als neue Zeile (NL) bekannt, eine Kombination aus zwei Zeichen: einem Wagenrücklauf (Carriage Return, CR) gefolgt von einem Zeilenvorschub (Line Feed, LF). In Unix-Textdateien bestehen Zeilenumbrüche nur aus einem Zeichen, dem Zeilenvorschub (LF). In Mac-Textdateien aus der Zeit vor MacOS X bestand ein Zeilenumbruch aus einem einzelnen CR-Zeichen. Heute verwendet macOS Zeilenumbrüche im Unix-Stil (LF).</p>
|
||||
|
||||
<p>Neben Zeilenumbrüchen kann dos2unix auch die Zeichenkodierung von Dateien umwandeln. Einige DOS-Codepages können in Unix Latin-1 umgewandelt werden, und Windows-Unicode-Dateien (UTF-16) können in Unix-Unicode-Dateien (UTF-8) umgewandelt werden.</p>
|
||||
|
||||
<p>Binärdateien werden automatisch übersprungen, sofern die Umwandlung nicht erzwungen wird.</p>
|
||||
|
||||
<p>Nicht-reguläre Dateien, wie Verzeichnisse und FIFOS (Weiterleitungen) werden automatisch übersprungen.</p>
|
||||
|
||||
<p>Symbolische Links und deren Ziele werden per Vorgabe unverändert belassen. Symbolische Links können optional ersetzt werden, oder die Ausgabe wird in das Ziel des symbolischen Links geschrieben. Unter Windows wird das Schreiben in das Ziel eines symbolischen Links nicht unterstützt.</p>
|
||||
|
||||
<p>Dos2unix wurde nach dem Vorbild der dos2unix-Version unter SunOS/Solaris entwickelt, doch es gibt einen wesentlichen Unterschied zum Original: Diese Version ersetzt per Vorgabe Dateien bei der Umwandlung (Alte-Datei-Modus), während unter SunOS/Solaris nur die paarweise Umwandlung (Neue-Datei-Modus) unterstützt wird. Siehe dazu die Optionen <code>-o</code> und <code>-n</code>. Ein weiterer Unterschied ist, dass die SunOS/Solaris-Version in der Voreinstellung die Umwandlung im <i>iso</i>-Modus vornimmt, während diese Version den <i>ascii</i>-Modus verwendet.</p>
|
||||
|
||||
<h1 id="OPTIONEN">OPTIONEN</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>nimmt an, dass alle folgenden Optionen Dateinamen sind. Verwenden Sie diese Option, wenn Sie Dateien umwandeln wollen, deren Namen mit einem Minuszeichen beginnen. Um beispielsweise eine Datei namens »-bla« umzuwandeln, können Sie folgenden Befehl verwenden:</p>
|
||||
|
||||
<pre><code>dos2unix -- -bla</code></pre>
|
||||
|
||||
<p>oder im Neue-Datei-Modus:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -bla ausgabe.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>erlaubt die Änderung des Eigentümers der Datei im Alte-Datei-Modus.</p>
|
||||
|
||||
<p>Wenn diese Option verwendet wird, dann bricht die Umwandlung nicht ab, wenn der Eigentümer und die Gruppe der Originaldatei im Alte-Datei-Modus nicht erhalten werden kann. Die Umwandlung wird fortgesetzt und die umgewandelte Datei erhält den gleichen neuen Eigentümer, als wäre sie im Neue-Datei-Modus umgewandelt worden. Siehe auch die Optionen <code>-o</code> und <code>-n</code>. Diese Option ist nur verfügbar, wenn dos2unix über Unterstützung für die Erhaltung des Eigentümers und der Gruppe von Dateien verfügt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>ist der voreingestellte Umwandlungsmodus. Weitere Informationen hierzu finden Sie im Abschnitt UMWANDLUNGSMODI.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>wandelt aus dem DOS- in den ISO-8859-1-Zeichensatz um. Weitere Informationen hierzu finden Sie im Abschnitt UMWANDLUNGSMODI.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die Windows-Codepage 1252 (Westeuropäisch).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die DOS-Codepage 437 (US). Dies ist die vorgegebene Codepage für die ISO-Umwandlung.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die DOS-Codepage 850 (Westeuropäisch).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die DOS-Codepage 860 (Portugiesisch).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die DOS-Codepage 863 (Kanadisches Französisch).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verwendet die DOS-Codepage 865 (Skandinavisch).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>wandelt 8-Bit-Zeichen in ein 7-Bit-Bitmuster um.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>erhält die Markierung der Bytereihenfolge (BOM). Wenn die Eingabedatei eine BOM enthält, wird ebenfalls eine BOM in die Ausgabedatei geschrieben. Dies ist das Standardverhalten beim Umwandeln von DOS-Zeilenumbrüchen. Siehe auch die Option <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-UMWANDLUNGSMODUS"><b>-c, --convmode UMWANDLUNGSMODUS</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>legt den Umwandlungsmodus fest. UMWANDLUNGSMODUS kann <i>ascii</i>, <i>7bit</i>, <i>iso</i> oder <i>mac</i> sein, wobei <i>ascii</i> die Vorgabe ist.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-KODIERUNG"><b>-D, --display-enc KODIERUNG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>legt die Kodierung des angezeigten Texts fest. KODIERUNG kann <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i> oder <utf8bom> sein, wobei <i>ansi</i> die Vorgabe ist.</p>
|
||||
|
||||
<p>Diese Option ist nur in dos2unix für Windows mit Unterstützung für Unicode-Dateinamen verfügbar. Sie bleibt wirkungslos, wenn die tatsächlichen Dateinamen gelesen und geschrieben werden, lediglich bei der Darstellung wird sie berücksichtigt.</p>
|
||||
|
||||
<p>Es gibt verschiedene Möglichkeiten, Text in einer Windows-Konsole basierend auf dessen Kodierung darzustellen. Alle haben verschiedene Vor- und Nachteile.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Die Standardmethode von dos2unix ist die Verwendung von ANSI-kodiertem Text, der Vorteil ist deren Abwärtskompatibilität. Dies funktioniert mit Raster- und TrueType-Schriften. In manchen Gebieten müssen Sie mit dem Befehl <code>chcp</code> die aktive DOS-OEM-Codepage in die -System-ANSI-Codepage des Systems ändern, da dos2unix Letztere verwendet.</p>
|
||||
|
||||
<p>Der Nachteil von ANSI ist, dass internationale Dateinamen nicht korrekt dargestellt werden, wenn darin Zeichen enthalten sind, die nicht in der im System voreingestellten Codepage enthalten sind. Stattdessen wird entweder ein Fragezeichen oder ein falsches Zeichen angezeigt. Sofern Sie nicht mit fremden Dateinamen arbeiten, ist diese Methode in Ordnung.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Der Vorteil von Unicode (dem Windows-Namen für UTF-16) ist die üblicherweise korrekte Textdarstellung. Eine Änderung der aktiven Codepage ist nicht erforderlich. Sie müssen die Schriftart der Konsole auf eine TrueType-Schrift einstellen, damit internationale Zeichen richtig angezeigt werden können. Sollte ein Zeichen in einer TrueType-Schrift nicht enthalten sein, wird ein kleines Quadrat angezeigt, das gelegentlich noch ein Fragezeichen enthält.</p>
|
||||
|
||||
<p>Wenn Sie die ConEmu-Konsole nutzen, wird der gesamte Text korrekt dargestellt, da ConEmu automatisch eine passende Schrift wählt.</p>
|
||||
|
||||
<p>Nachteilig für Unicode ist, dass es nicht zu ASCII kompatibel ist. Die Ausgabe ist schwer zu verarbeiten, wenn sie in ein anderes Programm oder eine Datei weitergeleitet wird.</p>
|
||||
|
||||
<p>Wenn die Methode <code>unicodebom</code> verwendet wird, dann wird dem Unicode-Text eine BOM (Markierung der Bytereihenfolge) vorangestellt. Eine BOM ist für korrekte Um- oder Weiterleitung in der PowerShell notwendig.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Der Vorteil von UTF-8 ist die ASCII-Kompatibilität. Sie müssen die Schriftart der Konsole auf eine TrueType-Schrift setzen. Dadurch wird der Text ähnlich wie in der <code>unicode</code>-Kodierung dargestellt.</p>
|
||||
|
||||
<p>Der Nachteil ist die falsche Darstellung aller Nicht-ASCII-Zeichen, wenn Sie die Standard-Rasterschrift verwenden. Nicht nur Unicode-Dateinamen, sondern auch übersetzte Meldungen werden unlesbar. Auf einem Windows-System, das für eine ostasiatische Region eingerichtet wurde, wird die Konsole bei der Anzeige von Meldungen deutlich flackern.</p>
|
||||
|
||||
<p>In einer ConEmu-Konsole funktioniert die UTF-8-Kodierung gut.</p>
|
||||
|
||||
<p>Wenn die Methode <code>utf8bom</code> verwendet wird, dann wird dem UTF-8-Text eine BOM (Markierung der Bytereihenfolge) vorangestellt. Eine BOM ist für korrekte Um- oder Weiterleitung in der PowerShell notwendig.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Die Standardkodierung kann durch Setzen der Umgebungsvariable DOS2UNIX_DISPLAY_ENC auf <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> oder <code>utf8</code> geändert werden.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>fügt einen Zeilenumbruch nach der letzten Zeile hinzu, falls ein solcher nicht existiert. Dies funktioniert in jeder Umwandlung.</p>
|
||||
|
||||
<p>Einer Datei, die aus dem DOS- ins Unix-Format umgewandelt wurde, kann ein Zeilenumbruch nach der letzten Zeile fehlen. Es gibt Texteditoren, die Dateien ohne diesen angehängten Zeilenumbruch schreiben. Einige Unix-Programme haben jedoch Probleme mit der Verarbeitung dieser Dateien, da der POSIX-Standard definiert, dass jede Zeile in einer Textdatei mit einem abschließenden Zeilenvorschubzeichen enden muss. Beispielsweise kann es beim Aneinanderhängen von solche Dateien zu unerwarteten Ergebnissen kommen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>liefert einen Fehler zurück, wenn eine Binärdatei übersprungen wird.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>erzwingt die Umwandlung von Binärdateien.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>wandelt unter Windows UTF-16-Dateien standardmäßig in UTF-8 um, ungeachtet der Einstellung der Locale. Verwenden Sie diese Option zum umwandeln von UTF-16-Dateien in GB18030. Diese Option ist nur unter Windows verfügbar. Siehe auch Abschnitt GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt eine Hilfe an und beendet das Programm.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-SCHALTER---info-SCHALTER-DATEI"><b>-i[SCHALTER], --info[=SCHALTER] DATEI …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt Dateiinformationen an. Es wird keine Umwandlung vorgenommen.</p>
|
||||
|
||||
<p>Die Ausgabe der Informationen geschieht in der folgenden Reihenfolge: Anzahl der DOS-Zeilenumbrüche, Anzahl der Unix-Zeilenumbrüche, Anzahl der Mac-Zeilenumbrüche, Markierung der Bytereihenfolge, Text- oder Binärformat, Dateiname.</p>
|
||||
|
||||
<p>Beispielausgabe:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Beachten sie, dass manchmal eine Binärdatei fälschlicherweise als Textdatei erkannt wird. Siehe auch Option <code>-s</code>.</p>
|
||||
|
||||
<p>Wenn zusätzlich die Option <code>-e</code> oder <code>--add-eol</code> verwendet wird, dann wird auch der Typ des Zeilenumbruchs der letzten Zeile ausgegeben, oder <code>noeol</code>, falls kein solcher Zeilenumbruch existiert.</p>
|
||||
|
||||
<p>Beispielausgabe:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Optionale zusätzliche Schalter können gesetzt werden, um die Ausgabe anzupassen. Einer oder mehrere Schalter können hinzugefügt werden.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt die Zeilen zur Dateiinformation mit einem Null-Zeichen am Ende anstelle eines Zeilenvorschub-Zeichens aus. Dies ermöglicht die korrekte Interpretation von Leer- und Anführungszeichen in Dateinamen, wenn der Schalter c verwendet wird. Verwenden Sie diesen Schalter in Kombination mit der xargs(1)-Option <code>-0</code> oder <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt die Anzahl der DOS-Zeilenumbrüche aus.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt die Anzahl der Unix-Zeilenumbrüche aus.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt die Anzahl der Mac-Zeilenumbrüche aus.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt die Markierung der Bytereihenfolge aus.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt an, ob es sich um eine Text- oder eine Binärdatei handelt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt den Typ des Zeilenumbruchs der letzten Zeile aus, oder <code>noeol</code>, falls kein solcher Zeilenumbruch existiert.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt nur die Dateien aus, die umgewandelt werden würden.</p>
|
||||
|
||||
<p>Mit dem Schalter <code>c</code> gibt dos2unix nur die Dateien aus, die DOS-Zeilenumbrüche enthalten, unix2dos nur die Dateien mit Unix-Zeilenumbrüchen.</p>
|
||||
|
||||
<p>Wenn zusätzlich die Option <code>-e</code> oder <code>--add-eol</code> verwendet wird, dann werden auch die Dateien ausgegeben, denen der Zeilenumbruch an der letzten Zeile fehlt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>gibt eine Kopfzeile aus.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt Dateinamen ohne Pfade an.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Beispiele:</p>
|
||||
|
||||
<p>Informationen zu allen *.txt-Dateien anzeigen:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Nur die Anzahl der DOS-Zeilenumbrüche und Unix-Zeilenumbrüche anzeigen:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Nur die Markierung der Bytereihenfolge anzeigen:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Die Dateien auflisten, die DOS-Zeilenumbrüche enthalten:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Die Dateien auflisten, die Unix-Zeilenumbrüche enthalten:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Die Dateien auflisten, die DOS-Zeilenumbrüche enthalten oder bei denen der Zeilenumbruch nach der letzten Zeile fehlt:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Nur Dateien umwandeln, die DOS-Zeilenumbrüche enthalten und die anderen Dateien unverändert belassen:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Nach Textdateien suchen, die DOS-Zeilenumbrüche enthalten:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>übernimmt den Zeitstempel der Eingabedatei in die Ausgabedatei.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt die Lizenz des Programms an.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>fügt eine zusätzliche neue Zeile hinzu.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Nur DOS-Zeilenumbrüche werden in Unix-Zeilenumbrüche umgewandelt. Im Mac-Modus werden nur Mac-Zeilenumbrüche in Unix-Zeilenumbrüche umgewandelt.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Nur Unix-Zeilenumbrüche werden in DOS-Zeilenumbrüche umgewandelt. Im Mac-Modus werden nur Unix-Zeilenumbrüche in Mac-Zeilenumbrüche umgewandelt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>schreibt eine Markierung der Bytereihenfolge (BOM) in die Ausgabedatei. In der Voreinstellung wird eine UTF-8-BOM geschrieben.</p>
|
||||
|
||||
<p>Wenn die Eingabedatei in UTF-16 kodiert ist und die Option <code>-u</code> verwendet wird, wird eine UTF-16-BOM geschrieben.</p>
|
||||
|
||||
<p>Verwenden Sie diese Option niemals, wenn die Kodierung der Ausgabedatei nicht UTF-8, UTF-16 oder GB 18030 ist. Weitere Informationen finden Sie im Abschnitt UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-EINGABEDATEI-AUSGABEDATEI"><b>-n, --newfile EINGABEDATEI AUSGABEDATEI …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Neue-Datei-Modus. Die EINGABEDATEI wird umgewandelt und in die AUSGABEDATEI geschrieben. Die Dateinamen müssen paarweise angegeben werden. Platzhalter sollten <i>nicht</i> verwendet werden, sonst werden Sie Ihre Dateien <i>verlieren</i>.</p>
|
||||
|
||||
<p>Der Benutzer, der die Umwandlung im Neue-Datei-Modus startet, wird Besitzer der umgewandelten Datei. Die Lese- und Schreibrechte werden aus den Zugriffsrechten der Originaldatei minus der umask(1) der Person ermittelt, die die Umwandlung ausgeführt hat.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>verhindert die Änderung des Eigentümers der Datei im Alte-Datei-Modus (Voreinstellung).</p>
|
||||
|
||||
<p>bricht die Umwandlung ab, wenn der Eigentümer und/oder die Gruppe der Originaldatei im Alte-Datei-Modus nicht erhalten werden kann. Siehe auch die Optionen <code>-o</code> und <code>-n</code>. Diese Option ist nur verfügbar, wenn dos2unix über Unterstützung für die Erhaltung des Eigentümers und der Gruppe von Dateien verfügt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>fügt keinen Zeilenumbruch nach der letzten Zeile hinzu, falls ein solcher nicht existiert (Vorgabe).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>liefert keinen Fehler zurück, wenn eine Binärdatei übersprungen wird (Vorgabe).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>schreibt wie ein Unix-Filter in die Standardausgabe. Mit der Option <code>-o</code> können Sie zum Alte-Datei-Modus (Ersetzungsmodus) zurückkehren.</p>
|
||||
|
||||
<p>In Kombination mit der Option <code>-e</code> können Dateien korrekt aneinandergehängt werden. Weder werden Zeilen ohne Umbruch zusammengeführt, noch werden Unicode-Markierungen der Bytereihenfolge mitten in die verkettete Datei gesetzt. Beispiel:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O Datei1.txt Datei2.txt > Ausgabe.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-DATEI"><b>-o, --oldfile DATEI …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Alte-Datei-Modus. Die DATEI wird umgewandelt und durch die Ausgabedatei überschrieben. Per Vorgabe werden Umwandlungen in diesem Modus ausgeführt. Platzhalter sind verwendbar.</p>
|
||||
|
||||
<p>Im Alte-Datei-Modus (Ersetzungsmodus) erhalten die umgewandelten Dateien den gleichen Eigentümer, die gleiche Gruppe und die gleichen Lese- und Schreibberechtigungen wie die Originaldatei, auch wenn die Datei von einem anderen Benutzer umgewandelt wird, der Schreibrechte für die Datei hat (zum Beispiel der Systemadministrator). Die Umwandlung wird abgebrochen, wenn es nicht möglich ist, die originalen Werte beizubehalten. Die Änderung des Eigentümers könnte zum Beispiel bewirken, dass der ursprüngliche Eigentümer die Datei nicht mehr lesen kann. Die Änderung der Gruppe könnte ein Sicherheitsrisiko sein, da die Datei vielleicht für Benutzer lesbar wird, für die sie nicht bestimmt ist. Die Beibehaltung von Eigentümer, Gruppe und Schreib- und Leserechten wird nur unter Unix unterstützt.</p>
|
||||
|
||||
<p>Um herauszufinden, ob dos2unix über Unterstützung für die Erhaltung von Eigentümer und Gruppe von Dateien verfügt, rufen Sie <code>dos2unix -V</code> auf.</p>
|
||||
|
||||
<p>Die Umwandlung führt stets über eine temporäre Datei. Tritt im Laufe der Umwandlung ein Fehler auf, wird die temporäre Datei gelöscht und die Originaldatei bleibt intakt. War die Umwandlung erfolgreich, wird die Originaldatei durch die temporäre Datei ersetzt. Sie können Schreibrechte für die Originaldatei haben, aber keine Rechte, um die gleichen Eigentumsverhältnisse wie die der Originaldatei für die temporäre Datei festzulegen. Das bedeutet, dass Sie Eigentümer und Gruppe der Originaldatei nicht bewahren können. In diesem Fall können Sie die Option <code>--allow-chown</code> verwenden, um die Umwandlung fortzusetzen:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Eine weitere Option ist der Neue-Datei-Modus:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Der Vorteil der Option <b>--allow-chown</b> ist, dass Sie Platzhalter verwenden können und die Eigentumsverhältnisse bewahrt bleiben, sofern möglich.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>aktiviert den stillen Modus, in dem alle Warnungen und sonstigen Meldungen unterdrückt werden. Der Rückgabewert ist 0, außer wenn fehlerhafte Befehlszeilenoptionen angegeben werden.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>entfernt die Markierung der Bytereihenfolge (BOM). Es wird keine BOM in die Ausgabedatei geschrieben. Dies ist das Standardverhalten beim Umwandeln von Unix-Zeilenumbrüchen. Siehe auch die Option <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>überspringt Binärdateien (Vorgabe).</p>
|
||||
|
||||
<p>Binärdateien werden übersprungen, damit unerwünschtes Fehlverhalten vermieden wird. Denken Sie daran, dass die Erkennung nicht 100% sicher funktioniert. Die übergebenen Dateien werden auf Binärsymbole überprüft, die typischerweise in Textdateien nicht vorkommen. Es ist jedoch möglich, dass eine Binärdatei ausschließlich gewöhnliche Textzeichen enthält. Eine solche Binärdatei wird dann fälschlicherweise als Textdatei angesehen.</p>
|
||||
|
||||
<p>Standardmäßig wird kein Fehler zurückgeliefert, wenn eine Binärdatei übersprungen wird. Bei Verwendung der Option <b>--error-binary</b> wird ein Fehler zurückgeliefert.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>erhält die originale UTF-16-Kodierung der Eingabedatei. Die Ausgabedatei wird in der gleichen UTF-16-Kodierung geschrieben (Little-Endian- oder Big-Endian-Bytereihenfolge) wie die Eingabedatei. Dies verhindert die Umwandlung in UTF-8. Eine UTF-16-BOM wird dementsprechend geschrieben. Diese Option kann durch Angabe der Option <code>-ascii</code> deaktiviert werden.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>nimmt an, dass die Eingabedatei das Format UTF-16LE hat.</p>
|
||||
|
||||
<p>Wenn die Eingabedatei eine Markierung der Bytereihenfolge enthält (BOM), dann hat die BOM Vorrang vor dieser Option.</p>
|
||||
|
||||
<p>Durch eine falsche Annahme (die Eingabedatei war nicht in UTF-16LE kodiert) mit erfolgreicher Umwandlung erhalten Sie eine UTF-8-Ausgabedatei mit fehlerhaftem Text. Sie können die fehlgeschlagene Umwandlung mit iconv(1) rückgängig machen, indem Sie die Rückumwandlung von UTF-8 nach UTF-16LE vornehmen. Dadurch gewinnen Sie die Originaldatei zurück.</p>
|
||||
|
||||
<p>Die Annahme von UTF-16LE wirkt wie ein <i>Umwandlungsmodus</i>. Beim Wechsel zum vorgegebenen <i>ascii</i>-Modus wird die UTF16LE-Annahme deaktiviert.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>nimmt an, dass die Eingabedatei das Format UTF-16BE hat.</p>
|
||||
|
||||
<p>Diese Option ist gleichbedeutend mit <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt ausführliche Meldungen an. Zusätzliche Informationen werden zu den Markierungen der Bytereihenfolge (BOM) und zur Anzahl der umgewandelten Zeilenumbrüche angezeigt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>folgt symbolischen Links und wandelt die Zieldateien um.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>ersetzt symbolische Links durch die umgewandelten Dateien (die originalen Zieldateien bleiben unverändert).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>erhält symbolische Links als solche und lässt die Ziele unverändert (Vorgabe).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>zeigt Versionsinformationen an und beendet das Programm.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MAC-MODUS">MAC-MODUS</h1>
|
||||
|
||||
<p>In der Voreinstellung werden Zeilenumbrüche von DOS nach Unix und umgekehrt umgewandelt. Mac-Zeilenumbrüche werden nicht verändert.</p>
|
||||
|
||||
<p>Im Mac-Modus werden Zeilenumbrüche von Mac nach Unix und umgekehrt umgewandelt. DOS-Zeilenumbrüche werden nicht verändert.</p>
|
||||
|
||||
<p>Um das Programm im Mac-Modus auszuführen, verwenden Sie die Befehlszeilenoption <code>-c mac</code> oder die Befehle <code>mac2unix</code> oder <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="UMWANDLUNGSMODI">UMWANDLUNGSMODI</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Dies ist der vorgegebene Umwandlungsmodus. Dieser Modus dient zum Umwandeln von ASCII- und ASCII-kompatibel kodierten Dateien, wie UTF-8. Durch Aktivierung des <b>ascii</b>-Modus werden die Modi <b>7bit</b> und <b>iso</b> deaktiviert.</p>
|
||||
|
||||
<p>Falls dos2unix über Unterstützung für UTF-16 verfügt, werden UTF-16-kodierte Dateien auf POSIX-Systemen in die aktuelle Zeichenkodierung der Locale und unter Windows in UTF-8 umgewandelt. Die Aktivierung des <b>ascii</b>-Modus deaktiviert die Option <code>-u</code> zum Erhalten der UTF-16-Kodierung sowie die Optionen <code>-ul</code> und <code>-ub</code>, welche davon ausgehen, dass die Eingabe in UTF-16 kodiert ist. Geben Sie den Befehl <code>dos2unix -V</code> ein, um zu sehen, ob dos2unix UTF-16 unterstützt. Weitere Informationen hierzu finden Sie im Abschnitt UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>In diesem Modus werden alle Nicht-ASCII-Zeichen aus 8 Bit in das 7-Bit-Bitmuster umgewandelt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Die Zeichen werden aus dem DOS-Zeichensatz (der Codepage) in den ISO-Zeichensatz ISO-8859-1 (Latin-1) in Unix umgewandelt. DOS-Zeichen ohne Äquivalent in ISO-8859-1, für die die Umwandlung nicht möglich ist, werden durch einen Punkt ersetzt. Gleiches gilt für ISO-8859-1-Zeichen ohne DOS-Gegenstück.</p>
|
||||
|
||||
<p>Wenn nur die Option <code>-iso</code> angegeben ist, versucht dos2unix die aktive Codepage selbst zu ermitteln. Sollte dies nicht möglich sein, wird die Standard-Codepage CP437 verwendet, welche hauptsächlich in den USA eingesetzt wird. Um eine bestimmte Codepage zu erzwingen, verwenden Sie die Optionen <code>-437</code> (US), <code>-850</code> (Westeuropäisch), <code>-860</code> (Portugiesisch), <code>-863</code> (Kanadisches Französisch) oder <code>-865</code> (Skandinavisch). Die Windows-Codepage CP1252 (Westeuropäisch) wird durch die Option <code>-1252</code> unterstützt.</p>
|
||||
|
||||
<p>Wenden Sie niemals die ISO-Umwandlung auf Unicode-Textdateien an. In UTF-8 kodierte Dateien werden dadurch beschädigt.</p>
|
||||
|
||||
<p>Einige Beispiele:</p>
|
||||
|
||||
<p>Umwandlung aus der vorgegebenen DOS-Codepage nach Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von DOS CP850 nach Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Windows CP1252 nach Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Windows CP1252 nach Unix UTF-8 (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 eingabe.txt | dos2unix > ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix Latin-1 in die vorgegebene DOS-Codepage:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix Latin-1 nach DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix Latin-1 nach Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix UTF-8 (Unicode) nach Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < eingabe.txt | iconv -f UTF-8 -t CP1252 > ausgabe.txt</code></pre>
|
||||
|
||||
<p>Siehe auch <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> und <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Zeichenkodierungen">Zeichenkodierungen</h2>
|
||||
|
||||
<p>Es gibt verschiedene Unicode-Zeichenkodierungen. Unter Unix und Linux sind Unicode-Dateien typischerweise in UTF-8 kodiert. Unter Windows können Textdateien in UTF-8, UTF-16 oder UTF-16 in Big-Endian-Bytereihenfolge kodiert sein, liegen aber meist im Format UTF-16 vor.</p>
|
||||
|
||||
<h2 id="Umwandlung">Umwandlung</h2>
|
||||
|
||||
<p>Unicode-Textdateien können DOS-, Unix- oder Mac-Zeilenumbrüche enthalten, so wie ASCII-Textdateien.</p>
|
||||
|
||||
<p>Alle Versionen von dos2unix und unix2dos können UTF-8-kodierte Dateien umwandeln, weil UTF-8 im Hinblick auf Abwärtskompatibilität mit ASCII entwickelt wurde.</p>
|
||||
|
||||
<p>Dos2unix und unix2dos mit Unterstützung für UTF-16 können in UTF-16 kodierte Dateien in Little-Endian- und Big-Endian-Bytereihenfolge lesen. Um festzustellen, ob dos2unix mit UTF-16-Unterstützung kompiliert wurde, geben Sie <code>dos2unix -V</code> ein.</p>
|
||||
|
||||
<p>Unter Unix/Linux werden UTF-16 kodierte Dateien standardmäßig in die Zeichenkodierung entsprechend der Locale umgewandelt. Mit dem Befehl locale(1) können Sie herausfinden, wie die Zeichenkodierung der Locale eingestellt ist. Wenn eine Umwandlung nicht möglich ist, verursacht dies einen Umwandlungsfehler, wodurch die Datei übersprungen wird.</p>
|
||||
|
||||
<p>Unter Windows werden UTF-16-Dateien standardmäßig in UTF-8 umgewandelt. In UTF-8 formatierte Textdateien werden von Windows und Unix/Linux gleichermaßen unterstützt.</p>
|
||||
|
||||
<p>Die Kodierungen UTF-16 und UTF-8 sind vollständig kompatibel, daher wird bei der Umwandlung keinerlei Text verlorengehen. Sollte bei der Umwandlung von UTF-16 in UTF-8 ein Problem auftreten, beispielsweise wenn die UTF-16-kodierte Eingabedatei einen Fehler enthält, dann wird diese Datei übersprungen.</p>
|
||||
|
||||
<p>Wenn die Option <code>-u</code> verwendet wird, wird die Ausgabedatei in der gleichen UTF-16-Kodierung wie die Eingabedatei geschrieben. Die Option <code>-u</code> verhindert die Umwandlung in UTF-8.</p>
|
||||
|
||||
<p>Dos2unix und unix2dos bieten keine Option zur Umwandlung von UTF-8-Dateien in UTF-16.</p>
|
||||
|
||||
<p>Umwandlungen im ISO- und 7bit-Modus funktionieren mit UTF-16-Dateien nicht.</p>
|
||||
|
||||
<h2 id="Markierung-der-Bytereihenfolge">Markierung der Bytereihenfolge</h2>
|
||||
|
||||
<p>Unicode-Textdateien unter Windows haben typischerweise eine Markierung der Bytereihenfolge (BOM), da viele Windows-Programme (zum Beispiel Notepad) solche BOMs standardmäßig hinzufügen. Weitere Informationen hierzu finden Sie auf <a href="https://de.wikipedia.org/wiki/Byte-Reihenfolge">https://de.wikipedia.org/wiki/Byte-Reihenfolge</a>.</p>
|
||||
|
||||
<p>Unter Unix haben Textdateien üblicherweise keine BOM. Es wird stattdessen angenommen, dass Textdateien in der Zeichenkodierung entsprechend der Spracheinstellung vorliegen.</p>
|
||||
|
||||
<p>Dos2unix kann nur dann erkennen, ob eine Datei UTF-16-kodiert ist, wenn die Datei eine BOM enthält. Ist dies nicht der Fall, nimmt dos2unix an, dass es sich um eine Binärdatei handelt.</p>
|
||||
|
||||
<p>Verwenden Sie die Optionen <code>-ul</code> oder <code>-ub</code>, um eine UTF-16-Datei ohne BOM umzuwandeln.</p>
|
||||
|
||||
<p>Dos2unix schreibt in der Voreinstellung keine BOM in die Ausgabedatei. Mit der Option <code>-b</code> schreibt dos2unix eine BOM, wenn die Eingabedatei ebenfalls eine BOM hat.</p>
|
||||
|
||||
<p>Unix2dos schreibt in der Voreinstellung eine BOM in die Ausgabedatei, wenn die Eingabedatei ebenfalls eine solche Markierung hat. Verwenden Sie die Option <code>-r</code>, um die BOM zu entfernen.</p>
|
||||
|
||||
<p>Dos2unix und unix2dos schreiben immer eine BOM, wenn die Option <code>-m</code> angegeben ist.</p>
|
||||
|
||||
<h2 id="Unicode-Dateinamen-unter-Windows">Unicode-Dateinamen unter Windows</h2>
|
||||
|
||||
<p>Dos2unix verfügt über optionale Unterstützung für das Lesen und Schreiben von Unicode-Dateinamen in der Windows-Eingabeaufforderung. Dadurch kann dos2unix Dateien öffnen, deren Namen Zeichen enthalten, die nicht zur Standard-ANSI-Codepage des Systems gehören. Geben Sie <code>dos2unix -V</code> ein, um zu sehen, ob dos2unix für Windows mit Unterstützung für Unicode-Dateinamen erstellt wurde.</p>
|
||||
|
||||
<p>Die Anzeige von Unicode-Dateinamen in einer Windows-Konsole ist gelegentlich nicht fehlerfrei, siehe die Option <code>-D</code>, <code>--display-enc</code>. Die Dateinamen können falsch dargestellt werden, allerdings werden die Dateien mit deren korrekten Namen gespeichert.</p>
|
||||
|
||||
<h2 id="Unicode-Beispiele">Unicode-Beispiele</h2>
|
||||
|
||||
<p>Umwandlung von Windows UTF-16 (mit BOM) nach Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Windows UTF-16LE (ohne BOM) nach Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix UTF-8 nach Windows UTF-8 mit BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n eingabe.txt ausgabe.txt</code></pre>
|
||||
|
||||
<p>Umwandlung von Unix UTF-8 nach Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < eingabe.txt | iconv -f UTF-8 -t UTF-16 > ausgabe.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 ist ein Standard der chinesischen Regierung. Eine Teilmenge des in GB18030 definierten Standards ist offiziell für alle in China verkauften Softwareprodukte vorgeschrieben. Siehe auch <a href="https://de.wikipedia.org/wiki/GB_18030">https://de.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 ist vollständig zu Unicode kompatibel und kann als Unicode-Umwandlungsformat betrachtet werden. Wie auch UTF-8 ist GB18030 kompatibel zu ASCII. Ebenfalls kompatibel ist es zur Codepage 936 von Windows, auch als GBK bekannt.</p>
|
||||
|
||||
<p>Unter Unix/Linux werden UTF-16-Dateien in GB18030 umgewandelt, wenn die Einstellung der Locale auf GB18030 gesetzt ist. Beachten Sie, dass dies nur funktioniert, wenn die Locale vom System unterstützt wird. Mit dem Befehl <code>locale -a</code> erhalten Sie eine Liste der unterstützten Locales.</p>
|
||||
|
||||
<p>Unter Windows benötigen Sie die Option <code>-gb</code>, um UTF-16-Dateien in GB18030 umwandeln zu können.</p>
|
||||
|
||||
<p>In GB 18030 kodierte Dateien haben wie Unicode-Dateien eine Markierung der Bytereihenfolge (BOM).</p>
|
||||
|
||||
<h1 id="BEISPIELE">BEISPIELE</h1>
|
||||
|
||||
<p>Aus der Standardeingabe lesen und in die Standardausgabe schreiben:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>a.txt umwandeln und ersetzen, b.txt umwandeln und ersetzen:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>a.txt im ascii-Modus umwandeln und ersetzen:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>a.txt im ascii-Modus umwandeln und ersetzen, b.txt im 7bit-Modus umwandeln und ersetzen:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>a.txt aus dem Mac- in das Unix-Format umwandeln:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>a.txt aus dem Unix- in das Mac-Format umwandeln:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>a.txt unter Beibehaltung des ursprünglichen Zeitstempels umwandeln:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>a.txt umwandeln und das Ergebnis nach e.txt schreiben:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>a.txt umwandeln und das Ergebnis nach e.txt schreiben, wobei e.txt den gleichen Zeitstempel erhält wie a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>a.txt umwandeln und ersetzen, b.txt umwandeln und das Ergebnis nach e.txt schreiben:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>c.txt umwandeln und das Ergebnis nach e.txt schreiben, a.txt umwandeln und ersetzen, b.txt umwandeln und ersetzen, d.txt umwandeln und das Ergebnis nach f.txt schreiben:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="REKURSIVE-UMWANDLUNG">REKURSIVE UMWANDLUNG</h1>
|
||||
|
||||
<p>In einer Unix-Shell können Sie dos2unix zusammen mit den Befehlen find(1) und xargs(1) verwenden, um Textdateien in einem Verzeichnisbaum rekursiv umzuwandeln. Um beispielsweise alle *.txt-Dateien im aktuellen Verzeichnis und dessen Unterverzeichnissen umzuwandeln, geben Sie Folgendes ein:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Die find(1)-Option <code>-print0</code> und die korrespondierende xargs(1)-Option <code>-0</code> werden für Dateien benötigt, deren Namen Leerzeichen oder Anführungszeichen enthalten. Ansonsten können diese Optionen weggelassen werden. Eine weitere Möglichkeit ist, find(1) zusammen mit der Option <code>-exec</code> zu verwenden:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>In einer Windows-Eingabeaufforderung kann der folgende Befehl verwendet werden:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>In der Windows PowerShell können Sie folgenden Befehl verwenden:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOKALISIERUNG">LOKALISIERUNG</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Die primäre Sprache wird durch die Umgebungsvariable LANG festgelegt. Diese Variable besteht aus mehreren Teilen: Der erste Teil besteht aus zwei Kleinbuchstaben, die den Sprachcode angeben. Der zweite Teil ist optional und bezeichnet den Ländercode in Großbuchstaben, vom davor stehenden Sprachcode durch einen Unterstrich getrennt. Der dritte Teil ist ebenfalls optional und gibt die Zeichenkodierung an, vom Ländercode durch einen Punkt getrennt. Einige Beispiele für Standard-POSIX-Shells:</p>
|
||||
|
||||
<pre><code>export LANG=de Deutsch
|
||||
export LANG=de_DE Deutsch, Deutschland
|
||||
export LANG=de_AT Deutsch, Österreich
|
||||
export LANG=es_ES Spanisch, Spanien
|
||||
export LANG=es_MX Spanisch, Mexiko
|
||||
export LANG=en_US.iso88591 Englisch, USA, Latin-1-Zeichenkodierung
|
||||
export LANG=en_GB.UTF-8 Englisch, GB, UTF-8-Zeichenkodierung</code></pre>
|
||||
|
||||
<p>Eine vollständige Liste der Sprachen und Ländercodes finden Sie im Gettext-Handbuch: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>Auf Unix-Systemen erhalten Sie mit dem Befehl locale(1) spezifische Informationen zu den Spracheinstellungen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mit der Umgebungsvariable LANGUAGE können Sie eine Prioritätenliste für Sprachen übergeben, die Sie durch Doppelpunkte voneinander trennen. Dos2unix gibt LANGUAGE vor LANG den Vorzug, zum Beispiel bei Deutsch vor Niederländisch: <code>LANGUAGE=de:nl</code>. Sie müssen zunächst die Lokalisierung aktivieren, indem Sie die Variable LANG (oder LC_ALL) auf einen anderen Wert als »C« setzen, bevor Sie die Liste der Sprachprioritäten mit der Variable LANGUAGE nutzen können. Weitere Informationen finden Sie im Gettext-Handbuch: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Falls Sie eine Sprache auswählen, die nicht verfügbar ist, erhalten Sie die Standardmeldungen in englischer Sprache.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Durch die Umgebungsvariable DOS2UNIX_LOCALEDIR wird LOCALEDIR während der Kompilierung übergangen. LOCALEDIR wird verwendet, um Sprachdateien zu finden. Der GNU-Standardwert ist <code>/usr/local/share/locale</code>. Die Option <b>--version</b> zeigt das verwendete LOCALEDIR an.</p>
|
||||
|
||||
<p>Beispiel (POSIX-Shell):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="R-CKGABEWERT">RÜCKGABEWERT</h1>
|
||||
|
||||
<p>Bei Erfolg wird 0 zurückgegeben. Bei aufgetretenen Systemfehlern wird der letzte Systemfehler zurückgegeben. Für alle anderen Fehler wird 1 zurückgegeben.</p>
|
||||
|
||||
<p>Der Rückgabewert ist im stillen Modus stets 0, außer wenn fehlerhafte Befehlszeilenoptionen verwendet werden.</p>
|
||||
|
||||
<h1 id="STANDARDS">STANDARDS</h1>
|
||||
|
||||
<p><a href="https://de.wikipedia.org/wiki/Textdatei">https://de.wikipedia.org/wiki/Textdatei</a></p>
|
||||
|
||||
<p><a href="https://de.wikipedia.org/wiki/Wagenr%C3%BCcklauf">https://de.wikipedia.org/wiki/Wagenr%C3%BCcklauf</a></p>
|
||||
|
||||
<p><a href="https://de.wikipedia.org/wiki/Zeilenumbruch">https://de.wikipedia.org/wiki/Zeilenumbruch</a></p>
|
||||
|
||||
<p><a href="https://de.wikipedia.org/wiki/Unicode">https://de.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTOREN">AUTOREN</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (Mac2unix-Modus) - <wuebben@kde.org>, Christian Wurll (Extra Zeilenumbruch) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (Betreuer)</p>
|
||||
|
||||
<p>Projektseite: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge-Seite: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="SIEHE-AUCH">SIEHE AUCH</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
891
Agent-Windows/OGP64/usr/share/doc/dos2unix/de/dos2unix.txt
Normal file
891
Agent-Windows/OGP64/usr/share/doc/dos2unix/de/dos2unix.txt
Normal file
|
|
@ -0,0 +1,891 @@
|
|||
BEZEICHNUNG
|
||||
dos2unix - Formatumwandlung für Textdateien von DOS/Mac nach Unix und
|
||||
umgekehrt
|
||||
|
||||
ÜBERSICHT
|
||||
dos2unix [Optionen] [DATEI …] [-n EINGABEDATEI AUSGABEDATEI …]
|
||||
unix2dos [Optionen] [DATEI …] [-n EINGABEDATEI AUSGABEDATEI …]
|
||||
|
||||
BESCHREIBUNG
|
||||
Das Paket dos2unix enthält die Werkzeuge "dos2unix" und "unix2dos" zum
|
||||
Umwandeln einfacher Textdateien aus dem DOS- oder Mac-Format in das
|
||||
Unix-Format und umgekehrt.
|
||||
|
||||
In Textdateien unter DOS/Windows sind Zeilenumbrüche, auch als neue
|
||||
Zeile (NL) bekannt, eine Kombination aus zwei Zeichen: einem
|
||||
Wagenrücklauf (Carriage Return, CR) gefolgt von einem Zeilenvorschub
|
||||
(Line Feed, LF). In Unix-Textdateien bestehen Zeilenumbrüche nur aus
|
||||
einem Zeichen, dem Zeilenvorschub (LF). In Mac-Textdateien aus der Zeit
|
||||
vor MacOS X bestand ein Zeilenumbruch aus einem einzelnen CR-Zeichen.
|
||||
Heute verwendet macOS Zeilenumbrüche im Unix-Stil (LF).
|
||||
|
||||
Neben Zeilenumbrüchen kann dos2unix auch die Zeichenkodierung von
|
||||
Dateien umwandeln. Einige DOS-Codepages können in Unix Latin-1
|
||||
umgewandelt werden, und Windows-Unicode-Dateien (UTF-16) können in
|
||||
Unix-Unicode-Dateien (UTF-8) umgewandelt werden.
|
||||
|
||||
Binärdateien werden automatisch übersprungen, sofern die Umwandlung
|
||||
nicht erzwungen wird.
|
||||
|
||||
Nicht-reguläre Dateien, wie Verzeichnisse und FIFOS (Weiterleitungen)
|
||||
werden automatisch übersprungen.
|
||||
|
||||
Symbolische Links und deren Ziele werden per Vorgabe unverändert
|
||||
belassen. Symbolische Links können optional ersetzt werden, oder die
|
||||
Ausgabe wird in das Ziel des symbolischen Links geschrieben. Unter
|
||||
Windows wird das Schreiben in das Ziel eines symbolischen Links nicht
|
||||
unterstützt.
|
||||
|
||||
Dos2unix wurde nach dem Vorbild der dos2unix-Version unter SunOS/Solaris
|
||||
entwickelt, doch es gibt einen wesentlichen Unterschied zum Original:
|
||||
Diese Version ersetzt per Vorgabe Dateien bei der Umwandlung
|
||||
(Alte-Datei-Modus), während unter SunOS/Solaris nur die paarweise
|
||||
Umwandlung (Neue-Datei-Modus) unterstützt wird. Siehe dazu die Optionen
|
||||
"-o" und "-n". Ein weiterer Unterschied ist, dass die
|
||||
SunOS/Solaris-Version in der Voreinstellung die Umwandlung im
|
||||
*iso*-Modus vornimmt, während diese Version den *ascii*-Modus verwendet.
|
||||
|
||||
OPTIONEN
|
||||
-- nimmt an, dass alle folgenden Optionen Dateinamen sind. Verwenden
|
||||
Sie diese Option, wenn Sie Dateien umwandeln wollen, deren Namen mit
|
||||
einem Minuszeichen beginnen. Um beispielsweise eine Datei namens
|
||||
»-bla« umzuwandeln, können Sie folgenden Befehl verwenden:
|
||||
|
||||
dos2unix -- -bla
|
||||
|
||||
oder im Neue-Datei-Modus:
|
||||
|
||||
dos2unix -n -- -bla ausgabe.txt
|
||||
|
||||
--allow-chown
|
||||
erlaubt die Änderung des Eigentümers der Datei im Alte-Datei-Modus.
|
||||
|
||||
Wenn diese Option verwendet wird, dann bricht die Umwandlung nicht
|
||||
ab, wenn der Eigentümer und die Gruppe der Originaldatei im
|
||||
Alte-Datei-Modus nicht erhalten werden kann. Die Umwandlung wird
|
||||
fortgesetzt und die umgewandelte Datei erhält den gleichen neuen
|
||||
Eigentümer, als wäre sie im Neue-Datei-Modus umgewandelt worden.
|
||||
Siehe auch die Optionen "-o" und "-n". Diese Option ist nur
|
||||
verfügbar, wenn dos2unix über Unterstützung für die Erhaltung des
|
||||
Eigentümers und der Gruppe von Dateien verfügt.
|
||||
|
||||
-ascii
|
||||
ist der voreingestellte Umwandlungsmodus. Weitere Informationen
|
||||
hierzu finden Sie im Abschnitt UMWANDLUNGSMODI.
|
||||
|
||||
-iso
|
||||
wandelt aus dem DOS- in den ISO-8859-1-Zeichensatz um. Weitere
|
||||
Informationen hierzu finden Sie im Abschnitt UMWANDLUNGSMODI.
|
||||
|
||||
-1252
|
||||
verwendet die Windows-Codepage 1252 (Westeuropäisch).
|
||||
|
||||
-437
|
||||
verwendet die DOS-Codepage 437 (US). Dies ist die vorgegebene
|
||||
Codepage für die ISO-Umwandlung.
|
||||
|
||||
-850
|
||||
verwendet die DOS-Codepage 850 (Westeuropäisch).
|
||||
|
||||
-860
|
||||
verwendet die DOS-Codepage 860 (Portugiesisch).
|
||||
|
||||
-863
|
||||
verwendet die DOS-Codepage 863 (Kanadisches Französisch).
|
||||
|
||||
-865
|
||||
verwendet die DOS-Codepage 865 (Skandinavisch).
|
||||
|
||||
-7 wandelt 8-Bit-Zeichen in ein 7-Bit-Bitmuster um.
|
||||
|
||||
-b, --keep-bom
|
||||
erhält die Markierung der Bytereihenfolge (BOM). Wenn die
|
||||
Eingabedatei eine BOM enthält, wird ebenfalls eine BOM in die
|
||||
Ausgabedatei geschrieben. Dies ist das Standardverhalten beim
|
||||
Umwandeln von DOS-Zeilenumbrüchen. Siehe auch die Option "-r".
|
||||
|
||||
-c, --convmode UMWANDLUNGSMODUS
|
||||
legt den Umwandlungsmodus fest. UMWANDLUNGSMODUS kann *ascii*,
|
||||
*7bit*, *iso* oder *mac* sein, wobei *ascii* die Vorgabe ist.
|
||||
|
||||
-D, --display-enc KODIERUNG
|
||||
legt die Kodierung des angezeigten Texts fest. KODIERUNG kann
|
||||
*ansi*, *unicode*, *unicodebom*, *utf8* oder <utf8bom> sein, wobei
|
||||
*ansi* die Vorgabe ist.
|
||||
|
||||
Diese Option ist nur in dos2unix für Windows mit Unterstützung für
|
||||
Unicode-Dateinamen verfügbar. Sie bleibt wirkungslos, wenn die
|
||||
tatsächlichen Dateinamen gelesen und geschrieben werden, lediglich
|
||||
bei der Darstellung wird sie berücksichtigt.
|
||||
|
||||
Es gibt verschiedene Möglichkeiten, Text in einer Windows-Konsole
|
||||
basierend auf dessen Kodierung darzustellen. Alle haben verschiedene
|
||||
Vor- und Nachteile.
|
||||
|
||||
ansi
|
||||
Die Standardmethode von dos2unix ist die Verwendung von
|
||||
ANSI-kodiertem Text, der Vorteil ist deren
|
||||
Abwärtskompatibilität. Dies funktioniert mit Raster- und
|
||||
TrueType-Schriften. In manchen Gebieten müssen Sie mit dem
|
||||
Befehl "chcp" die aktive DOS-OEM-Codepage in die
|
||||
-System-ANSI-Codepage des Systems ändern, da dos2unix Letztere
|
||||
verwendet.
|
||||
|
||||
Der Nachteil von ANSI ist, dass internationale Dateinamen nicht
|
||||
korrekt dargestellt werden, wenn darin Zeichen enthalten sind,
|
||||
die nicht in der im System voreingestellten Codepage enthalten
|
||||
sind. Stattdessen wird entweder ein Fragezeichen oder ein
|
||||
falsches Zeichen angezeigt. Sofern Sie nicht mit fremden
|
||||
Dateinamen arbeiten, ist diese Methode in Ordnung.
|
||||
|
||||
unicode, unicodebom
|
||||
Der Vorteil von Unicode (dem Windows-Namen für UTF-16) ist die
|
||||
üblicherweise korrekte Textdarstellung. Eine Änderung der
|
||||
aktiven Codepage ist nicht erforderlich. Sie müssen die
|
||||
Schriftart der Konsole auf eine TrueType-Schrift einstellen,
|
||||
damit internationale Zeichen richtig angezeigt werden können.
|
||||
Sollte ein Zeichen in einer TrueType-Schrift nicht enthalten
|
||||
sein, wird ein kleines Quadrat angezeigt, das gelegentlich noch
|
||||
ein Fragezeichen enthält.
|
||||
|
||||
Wenn Sie die ConEmu-Konsole nutzen, wird der gesamte Text
|
||||
korrekt dargestellt, da ConEmu automatisch eine passende Schrift
|
||||
wählt.
|
||||
|
||||
Nachteilig für Unicode ist, dass es nicht zu ASCII kompatibel
|
||||
ist. Die Ausgabe ist schwer zu verarbeiten, wenn sie in ein
|
||||
anderes Programm oder eine Datei weitergeleitet wird.
|
||||
|
||||
Wenn die Methode "unicodebom" verwendet wird, dann wird dem
|
||||
Unicode-Text eine BOM (Markierung der Bytereihenfolge)
|
||||
vorangestellt. Eine BOM ist für korrekte Um- oder Weiterleitung
|
||||
in der PowerShell notwendig.
|
||||
|
||||
utf8, utf8bom
|
||||
Der Vorteil von UTF-8 ist die ASCII-Kompatibilität. Sie müssen
|
||||
die Schriftart der Konsole auf eine TrueType-Schrift setzen.
|
||||
Dadurch wird der Text ähnlich wie in der "unicode"-Kodierung
|
||||
dargestellt.
|
||||
|
||||
Der Nachteil ist die falsche Darstellung aller
|
||||
Nicht-ASCII-Zeichen, wenn Sie die Standard-Rasterschrift
|
||||
verwenden. Nicht nur Unicode-Dateinamen, sondern auch übersetzte
|
||||
Meldungen werden unlesbar. Auf einem Windows-System, das für
|
||||
eine ostasiatische Region eingerichtet wurde, wird die Konsole
|
||||
bei der Anzeige von Meldungen deutlich flackern.
|
||||
|
||||
In einer ConEmu-Konsole funktioniert die UTF-8-Kodierung gut.
|
||||
|
||||
Wenn die Methode "utf8bom" verwendet wird, dann wird dem
|
||||
UTF-8-Text eine BOM (Markierung der Bytereihenfolge)
|
||||
vorangestellt. Eine BOM ist für korrekte Um- oder Weiterleitung
|
||||
in der PowerShell notwendig.
|
||||
|
||||
Die Standardkodierung kann durch Setzen der Umgebungsvariable
|
||||
DOS2UNIX_DISPLAY_ENC auf "unicode", "unicodebom", "utf8" oder "utf8"
|
||||
geändert werden.
|
||||
|
||||
-e, --add-eol
|
||||
fügt einen Zeilenumbruch nach der letzten Zeile hinzu, falls ein
|
||||
solcher nicht existiert. Dies funktioniert in jeder Umwandlung.
|
||||
|
||||
Einer Datei, die aus dem DOS- ins Unix-Format umgewandelt wurde,
|
||||
kann ein Zeilenumbruch nach der letzten Zeile fehlen. Es gibt
|
||||
Texteditoren, die Dateien ohne diesen angehängten Zeilenumbruch
|
||||
schreiben. Einige Unix-Programme haben jedoch Probleme mit der
|
||||
Verarbeitung dieser Dateien, da der POSIX-Standard definiert, dass
|
||||
jede Zeile in einer Textdatei mit einem abschließenden
|
||||
Zeilenvorschubzeichen enden muss. Beispielsweise kann es beim
|
||||
Aneinanderhängen von solche Dateien zu unerwarteten Ergebnissen
|
||||
kommen.
|
||||
|
||||
--error-binary
|
||||
liefert einen Fehler zurück, wenn eine Binärdatei übersprungen wird.
|
||||
|
||||
-f, --force
|
||||
erzwingt die Umwandlung von Binärdateien.
|
||||
|
||||
-gb, --gb18030
|
||||
wandelt unter Windows UTF-16-Dateien standardmäßig in UTF-8 um,
|
||||
ungeachtet der Einstellung der Locale. Verwenden Sie diese Option
|
||||
zum umwandeln von UTF-16-Dateien in GB18030. Diese Option ist nur
|
||||
unter Windows verfügbar. Siehe auch Abschnitt GB18030.
|
||||
|
||||
-h, --help
|
||||
zeigt eine Hilfe an und beendet das Programm.
|
||||
|
||||
-i[SCHALTER], --info[=SCHALTER] DATEI …
|
||||
zeigt Dateiinformationen an. Es wird keine Umwandlung vorgenommen.
|
||||
|
||||
Die Ausgabe der Informationen geschieht in der folgenden
|
||||
Reihenfolge: Anzahl der DOS-Zeilenumbrüche, Anzahl der
|
||||
Unix-Zeilenumbrüche, Anzahl der Mac-Zeilenumbrüche, Markierung der
|
||||
Bytereihenfolge, Text- oder Binärformat, Dateiname.
|
||||
|
||||
Beispielausgabe:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Beachten sie, dass manchmal eine Binärdatei fälschlicherweise als
|
||||
Textdatei erkannt wird. Siehe auch Option "-s".
|
||||
|
||||
Wenn zusätzlich die Option "-e" oder "--add-eol" verwendet wird,
|
||||
dann wird auch der Typ des Zeilenumbruchs der letzten Zeile
|
||||
ausgegeben, oder "noeol", falls kein solcher Zeilenumbruch
|
||||
existiert.
|
||||
|
||||
Beispielausgabe:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Optionale zusätzliche Schalter können gesetzt werden, um die Ausgabe
|
||||
anzupassen. Einer oder mehrere Schalter können hinzugefügt werden.
|
||||
|
||||
0 gibt die Zeilen zur Dateiinformation mit einem Null-Zeichen am
|
||||
Ende anstelle eines Zeilenvorschub-Zeichens aus. Dies ermöglicht
|
||||
die korrekte Interpretation von Leer- und Anführungszeichen in
|
||||
Dateinamen, wenn der Schalter c verwendet wird. Verwenden Sie
|
||||
diesen Schalter in Kombination mit der xargs(1)-Option -0 oder
|
||||
"--null".
|
||||
|
||||
d gibt die Anzahl der DOS-Zeilenumbrüche aus.
|
||||
|
||||
u gibt die Anzahl der Unix-Zeilenumbrüche aus.
|
||||
|
||||
m gibt die Anzahl der Mac-Zeilenumbrüche aus.
|
||||
|
||||
b gibt die Markierung der Bytereihenfolge aus.
|
||||
|
||||
t zeigt an, ob es sich um eine Text- oder eine Binärdatei handelt.
|
||||
|
||||
e gibt den Typ des Zeilenumbruchs der letzten Zeile aus, oder
|
||||
"noeol", falls kein solcher Zeilenumbruch existiert.
|
||||
|
||||
c gibt nur die Dateien aus, die umgewandelt werden würden.
|
||||
|
||||
Mit dem Schalter "c" gibt dos2unix nur die Dateien aus, die
|
||||
DOS-Zeilenumbrüche enthalten, unix2dos nur die Dateien mit
|
||||
Unix-Zeilenumbrüchen.
|
||||
|
||||
Wenn zusätzlich die Option "-e" oder "--add-eol" verwendet wird,
|
||||
dann werden auch die Dateien ausgegeben, denen der Zeilenumbruch
|
||||
an der letzten Zeile fehlt.
|
||||
|
||||
h gibt eine Kopfzeile aus.
|
||||
|
||||
p zeigt Dateinamen ohne Pfade an.
|
||||
|
||||
Beispiele:
|
||||
|
||||
Informationen zu allen *.txt-Dateien anzeigen:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Nur die Anzahl der DOS-Zeilenumbrüche und Unix-Zeilenumbrüche
|
||||
anzeigen:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Nur die Markierung der Bytereihenfolge anzeigen:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Die Dateien auflisten, die DOS-Zeilenumbrüche enthalten:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Die Dateien auflisten, die Unix-Zeilenumbrüche enthalten:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Die Dateien auflisten, die DOS-Zeilenumbrüche enthalten oder bei
|
||||
denen der Zeilenumbruch nach der letzten Zeile fehlt:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Nur Dateien umwandeln, die DOS-Zeilenumbrüche enthalten und die
|
||||
anderen Dateien unverändert belassen:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Nach Textdateien suchen, die DOS-Zeilenumbrüche enthalten:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
übernimmt den Zeitstempel der Eingabedatei in die Ausgabedatei.
|
||||
|
||||
-L, --license
|
||||
zeigt die Lizenz des Programms an.
|
||||
|
||||
-l, --newline
|
||||
fügt eine zusätzliche neue Zeile hinzu.
|
||||
|
||||
dos2unix: Nur DOS-Zeilenumbrüche werden in Unix-Zeilenumbrüche
|
||||
umgewandelt. Im Mac-Modus werden nur Mac-Zeilenumbrüche in
|
||||
Unix-Zeilenumbrüche umgewandelt.
|
||||
|
||||
unix2dos: Nur Unix-Zeilenumbrüche werden in DOS-Zeilenumbrüche
|
||||
umgewandelt. Im Mac-Modus werden nur Unix-Zeilenumbrüche in
|
||||
Mac-Zeilenumbrüche umgewandelt.
|
||||
|
||||
-m, --add-bom
|
||||
schreibt eine Markierung der Bytereihenfolge (BOM) in die
|
||||
Ausgabedatei. In der Voreinstellung wird eine UTF-8-BOM geschrieben.
|
||||
|
||||
Wenn die Eingabedatei in UTF-16 kodiert ist und die Option "-u"
|
||||
verwendet wird, wird eine UTF-16-BOM geschrieben.
|
||||
|
||||
Verwenden Sie diese Option niemals, wenn die Kodierung der
|
||||
Ausgabedatei nicht UTF-8, UTF-16 oder GB 18030 ist. Weitere
|
||||
Informationen finden Sie im Abschnitt UNICODE.
|
||||
|
||||
-n, --newfile EINGABEDATEI AUSGABEDATEI …
|
||||
Neue-Datei-Modus. Die EINGABEDATEI wird umgewandelt und in die
|
||||
AUSGABEDATEI geschrieben. Die Dateinamen müssen paarweise angegeben
|
||||
werden. Platzhalter sollten *nicht* verwendet werden, sonst werden
|
||||
Sie Ihre Dateien *verlieren*.
|
||||
|
||||
Der Benutzer, der die Umwandlung im Neue-Datei-Modus startet, wird
|
||||
Besitzer der umgewandelten Datei. Die Lese- und Schreibrechte werden
|
||||
aus den Zugriffsrechten der Originaldatei minus der umask(1) der
|
||||
Person ermittelt, die die Umwandlung ausgeführt hat.
|
||||
|
||||
--no-allow-chown
|
||||
verhindert die Änderung des Eigentümers der Datei im
|
||||
Alte-Datei-Modus (Voreinstellung).
|
||||
|
||||
bricht die Umwandlung ab, wenn der Eigentümer und/oder die Gruppe
|
||||
der Originaldatei im Alte-Datei-Modus nicht erhalten werden kann.
|
||||
Siehe auch die Optionen "-o" und "-n". Diese Option ist nur
|
||||
verfügbar, wenn dos2unix über Unterstützung für die Erhaltung des
|
||||
Eigentümers und der Gruppe von Dateien verfügt.
|
||||
|
||||
--no-add-eol
|
||||
fügt keinen Zeilenumbruch nach der letzten Zeile hinzu, falls ein
|
||||
solcher nicht existiert (Vorgabe).
|
||||
|
||||
--no-error-binary
|
||||
liefert keinen Fehler zurück, wenn eine Binärdatei übersprungen wird
|
||||
(Vorgabe).
|
||||
|
||||
-O, --to-stdout
|
||||
schreibt wie ein Unix-Filter in die Standardausgabe. Mit der Option
|
||||
"-o" können Sie zum Alte-Datei-Modus (Ersetzungsmodus) zurückkehren.
|
||||
|
||||
In Kombination mit der Option "-e" können Dateien korrekt
|
||||
aneinandergehängt werden. Weder werden Zeilen ohne Umbruch
|
||||
zusammengeführt, noch werden Unicode-Markierungen der
|
||||
Bytereihenfolge mitten in die verkettete Datei gesetzt. Beispiel:
|
||||
|
||||
dos2unix -e -O Datei1.txt Datei2.txt > Ausgabe.txt
|
||||
|
||||
-o, --oldfile DATEI …
|
||||
Alte-Datei-Modus. Die DATEI wird umgewandelt und durch die
|
||||
Ausgabedatei überschrieben. Per Vorgabe werden Umwandlungen in
|
||||
diesem Modus ausgeführt. Platzhalter sind verwendbar.
|
||||
|
||||
Im Alte-Datei-Modus (Ersetzungsmodus) erhalten die umgewandelten
|
||||
Dateien den gleichen Eigentümer, die gleiche Gruppe und die gleichen
|
||||
Lese- und Schreibberechtigungen wie die Originaldatei, auch wenn die
|
||||
Datei von einem anderen Benutzer umgewandelt wird, der Schreibrechte
|
||||
für die Datei hat (zum Beispiel der Systemadministrator). Die
|
||||
Umwandlung wird abgebrochen, wenn es nicht möglich ist, die
|
||||
originalen Werte beizubehalten. Die Änderung des Eigentümers könnte
|
||||
zum Beispiel bewirken, dass der ursprüngliche Eigentümer die Datei
|
||||
nicht mehr lesen kann. Die Änderung der Gruppe könnte ein
|
||||
Sicherheitsrisiko sein, da die Datei vielleicht für Benutzer lesbar
|
||||
wird, für die sie nicht bestimmt ist. Die Beibehaltung von
|
||||
Eigentümer, Gruppe und Schreib- und Leserechten wird nur unter Unix
|
||||
unterstützt.
|
||||
|
||||
Um herauszufinden, ob dos2unix über Unterstützung für die Erhaltung
|
||||
von Eigentümer und Gruppe von Dateien verfügt, rufen Sie "dos2unix
|
||||
-V" auf.
|
||||
|
||||
Die Umwandlung führt stets über eine temporäre Datei. Tritt im Laufe
|
||||
der Umwandlung ein Fehler auf, wird die temporäre Datei gelöscht und
|
||||
die Originaldatei bleibt intakt. War die Umwandlung erfolgreich,
|
||||
wird die Originaldatei durch die temporäre Datei ersetzt. Sie können
|
||||
Schreibrechte für die Originaldatei haben, aber keine Rechte, um die
|
||||
gleichen Eigentumsverhältnisse wie die der Originaldatei für die
|
||||
temporäre Datei festzulegen. Das bedeutet, dass Sie Eigentümer und
|
||||
Gruppe der Originaldatei nicht bewahren können. In diesem Fall
|
||||
können Sie die Option "--allow-chown" verwenden, um die Umwandlung
|
||||
fortzusetzen:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Eine weitere Option ist der Neue-Datei-Modus:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Der Vorteil der Option --allow-chown ist, dass Sie Platzhalter
|
||||
verwenden können und die Eigentumsverhältnisse bewahrt bleiben,
|
||||
sofern möglich.
|
||||
|
||||
-q, --quiet
|
||||
aktiviert den stillen Modus, in dem alle Warnungen und sonstigen
|
||||
Meldungen unterdrückt werden. Der Rückgabewert ist 0, außer wenn
|
||||
fehlerhafte Befehlszeilenoptionen angegeben werden.
|
||||
|
||||
-r, --remove-bom
|
||||
entfernt die Markierung der Bytereihenfolge (BOM). Es wird keine BOM
|
||||
in die Ausgabedatei geschrieben. Dies ist das Standardverhalten beim
|
||||
Umwandeln von Unix-Zeilenumbrüchen. Siehe auch die Option "-b".
|
||||
|
||||
-s, --safe
|
||||
überspringt Binärdateien (Vorgabe).
|
||||
|
||||
Binärdateien werden übersprungen, damit unerwünschtes Fehlverhalten
|
||||
vermieden wird. Denken Sie daran, dass die Erkennung nicht 100%
|
||||
sicher funktioniert. Die übergebenen Dateien werden auf Binärsymbole
|
||||
überprüft, die typischerweise in Textdateien nicht vorkommen. Es ist
|
||||
jedoch möglich, dass eine Binärdatei ausschließlich gewöhnliche
|
||||
Textzeichen enthält. Eine solche Binärdatei wird dann
|
||||
fälschlicherweise als Textdatei angesehen.
|
||||
|
||||
Standardmäßig wird kein Fehler zurückgeliefert, wenn eine Binärdatei
|
||||
übersprungen wird. Bei Verwendung der Option --error-binary wird ein
|
||||
Fehler zurückgeliefert.
|
||||
|
||||
-u, --keep-utf16
|
||||
erhält die originale UTF-16-Kodierung der Eingabedatei. Die
|
||||
Ausgabedatei wird in der gleichen UTF-16-Kodierung geschrieben
|
||||
(Little-Endian- oder Big-Endian-Bytereihenfolge) wie die
|
||||
Eingabedatei. Dies verhindert die Umwandlung in UTF-8. Eine
|
||||
UTF-16-BOM wird dementsprechend geschrieben. Diese Option kann durch
|
||||
Angabe der Option "-ascii" deaktiviert werden.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
nimmt an, dass die Eingabedatei das Format UTF-16LE hat.
|
||||
|
||||
Wenn die Eingabedatei eine Markierung der Bytereihenfolge enthält
|
||||
(BOM), dann hat die BOM Vorrang vor dieser Option.
|
||||
|
||||
Durch eine falsche Annahme (die Eingabedatei war nicht in UTF-16LE
|
||||
kodiert) mit erfolgreicher Umwandlung erhalten Sie eine
|
||||
UTF-8-Ausgabedatei mit fehlerhaftem Text. Sie können die
|
||||
fehlgeschlagene Umwandlung mit iconv(1) rückgängig machen, indem Sie
|
||||
die Rückumwandlung von UTF-8 nach UTF-16LE vornehmen. Dadurch
|
||||
gewinnen Sie die Originaldatei zurück.
|
||||
|
||||
Die Annahme von UTF-16LE wirkt wie ein *Umwandlungsmodus*. Beim
|
||||
Wechsel zum vorgegebenen *ascii*-Modus wird die UTF16LE-Annahme
|
||||
deaktiviert.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
nimmt an, dass die Eingabedatei das Format UTF-16BE hat.
|
||||
|
||||
Diese Option ist gleichbedeutend mit "-ul".
|
||||
|
||||
-v, --verbose
|
||||
zeigt ausführliche Meldungen an. Zusätzliche Informationen werden zu
|
||||
den Markierungen der Bytereihenfolge (BOM) und zur Anzahl der
|
||||
umgewandelten Zeilenumbrüche angezeigt.
|
||||
|
||||
-F, --follow-symlink
|
||||
folgt symbolischen Links und wandelt die Zieldateien um.
|
||||
|
||||
-R, --replace-symlink
|
||||
ersetzt symbolische Links durch die umgewandelten Dateien (die
|
||||
originalen Zieldateien bleiben unverändert).
|
||||
|
||||
-S, --skip-symlink
|
||||
erhält symbolische Links als solche und lässt die Ziele unverändert
|
||||
(Vorgabe).
|
||||
|
||||
-V, --version
|
||||
zeigt Versionsinformationen an und beendet das Programm.
|
||||
|
||||
MAC-MODUS
|
||||
In der Voreinstellung werden Zeilenumbrüche von DOS nach Unix und
|
||||
umgekehrt umgewandelt. Mac-Zeilenumbrüche werden nicht verändert.
|
||||
|
||||
Im Mac-Modus werden Zeilenumbrüche von Mac nach Unix und umgekehrt
|
||||
umgewandelt. DOS-Zeilenumbrüche werden nicht verändert.
|
||||
|
||||
Um das Programm im Mac-Modus auszuführen, verwenden Sie die
|
||||
Befehlszeilenoption "-c mac" oder die Befehle "mac2unix" oder
|
||||
"unix2mac".
|
||||
|
||||
UMWANDLUNGSMODI
|
||||
ascii
|
||||
Dies ist der vorgegebene Umwandlungsmodus. Dieser Modus dient zum
|
||||
Umwandeln von ASCII- und ASCII-kompatibel kodierten Dateien, wie
|
||||
UTF-8. Durch Aktivierung des ascii-Modus werden die Modi 7bit und
|
||||
iso deaktiviert.
|
||||
|
||||
Falls dos2unix über Unterstützung für UTF-16 verfügt, werden
|
||||
UTF-16-kodierte Dateien auf POSIX-Systemen in die aktuelle
|
||||
Zeichenkodierung der Locale und unter Windows in UTF-8 umgewandelt.
|
||||
Die Aktivierung des ascii-Modus deaktiviert die Option "-u" zum
|
||||
Erhalten der UTF-16-Kodierung sowie die Optionen "-ul" und "-ub",
|
||||
welche davon ausgehen, dass die Eingabe in UTF-16 kodiert ist. Geben
|
||||
Sie den Befehl "dos2unix -V" ein, um zu sehen, ob dos2unix UTF-16
|
||||
unterstützt. Weitere Informationen hierzu finden Sie im Abschnitt
|
||||
UNICODE.
|
||||
|
||||
7bit
|
||||
In diesem Modus werden alle Nicht-ASCII-Zeichen aus 8 Bit in das
|
||||
7-Bit-Bitmuster umgewandelt.
|
||||
|
||||
iso Die Zeichen werden aus dem DOS-Zeichensatz (der Codepage) in den
|
||||
ISO-Zeichensatz ISO-8859-1 (Latin-1) in Unix umgewandelt.
|
||||
DOS-Zeichen ohne Äquivalent in ISO-8859-1, für die die Umwandlung
|
||||
nicht möglich ist, werden durch einen Punkt ersetzt. Gleiches gilt
|
||||
für ISO-8859-1-Zeichen ohne DOS-Gegenstück.
|
||||
|
||||
Wenn nur die Option "-iso" angegeben ist, versucht dos2unix die
|
||||
aktive Codepage selbst zu ermitteln. Sollte dies nicht möglich sein,
|
||||
wird die Standard-Codepage CP437 verwendet, welche hauptsächlich in
|
||||
den USA eingesetzt wird. Um eine bestimmte Codepage zu erzwingen,
|
||||
verwenden Sie die Optionen -437 (US), -850 (Westeuropäisch), -860
|
||||
(Portugiesisch), -863 (Kanadisches Französisch) oder -865
|
||||
(Skandinavisch). Die Windows-Codepage CP1252 (Westeuropäisch) wird
|
||||
durch die Option -1252 unterstützt.
|
||||
|
||||
Wenden Sie niemals die ISO-Umwandlung auf Unicode-Textdateien an. In
|
||||
UTF-8 kodierte Dateien werden dadurch beschädigt.
|
||||
|
||||
Einige Beispiele:
|
||||
|
||||
Umwandlung aus der vorgegebenen DOS-Codepage nach Unix Latin-1:
|
||||
|
||||
dos2unix -iso -n in.txt ausgabe.txt
|
||||
|
||||
Umwandlung von DOS CP850 nach Unix Latin-1:
|
||||
|
||||
dos2unix -850 -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Windows CP1252 nach Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Windows CP1252 nach Unix UTF-8 (Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 eingabe.txt | dos2unix > ausgabe.txt
|
||||
|
||||
Umwandlung von Unix Latin-1 in die vorgegebene DOS-Codepage:
|
||||
|
||||
unix2dos -iso -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Unix Latin-1 nach DOS CP850:
|
||||
|
||||
unix2dos -850 -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Unix Latin-1 nach Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Unix UTF-8 (Unicode) nach Windows CP1252:
|
||||
|
||||
unix2dos < eingabe.txt | iconv -f UTF-8 -t CP1252 > ausgabe.txt
|
||||
|
||||
Siehe auch <https://czyborra.com/charsets/codepages.html> und
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Zeichenkodierungen
|
||||
Es gibt verschiedene Unicode-Zeichenkodierungen. Unter Unix und Linux
|
||||
sind Unicode-Dateien typischerweise in UTF-8 kodiert. Unter Windows
|
||||
können Textdateien in UTF-8, UTF-16 oder UTF-16 in
|
||||
Big-Endian-Bytereihenfolge kodiert sein, liegen aber meist im Format
|
||||
UTF-16 vor.
|
||||
|
||||
Umwandlung
|
||||
Unicode-Textdateien können DOS-, Unix- oder Mac-Zeilenumbrüche
|
||||
enthalten, so wie ASCII-Textdateien.
|
||||
|
||||
Alle Versionen von dos2unix und unix2dos können UTF-8-kodierte Dateien
|
||||
umwandeln, weil UTF-8 im Hinblick auf Abwärtskompatibilität mit ASCII
|
||||
entwickelt wurde.
|
||||
|
||||
Dos2unix und unix2dos mit Unterstützung für UTF-16 können in UTF-16
|
||||
kodierte Dateien in Little-Endian- und Big-Endian-Bytereihenfolge lesen.
|
||||
Um festzustellen, ob dos2unix mit UTF-16-Unterstützung kompiliert wurde,
|
||||
geben Sie "dos2unix -V" ein.
|
||||
|
||||
Unter Unix/Linux werden UTF-16 kodierte Dateien standardmäßig in die
|
||||
Zeichenkodierung entsprechend der Locale umgewandelt. Mit dem Befehl
|
||||
locale(1) können Sie herausfinden, wie die Zeichenkodierung der Locale
|
||||
eingestellt ist. Wenn eine Umwandlung nicht möglich ist, verursacht dies
|
||||
einen Umwandlungsfehler, wodurch die Datei übersprungen wird.
|
||||
|
||||
Unter Windows werden UTF-16-Dateien standardmäßig in UTF-8 umgewandelt.
|
||||
In UTF-8 formatierte Textdateien werden von Windows und Unix/Linux
|
||||
gleichermaßen unterstützt.
|
||||
|
||||
Die Kodierungen UTF-16 und UTF-8 sind vollständig kompatibel, daher wird
|
||||
bei der Umwandlung keinerlei Text verlorengehen. Sollte bei der
|
||||
Umwandlung von UTF-16 in UTF-8 ein Problem auftreten, beispielsweise
|
||||
wenn die UTF-16-kodierte Eingabedatei einen Fehler enthält, dann wird
|
||||
diese Datei übersprungen.
|
||||
|
||||
Wenn die Option "-u" verwendet wird, wird die Ausgabedatei in der
|
||||
gleichen UTF-16-Kodierung wie die Eingabedatei geschrieben. Die Option
|
||||
"-u" verhindert die Umwandlung in UTF-8.
|
||||
|
||||
Dos2unix und unix2dos bieten keine Option zur Umwandlung von
|
||||
UTF-8-Dateien in UTF-16.
|
||||
|
||||
Umwandlungen im ISO- und 7bit-Modus funktionieren mit UTF-16-Dateien
|
||||
nicht.
|
||||
|
||||
Markierung der Bytereihenfolge
|
||||
Unicode-Textdateien unter Windows haben typischerweise eine Markierung
|
||||
der Bytereihenfolge (BOM), da viele Windows-Programme (zum Beispiel
|
||||
Notepad) solche BOMs standardmäßig hinzufügen. Weitere Informationen
|
||||
hierzu finden Sie auf <https://de.wikipedia.org/wiki/Byte-Reihenfolge>.
|
||||
|
||||
Unter Unix haben Textdateien üblicherweise keine BOM. Es wird
|
||||
stattdessen angenommen, dass Textdateien in der Zeichenkodierung
|
||||
entsprechend der Spracheinstellung vorliegen.
|
||||
|
||||
Dos2unix kann nur dann erkennen, ob eine Datei UTF-16-kodiert ist, wenn
|
||||
die Datei eine BOM enthält. Ist dies nicht der Fall, nimmt dos2unix an,
|
||||
dass es sich um eine Binärdatei handelt.
|
||||
|
||||
Verwenden Sie die Optionen "-ul" oder "-ub", um eine UTF-16-Datei ohne
|
||||
BOM umzuwandeln.
|
||||
|
||||
Dos2unix schreibt in der Voreinstellung keine BOM in die Ausgabedatei.
|
||||
Mit der Option "-b" schreibt dos2unix eine BOM, wenn die Eingabedatei
|
||||
ebenfalls eine BOM hat.
|
||||
|
||||
Unix2dos schreibt in der Voreinstellung eine BOM in die Ausgabedatei,
|
||||
wenn die Eingabedatei ebenfalls eine solche Markierung hat. Verwenden
|
||||
Sie die Option "-r", um die BOM zu entfernen.
|
||||
|
||||
Dos2unix und unix2dos schreiben immer eine BOM, wenn die Option "-m"
|
||||
angegeben ist.
|
||||
|
||||
Unicode-Dateinamen unter Windows
|
||||
Dos2unix verfügt über optionale Unterstützung für das Lesen und
|
||||
Schreiben von Unicode-Dateinamen in der Windows-Eingabeaufforderung.
|
||||
Dadurch kann dos2unix Dateien öffnen, deren Namen Zeichen enthalten, die
|
||||
nicht zur Standard-ANSI-Codepage des Systems gehören. Geben Sie
|
||||
"dos2unix -V" ein, um zu sehen, ob dos2unix für Windows mit
|
||||
Unterstützung für Unicode-Dateinamen erstellt wurde.
|
||||
|
||||
Die Anzeige von Unicode-Dateinamen in einer Windows-Konsole ist
|
||||
gelegentlich nicht fehlerfrei, siehe die Option "-D", "--display-enc".
|
||||
Die Dateinamen können falsch dargestellt werden, allerdings werden die
|
||||
Dateien mit deren korrekten Namen gespeichert.
|
||||
|
||||
Unicode-Beispiele
|
||||
Umwandlung von Windows UTF-16 (mit BOM) nach Unix UTF-8:
|
||||
|
||||
dos2unix -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Windows UTF-16LE (ohne BOM) nach Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Unix UTF-8 nach Windows UTF-8 mit BOM:
|
||||
|
||||
unix2dos -m -n eingabe.txt ausgabe.txt
|
||||
|
||||
Umwandlung von Unix UTF-8 nach Windows UTF-16:
|
||||
|
||||
unix2dos < eingabe.txt | iconv -f UTF-8 -t UTF-16 > ausgabe.txt
|
||||
|
||||
GB18030
|
||||
GB18030 ist ein Standard der chinesischen Regierung. Eine Teilmenge des
|
||||
in GB18030 definierten Standards ist offiziell für alle in China
|
||||
verkauften Softwareprodukte vorgeschrieben. Siehe auch
|
||||
<https://de.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 ist vollständig zu Unicode kompatibel und kann als
|
||||
Unicode-Umwandlungsformat betrachtet werden. Wie auch UTF-8 ist GB18030
|
||||
kompatibel zu ASCII. Ebenfalls kompatibel ist es zur Codepage 936 von
|
||||
Windows, auch als GBK bekannt.
|
||||
|
||||
Unter Unix/Linux werden UTF-16-Dateien in GB18030 umgewandelt, wenn die
|
||||
Einstellung der Locale auf GB18030 gesetzt ist. Beachten Sie, dass dies
|
||||
nur funktioniert, wenn die Locale vom System unterstützt wird. Mit dem
|
||||
Befehl "locale -a" erhalten Sie eine Liste der unterstützten Locales.
|
||||
|
||||
Unter Windows benötigen Sie die Option "-gb", um UTF-16-Dateien in
|
||||
GB18030 umwandeln zu können.
|
||||
|
||||
In GB 18030 kodierte Dateien haben wie Unicode-Dateien eine Markierung
|
||||
der Bytereihenfolge (BOM).
|
||||
|
||||
BEISPIELE
|
||||
Aus der Standardeingabe lesen und in die Standardausgabe schreiben:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
a.txt umwandeln und ersetzen, b.txt umwandeln und ersetzen:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
a.txt im ascii-Modus umwandeln und ersetzen:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
a.txt im ascii-Modus umwandeln und ersetzen, b.txt im 7bit-Modus
|
||||
umwandeln und ersetzen:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
a.txt aus dem Mac- in das Unix-Format umwandeln:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
a.txt aus dem Unix- in das Mac-Format umwandeln:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
a.txt unter Beibehaltung des ursprünglichen Zeitstempels umwandeln:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
a.txt umwandeln und das Ergebnis nach e.txt schreiben:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
a.txt umwandeln und das Ergebnis nach e.txt schreiben, wobei e.txt den
|
||||
gleichen Zeitstempel erhält wie a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
a.txt umwandeln und ersetzen, b.txt umwandeln und das Ergebnis nach
|
||||
e.txt schreiben:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
c.txt umwandeln und das Ergebnis nach e.txt schreiben, a.txt umwandeln
|
||||
und ersetzen, b.txt umwandeln und ersetzen, d.txt umwandeln und das
|
||||
Ergebnis nach f.txt schreiben:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
REKURSIVE UMWANDLUNG
|
||||
In einer Unix-Shell können Sie dos2unix zusammen mit den Befehlen
|
||||
find(1) und xargs(1) verwenden, um Textdateien in einem Verzeichnisbaum
|
||||
rekursiv umzuwandeln. Um beispielsweise alle *.txt-Dateien im aktuellen
|
||||
Verzeichnis und dessen Unterverzeichnissen umzuwandeln, geben Sie
|
||||
Folgendes ein:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
Die find(1)-Option "-print0" und die korrespondierende xargs(1)-Option
|
||||
-0 werden für Dateien benötigt, deren Namen Leerzeichen oder
|
||||
Anführungszeichen enthalten. Ansonsten können diese Optionen weggelassen
|
||||
werden. Eine weitere Möglichkeit ist, find(1) zusammen mit der Option
|
||||
"-exec" zu verwenden:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
In einer Windows-Eingabeaufforderung kann der folgende Befehl verwendet
|
||||
werden:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
In der Windows PowerShell können Sie folgenden Befehl verwenden:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOKALISIERUNG
|
||||
LANG
|
||||
Die primäre Sprache wird durch die Umgebungsvariable LANG
|
||||
festgelegt. Diese Variable besteht aus mehreren Teilen: Der erste
|
||||
Teil besteht aus zwei Kleinbuchstaben, die den Sprachcode angeben.
|
||||
Der zweite Teil ist optional und bezeichnet den Ländercode in
|
||||
Großbuchstaben, vom davor stehenden Sprachcode durch einen
|
||||
Unterstrich getrennt. Der dritte Teil ist ebenfalls optional und
|
||||
gibt die Zeichenkodierung an, vom Ländercode durch einen Punkt
|
||||
getrennt. Einige Beispiele für Standard-POSIX-Shells:
|
||||
|
||||
export LANG=de Deutsch
|
||||
export LANG=de_DE Deutsch, Deutschland
|
||||
export LANG=de_AT Deutsch, Österreich
|
||||
export LANG=es_ES Spanisch, Spanien
|
||||
export LANG=es_MX Spanisch, Mexiko
|
||||
export LANG=en_US.iso88591 Englisch, USA, Latin-1-Zeichenkodierung
|
||||
export LANG=en_GB.UTF-8 Englisch, GB, UTF-8-Zeichenkodierung
|
||||
|
||||
Eine vollständige Liste der Sprachen und Ländercodes finden Sie im
|
||||
Gettext-Handbuch:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
Auf Unix-Systemen erhalten Sie mit dem Befehl locale(1) spezifische
|
||||
Informationen zu den Spracheinstellungen.
|
||||
|
||||
LANGUAGE
|
||||
Mit der Umgebungsvariable LANGUAGE können Sie eine Prioritätenliste
|
||||
für Sprachen übergeben, die Sie durch Doppelpunkte voneinander
|
||||
trennen. Dos2unix gibt LANGUAGE vor LANG den Vorzug, zum Beispiel
|
||||
bei Deutsch vor Niederländisch: "LANGUAGE=de:nl". Sie müssen
|
||||
zunächst die Lokalisierung aktivieren, indem Sie die Variable LANG
|
||||
(oder LC_ALL) auf einen anderen Wert als »C« setzen, bevor Sie die
|
||||
Liste der Sprachprioritäten mit der Variable LANGUAGE nutzen können.
|
||||
Weitere Informationen finden Sie im Gettext-Handbuch:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Falls Sie eine Sprache auswählen, die nicht verfügbar ist, erhalten
|
||||
Sie die Standardmeldungen in englischer Sprache.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Durch die Umgebungsvariable DOS2UNIX_LOCALEDIR wird LOCALEDIR
|
||||
während der Kompilierung übergangen. LOCALEDIR wird verwendet, um
|
||||
Sprachdateien zu finden. Der GNU-Standardwert ist
|
||||
"/usr/local/share/locale". Die Option --version zeigt das verwendete
|
||||
LOCALEDIR an.
|
||||
|
||||
Beispiel (POSIX-Shell):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
RÜCKGABEWERT
|
||||
Bei Erfolg wird 0 zurückgegeben. Bei aufgetretenen Systemfehlern wird
|
||||
der letzte Systemfehler zurückgegeben. Für alle anderen Fehler wird 1
|
||||
zurückgegeben.
|
||||
|
||||
Der Rückgabewert ist im stillen Modus stets 0, außer wenn fehlerhafte
|
||||
Befehlszeilenoptionen verwendet werden.
|
||||
|
||||
STANDARDS
|
||||
<https://de.wikipedia.org/wiki/Textdatei>
|
||||
|
||||
<https://de.wikipedia.org/wiki/Wagenr%C3%BCcklauf>
|
||||
|
||||
<https://de.wikipedia.org/wiki/Zeilenumbruch>
|
||||
|
||||
<https://de.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTOREN
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben
|
||||
(Mac2unix-Modus) - <wuebben@kde.org>, Christian Wurll (Extra
|
||||
Zeilenumbruch) - <wurll@ira.uka.de>, Erwin Waterlander -
|
||||
<waterlan@xs4all.nl> (Betreuer)
|
||||
|
||||
Projektseite: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge-Seite: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
SIEHE AUCH
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - DOS/MAC to UNIX and vice versa text file format converter</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NAME">NAME</a></li>
|
||||
<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
|
||||
<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
|
||||
<li><a href="#OPTIONS">OPTIONS</a></li>
|
||||
<li><a href="#MAC-MODE">MAC MODE</a></li>
|
||||
<li><a href="#CONVERSION-MODES">CONVERSION MODES</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Encodings">Encodings</a></li>
|
||||
<li><a href="#Conversion">Conversion</a></li>
|
||||
<li><a href="#Byte-Order-Mark">Byte Order Mark</a></li>
|
||||
<li><a href="#Unicode-file-names-on-Windows">Unicode file names on Windows</a></li>
|
||||
<li><a href="#Unicode-examples">Unicode examples</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EXAMPLES">EXAMPLES</a></li>
|
||||
<li><a href="#RECURSIVE-CONVERSION">RECURSIVE CONVERSION</a></li>
|
||||
<li><a href="#LOCALIZATION">LOCALIZATION</a></li>
|
||||
<li><a href="#RETURN-VALUE">RETURN VALUE</a></li>
|
||||
<li><a href="#STANDARDS">STANDARDS</a></li>
|
||||
<li><a href="#AUTHORS">AUTHORS</a></li>
|
||||
<li><a href="#SEE-ALSO">SEE ALSO</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NAME">NAME</h1>
|
||||
|
||||
<p>dos2unix - DOS/Mac to Unix and vice versa text file format converter</p>
|
||||
|
||||
<h1 id="SYNOPSIS">SYNOPSIS</h1>
|
||||
|
||||
<pre><code>dos2unix [options] [FILE ...] [-n INFILE OUTFILE ...]
|
||||
unix2dos [options] [FILE ...] [-n INFILE OUTFILE ...]</code></pre>
|
||||
|
||||
<h1 id="DESCRIPTION">DESCRIPTION</h1>
|
||||
|
||||
<p>The dos2unix package includes utilities <code>dos2unix</code> and <code>unix2dos</code> to convert plain text files in DOS or Mac format to Unix format and vice versa.</p>
|
||||
|
||||
<p>In DOS/Windows text files a line break, also known as newline, is a combination of two characters: a Carriage Return (CR) followed by a Line Feed (LF). In Unix text files a line break is a single character: the Line Feed (LF). In Mac text files, prior to Mac OS X, a line break was single Carriage Return (CR) character. Nowadays Mac OS uses Unix style (LF) line breaks.</p>
|
||||
|
||||
<p>Besides line breaks dos2unix can also convert the encoding of files. A few DOS code pages can be converted to Unix Latin-1. And Windows Unicode (UTF-16) files can be converted to Unix Unicode (UTF-8) files.</p>
|
||||
|
||||
<p>Binary files are automatically skipped, unless conversion is forced.</p>
|
||||
|
||||
<p>Non-regular files, such as directories and FIFOs, are automatically skipped.</p>
|
||||
|
||||
<p>Symbolic links and their targets are by default kept untouched. Symbolic links can optionally be replaced, or the output can be written to the symbolic link target. Writing to a symbolic link target is not supported on Windows.</p>
|
||||
|
||||
<p>dos2unix was modelled after dos2unix under SunOS/Solaris. There is one important difference with the original SunOS/Solaris version. This version does by default in-place conversion (old file mode), while the original SunOS/Solaris version only supports paired conversion (new file mode). See also options <code>-o</code> and <code>-n</code>. Another difference is that the SunOS/Solaris version uses by default <i>iso</i> mode conversion while this version uses by default <i>ascii</i> mode conversion.</p>
|
||||
|
||||
<h1 id="OPTIONS">OPTIONS</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Treat all following options as file names. Use this option if you want to convert files whose names start with a dash. For instance to convert a file named "-foo", you can use this command:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Or in new file mode:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Allow file ownership change in old file mode.</p>
|
||||
|
||||
<p>When this option is used, the conversion will not be aborted when the user and/or group ownership of the original file can't be preserved in old file mode. Conversion will continue and the converted file will get the same new ownership as if it was converted in new file mode. See also options <code>-o</code> and <code>-n</code>. This option is only available if dos2unix has support for preserving the user and group ownership of files.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Default conversion mode. See also section CONVERSION MODES.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversion between DOS and ISO-8859-1 character set. See also section CONVERSION MODES.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use Windows code page 1252 (Western European).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use DOS code page 437 (US). This is the default code page used for ISO conversion.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use DOS code page 850 (Western European).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use DOS code page 860 (Portuguese).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use DOS code page 863 (French Canadian).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Use DOS code page 865 (Nordic).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convert 8 bit characters to 7 bit space.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep Byte Order Mark (BOM). When the input file has a BOM, write a BOM in the output file. This is the default behavior when converting to DOS line breaks. See also option <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-CONVMODE"><b>-c, --convmode CONVMODE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Set conversion mode. Where CONVMODE is one of: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> with ascii being the default.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-ENCODING"><b>-D, --display-enc ENCODING</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Set encoding of displayed text. Where ENCODING is one of: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i> with ansi being the default.</p>
|
||||
|
||||
<p>This option is only available in dos2unix for Windows with Unicode file name support. This option has no effect on the actual file names read and written, only on how they are displayed.</p>
|
||||
|
||||
<p>There are several methods for displaying text in a Windows console based on the encoding of the text. They all have their own advantages and disadvantages.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix's default method is to use ANSI encoded text. The advantage is that it is backwards compatible. It works with raster and TrueType fonts. In some regions you may need to change the active DOS OEM code page to the Windows system ANSI code page using the <code>chcp</code> command, because dos2unix uses the Windows system code page.</p>
|
||||
|
||||
<p>The disadvantage of ansi is that international file names with characters not inside the system default code page are not displayed properly. You will see a question mark, or a wrong symbol instead. When you don't work with foreign file names this method is OK.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>The advantage of unicode (the Windows name for UTF-16) encoding is that text is usually properly displayed. There is no need to change the active code page. You may need to set the console's font to a TrueType font to have international characters displayed properly. When a character is not included in the TrueType font you usually see a small square, sometimes with a question mark in it.</p>
|
||||
|
||||
<p>When you use the ConEmu console all text is displayed properly, because ConEmu automatically selects a good font.</p>
|
||||
|
||||
<p>The disadvantage of unicode is that it is not compatible with ASCII. The output is not easy to handle when you redirect it to another program.</p>
|
||||
|
||||
<p>When method <code>unicodebom</code> is used the Unicode text will be preceded with a BOM (Byte Order Mark). A BOM is required for correct redirection or piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>The advantage of utf8 is that it is compatible with ASCII. You need to set the console's font to a TrueType font. With a TrueType font the text is displayed similar as with the <code>unicode</code> encoding.</p>
|
||||
|
||||
<p>The disadvantage is that when you use the default raster font all non-ASCII characters are displayed wrong. Not only unicode file names, but also translated messages become unreadable. On Windows configured for an East-Asian region you may see a lot of flickering of the console when the messages are displayed.</p>
|
||||
|
||||
<p>In a ConEmu console the utf8 encoding method works well.</p>
|
||||
|
||||
<p>When method <code>utf8bom</code> is used the UTF-8 text will be preceded with a BOM (Byte Order Mark). A BOM is required for correct redirection or piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>The default encoding can be changed with environment variable DOS2UNIX_DISPLAY_ENC by setting it to <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code>, or <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Add a line break to the last line if there isn't one. This works for every conversion.</p>
|
||||
|
||||
<p>A file converted from DOS to Unix format may lack a line break on the last line. There are text editors that write text files without a line break on the last line. Some Unix programs have problems processing these files, because the POSIX standard defines that every line in a text file must end with a terminating newline character. For instance concatenating files may not give the expected result.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Return an error if a binary file is skipped.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Force conversion of binary files.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>On Windows UTF-16 files are by default converted to UTF-8, regardless of the locale setting. Use this option to convert UTF-16 files to GB18030. This option is only available on Windows. See also section GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Display help and exit.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-FLAGS---info-FLAGS-FILE"><b>-i[FLAGS], --info[=FLAGS] FILE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Display file information. No conversion is done.</p>
|
||||
|
||||
<p>The following information is printed, in this order: number of DOS line breaks, number of Unix line breaks, number of Mac line breaks, byte order mark, text or binary, file name.</p>
|
||||
|
||||
<p>Example output:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Note that sometimes a binary file can be mistaken for a text file. See also option <code>-s</code>.</p>
|
||||
|
||||
<p>If in addition option <code>-e</code> or <code>--add-eol</code> is used also the type of the line break of the last line is printed, or <code>noeol</code> if there is none.</p>
|
||||
|
||||
<p>Example output:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Optionally extra flags can be set to change the output. One or more flags can be added.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print the file information lines followed by a null character instead of a newline character. This enables correct interpretation of file names with spaces or quotes when flag c is used. Use this flag in combination with xargs(1) option <code>-0</code> or <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print number of DOS line breaks.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print number of Unix line breaks.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print number of Mac line breaks.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print the byte order mark.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print if file is text or binary.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print the type of the line break of the last line, or <code>noeol</code> if there is none.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print only the files that would be converted.</p>
|
||||
|
||||
<p>With the <code>c</code> flag dos2unix will print only the files that contain DOS line breaks, unix2dos will print only file names that have Unix line breaks.</p>
|
||||
|
||||
<p>If in addition option <code>-e</code> or <code>--add-eol</code> is used also the files that lack a line break on the last line will be printed.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print a header.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Show file names without path.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Examples:</p>
|
||||
|
||||
<p>Show information for all *.txt files:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Show only the number of DOS line breaks and Unix line breaks:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Show only the byte order mark:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>List the files that have DOS line breaks:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>List the files that have Unix line breaks:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>List the files that have DOS line breaks or lack a line break on the last line:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Convert only files that have DOS line breaks and leave the other files untouched:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Find text files that have DOS line breaks:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the date stamp of output file same as input file.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Display program's license.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Add additional newline.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Only DOS line breaks are changed to two Unix line breaks. In Mac mode only Mac line breaks are changed to two Unix line breaks.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Only Unix line breaks are changed to two DOS line breaks. In Mac mode Unix line breaks are changed to two Mac line breaks.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Write a Byte Order Mark (BOM) in the output file. By default an UTF-8 BOM is written.</p>
|
||||
|
||||
<p>When the input file is UTF-16, and the option <code>-u</code> is used, an UTF-16 BOM will be written.</p>
|
||||
|
||||
<p>Never use this option when the output encoding is other than UTF-8, UTF-16, or GB18030. See also section UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-INFILE-OUTFILE"><b>-n, --newfile INFILE OUTFILE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>New file mode. Convert file INFILE and write output to file OUTFILE. File names must be given in pairs and wildcard names should <i>not</i> be used or you <i>will</i> lose your files.</p>
|
||||
|
||||
<p>The person who starts the conversion in new file (paired) mode will be the owner of the converted file. The read/write permissions of the new file will be the permissions of the original file minus the umask(1) of the person who runs the conversion.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Don't allow file ownership change in old file mode (default).</p>
|
||||
|
||||
<p>Abort conversion when the user and/or group ownership of the original file can't be preserved in old file mode. See also options <code>-o</code> and <code>-n</code>. This option is only available if dos2unix has support for preserving the user and group ownership of files.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not add a line break to the last line if there isn't one (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not return an error if a binary file is skipped (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Write to standard output, like a Unix filter. Use option <code>-o</code> to go back to old file (in-place) mode.</p>
|
||||
|
||||
<p>Combined with option <code>-e</code> files can be properly concatenated. No merged last and first lines, and no Unicode byte order marks in the middle of the concatenated file. Example:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O file1.txt file2.txt > output.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-FILE"><b>-o, --oldfile FILE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Old file mode. Convert file FILE and overwrite output to it. The program defaults to run in this mode. Wildcard names may be used.</p>
|
||||
|
||||
<p>In old file (in-place) mode the converted file gets the same owner, group, and read/write permissions as the original file. Also when the file is converted by another user who has write permissions on the file (e.g. user root). The conversion will be aborted when it is not possible to preserve the original values. Change of owner could mean that the original owner is not able to read the file any more. Change of group could be a security risk, the file could be made readable for persons for whom it is not intended. Preservation of owner, group, and read/write permissions is only supported on Unix.</p>
|
||||
|
||||
<p>To check if dos2unix has support for preserving the user and group ownership of files type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Conversion is always done via a temporary file. When an error occurs halfway the conversion, the temporary file is deleted and the original file stays intact. When the conversion is successful, the original file is replaced with the temporary file. You may have write permission on the original file, but no permission to put the same user and/or group ownership properties on the temporary file as the original file has. This means you are not able to preserve the user and/or group ownership of the original file. In this case you can use option <code>--allow-chown</code> to continue with the conversion:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Another option is to use new file mode:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>The advantage of the <code>--allow-chown</code> option is that you can use wildcards, and the ownership properties will be preserved when possible.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Quiet mode. Suppress all warnings and messages. The return value is zero. Except when wrong command-line options are used.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Remove Byte Order Mark (BOM). Do not write a BOM in the output file. This is the default behavior when converting to Unix line breaks. See also option <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skip binary files (default).</p>
|
||||
|
||||
<p>The skipping of binary files is done to avoid accidental mistakes. Be aware that the detection of binary files is not 100% foolproof. Input files are scanned for binary symbols which are typically not found in text files. It is possible that a binary file contains only normal text characters. Such a binary file will mistakenly be seen as a text file.</p>
|
||||
|
||||
<p>By default, no error is returned when a binary file is skipped. When the <code>--error-binary</code> option is used, an error is returned.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Assume that the input file format is UTF-16LE.</p>
|
||||
|
||||
<p>When there is a Byte Order Mark in the input file the BOM has priority over this option.</p>
|
||||
|
||||
<p>When you made a wrong assumption (the input file was not in UTF-16LE format) and the conversion succeeded, you will get an UTF-8 output file with wrong text. You can undo the wrong conversion with iconv(1) by converting the UTF-8 output file back to UTF-16LE. This will bring back the original file.</p>
|
||||
|
||||
<p>The assumption of UTF-16LE works as a <i>conversion mode</i>. By switching to the default <i>ascii</i> mode the UTF-16LE assumption is turned off.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Assume that the input file format is UTF-16BE.</p>
|
||||
|
||||
<p>This option works the same as option <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Display verbose messages. Extra information is displayed about Byte Order Marks and the amount of converted line breaks.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Follow symbolic links and convert the targets.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Replace symbolic links with converted files (original target files remain unchanged).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep symbolic links and targets unchanged (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Display version information and exit.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MAC-MODE">MAC MODE</h1>
|
||||
|
||||
<p>By default line breaks are converted from DOS to Unix and vice versa. Mac line breaks are not converted.</p>
|
||||
|
||||
<p>In Mac mode line breaks are converted from Mac to Unix and vice versa. DOS line breaks are not changed.</p>
|
||||
|
||||
<p>To run in Mac mode use the command-line option <code>-c mac</code> or use the commands <code>mac2unix</code> or <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="CONVERSION-MODES">CONVERSION MODES</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>This is the default conversion mode. This mode is for converting ASCII and ASCII-compatible encoded files, like UTF-8. Enabling <b>ascii</b> mode disables <b>7bit</b> and <b>iso</b> mode.</p>
|
||||
|
||||
<p>If dos2unix has UTF-16 support, UTF-16 encoded files are converted to the current locale character encoding on POSIX systems and to UTF-8 on Windows. Enabling <b>ascii</b> mode disables the option to keep UTF-16 encoding (<code>-u</code>) and the options to assume UTF-16 input (<code>-ul</code> and <code>-ub</code>). To see if dos2unix has UTF-16 support type <code>dos2unix -V</code>. See also section UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>In this mode all 8 bit non-ASCII characters (with values from 128 to 255) are converted to a 7 bit space.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Characters are converted between a DOS character set (code page) and ISO character set ISO-8859-1 (Latin-1) on Unix. DOS characters without ISO-8859-1 equivalent, for which conversion is not possible, are converted to a dot. The same counts for ISO-8859-1 characters without DOS counterpart.</p>
|
||||
|
||||
<p>When only option <code>-iso</code> is used dos2unix will try to determine the active code page. When this is not possible dos2unix will use default code page CP437, which is mainly used in the USA. To force a specific code page use options <code>-437</code> (US), <code>-850</code> (Western European), <code>-860</code> (Portuguese), <code>-863</code> (French Canadian), or <code>-865</code> (Nordic). Windows code page CP1252 (Western European) is also supported with option <code>-1252</code>. For other code pages use dos2unix in combination with iconv(1). Iconv can convert between a long list of character encodings.</p>
|
||||
|
||||
<p>Never use ISO conversion on Unicode text files. It will corrupt UTF-8 encoded files.</p>
|
||||
|
||||
<p>Some examples:</p>
|
||||
|
||||
<p>Convert from DOS default code page to Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from DOS CP850 to Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Windows CP1252 to Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Windows CP1252 to Unix UTF-8 (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix Latin-1 to DOS default code page:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix Latin-1 to DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix Latin-1 to Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix UTF-8 (Unicode) to Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Encodings">Encodings</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Conversion">Conversion</h2>
|
||||
|
||||
<p>Unicode text files can have DOS, Unix or Mac line breaks, like ASCII text files.</p>
|
||||
|
||||
<p>All versions of dos2unix and unix2dos can convert UTF-8 encoded files, because UTF-8 was designed for backward compatibility with ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>On Unix/Linux UTF-16 encoded files are converted to the locale character encoding. Use the locale(1) command to find out what the locale character encoding is. When conversion is not possible a conversion error will occur and the file will be skipped.</p>
|
||||
|
||||
<p>On Windows UTF-16 files are by default converted to UTF-8. UTF-8 formatted text files are well supported on both Windows and Unix/Linux.</p>
|
||||
|
||||
<p>UTF-16 and UTF-8 encoding are fully compatible, there will no text be lost in the conversion. When an UTF-16 to UTF-8 conversion error occurs, for instance when the UTF-16 input file contains an error, the file will be skipped.</p>
|
||||
|
||||
<p>When option <code>-u</code> is used, the output file will be written in the same UTF-16 encoding as the input file. Option <code>-u</code> prevents conversion to UTF-8.</p>
|
||||
|
||||
<p>dos2unix and unix2dos have no option to convert UTF-8 files to UTF-16.</p>
|
||||
|
||||
<p>ISO and 7-bit mode conversion do not work on UTF-16 files.</p>
|
||||
|
||||
<h2 id="Byte-Order-Mark">Byte Order Mark</h2>
|
||||
|
||||
<p>On Windows Unicode text files typically have a Byte Order Mark (BOM), because many Windows programs (including Notepad) add BOMs by default. See also <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>On Unix Unicode files typically don't have a BOM. It is assumed that text files are encoded in the locale character encoding.</p>
|
||||
|
||||
<p>dos2unix can only detect if a file is in UTF-16 format if the file has a BOM. When an UTF-16 file doesn't have a BOM, dos2unix will see the file as a binary file.</p>
|
||||
|
||||
<p>Use option <code>-ul</code> or <code>-ub</code> to convert an UTF-16 file without BOM.</p>
|
||||
|
||||
<p>dos2unix writes by default no BOM in the output file. With option <code>-b</code> dos2unix writes a BOM when the input file has a BOM.</p>
|
||||
|
||||
<p>unix2dos writes by default a BOM in the output file when the input file has a BOM. Use option <code>-r</code> to remove the BOM.</p>
|
||||
|
||||
<p>dos2unix and unix2dos write always a BOM when option <code>-m</code> is used.</p>
|
||||
|
||||
<h2 id="Unicode-file-names-on-Windows">Unicode file names on Windows</h2>
|
||||
|
||||
<p>dos2unix has optional support for reading and writing Unicode file names in the Windows Command Prompt. That means that dos2unix can open files that have characters in the name that are not part of the default system ANSI code page. To see if dos2unix for Windows was built with Unicode file name support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>There are some issues with displaying Unicode file names in a Windows console. See option <code>-D</code>, <code>--display-enc</code>. The file names may be displayed wrongly in the console, but the files will be written with the correct name.</p>
|
||||
|
||||
<h2 id="Unicode-examples">Unicode examples</h2>
|
||||
|
||||
<p>Convert from Windows UTF-16 (with BOM) to Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Windows UTF-16LE (without BOM) to Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix UTF-8 to Windows UTF-8 with BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convert from Unix UTF-8 to Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 is a Chinese government standard. A mandatory subset of the GB18030 standard is officially required for all software products sold in China. See also <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 is fully compatible with Unicode, and can be considered an unicode transformation format. Like UTF-8, GB18030 is compatible with ASCII. GB18030 is also compatible with Windows code page 936, also known as GBK.</p>
|
||||
|
||||
<p>On Unix/Linux UTF-16 files are converted to GB18030 when the locale encoding is set to GB18030. Note that this will only work if the locale is supported by the system. Use command <code>locale -a</code> to get the list of supported locales.</p>
|
||||
|
||||
<p>On Windows you need to use option <code>-gb</code> to convert UTF-16 files to GB18030.</p>
|
||||
|
||||
<p>GB18030 encoded files can have a Byte Order Mark, like Unicode files.</p>
|
||||
|
||||
<h1 id="EXAMPLES">EXAMPLES</h1>
|
||||
|
||||
<p>Read input from 'stdin' and write output to 'stdout':</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Convert and replace a.txt. Convert and replace b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Convert and replace a.txt in ascii conversion mode:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Convert and replace a.txt in ascii conversion mode, convert and replace b.txt in 7bit conversion mode:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Convert a.txt from Mac to Unix format:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Convert a.txt from Unix to Mac format:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Convert and replace a.txt while keeping original date stamp:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Convert a.txt and write to e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convert and replace a.txt, convert b.txt and write to e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Convert c.txt and write to e.txt, convert and replace a.txt, convert and replace b.txt, convert d.txt and write to f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="RECURSIVE-CONVERSION">RECURSIVE CONVERSION</h1>
|
||||
|
||||
<p>In a Unix shell the find(1) and xargs(1) commands can be used to run dos2unix recursively over all text files in a directory tree. For instance to convert all .txt files in the directory tree under the current directory type:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>The find(1) option <code>-print0</code> and corresponding xargs(1) option <code>-0</code> are needed when there are files with spaces or quotes in the name. Otherwise these options can be omitted. Another option is to use find(1) with the <code>-exec</code> option:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>In a Windows Command Prompt the following command can be used:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>PowerShell users can use the following command in Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOCALIZATION">LOCALIZATION</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>The primary language is selected with the environment variable LANG. The LANG variable consists out of several parts. The first part is in small letters the language code. The second is optional and is the country code in capital letters, preceded with an underscore. There is also an optional third part: character encoding, preceded with a dot. A few examples for POSIX standard type shells:</p>
|
||||
|
||||
<pre><code>export LANG=nl Dutch
|
||||
export LANG=nl_NL Dutch, The Netherlands
|
||||
export LANG=nl_BE Dutch, Belgium
|
||||
export LANG=es_ES Spanish, Spain
|
||||
export LANG=es_MX Spanish, Mexico
|
||||
export LANG=en_US.iso88591 English, USA, Latin-1 encoding
|
||||
export LANG=en_GB.UTF-8 English, UK, UTF-8 encoding</code></pre>
|
||||
|
||||
<p>For a complete list of language and country codes see the gettext manual: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>On Unix systems you can use the command locale(1) to get locale specific information.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>With the LANGUAGE environment variable you can specify a priority list of languages, separated by colons. dos2unix gives preference to LANGUAGE over LANG. For instance, first Dutch and then German: <code>LANGUAGE=nl:de</code>. You have to first enable localization, by setting LANG (or LC_ALL) to a value other than "C", before you can use a language priority list through the LANGUAGE variable. See also the gettext manual: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>If you select a language which is not available you will get the standard English messages.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>With the environment variable DOS2UNIX_LOCALEDIR the LOCALEDIR set during compilation can be overruled. LOCALEDIR is used to find the language files. The GNU default value is <code>/usr/local/share/locale</code>. Option <b>--version</b> will display the LOCALEDIR that is used.</p>
|
||||
|
||||
<p>Example (POSIX shell):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="RETURN-VALUE">RETURN VALUE</h1>
|
||||
|
||||
<p>On success, zero is returned. When a system error occurs the last system error will be returned. For other errors 1 is returned.</p>
|
||||
|
||||
<p>The return value is always zero in quiet mode, except when wrong command-line options are used.</p>
|
||||
|
||||
<h1 id="STANDARDS">STANDARDS</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTHORS">AUTHORS</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (maintainer)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge page: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="SEE-ALSO">SEE ALSO</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
814
Agent-Windows/OGP64/usr/share/doc/dos2unix/dos2unix.txt
Normal file
814
Agent-Windows/OGP64/usr/share/doc/dos2unix/dos2unix.txt
Normal file
|
|
@ -0,0 +1,814 @@
|
|||
NAME
|
||||
dos2unix - DOS/Mac to Unix and vice versa text file format converter
|
||||
|
||||
SYNOPSIS
|
||||
dos2unix [options] [FILE ...] [-n INFILE OUTFILE ...]
|
||||
unix2dos [options] [FILE ...] [-n INFILE OUTFILE ...]
|
||||
|
||||
DESCRIPTION
|
||||
The dos2unix package includes utilities "dos2unix" and "unix2dos" to
|
||||
convert plain text files in DOS or Mac format to Unix format and vice
|
||||
versa.
|
||||
|
||||
In DOS/Windows text files a line break, also known as newline, is a
|
||||
combination of two characters: a Carriage Return (CR) followed by a Line
|
||||
Feed (LF). In Unix text files a line break is a single character: the
|
||||
Line Feed (LF). In Mac text files, prior to Mac OS X, a line break was
|
||||
single Carriage Return (CR) character. Nowadays Mac OS uses Unix style
|
||||
(LF) line breaks.
|
||||
|
||||
Besides line breaks dos2unix can also convert the encoding of files. A
|
||||
few DOS code pages can be converted to Unix Latin-1. And Windows Unicode
|
||||
(UTF-16) files can be converted to Unix Unicode (UTF-8) files.
|
||||
|
||||
Binary files are automatically skipped, unless conversion is forced.
|
||||
|
||||
Non-regular files, such as directories and FIFOs, are automatically
|
||||
skipped.
|
||||
|
||||
Symbolic links and their targets are by default kept untouched. Symbolic
|
||||
links can optionally be replaced, or the output can be written to the
|
||||
symbolic link target. Writing to a symbolic link target is not supported
|
||||
on Windows.
|
||||
|
||||
dos2unix was modelled after dos2unix under SunOS/Solaris. There is one
|
||||
important difference with the original SunOS/Solaris version. This
|
||||
version does by default in-place conversion (old file mode), while the
|
||||
original SunOS/Solaris version only supports paired conversion (new file
|
||||
mode). See also options "-o" and "-n". Another difference is that the
|
||||
SunOS/Solaris version uses by default *iso* mode conversion while this
|
||||
version uses by default *ascii* mode conversion.
|
||||
|
||||
OPTIONS
|
||||
-- Treat all following options as file names. Use this option if you
|
||||
want to convert files whose names start with a dash. For instance to
|
||||
convert a file named "-foo", you can use this command:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Or in new file mode:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
Allow file ownership change in old file mode.
|
||||
|
||||
When this option is used, the conversion will not be aborted when
|
||||
the user and/or group ownership of the original file can't be
|
||||
preserved in old file mode. Conversion will continue and the
|
||||
converted file will get the same new ownership as if it was
|
||||
converted in new file mode. See also options "-o" and "-n". This
|
||||
option is only available if dos2unix has support for preserving the
|
||||
user and group ownership of files.
|
||||
|
||||
-ascii
|
||||
Default conversion mode. See also section CONVERSION MODES.
|
||||
|
||||
-iso
|
||||
Conversion between DOS and ISO-8859-1 character set. See also
|
||||
section CONVERSION MODES.
|
||||
|
||||
-1252
|
||||
Use Windows code page 1252 (Western European).
|
||||
|
||||
-437
|
||||
Use DOS code page 437 (US). This is the default code page used for
|
||||
ISO conversion.
|
||||
|
||||
-850
|
||||
Use DOS code page 850 (Western European).
|
||||
|
||||
-860
|
||||
Use DOS code page 860 (Portuguese).
|
||||
|
||||
-863
|
||||
Use DOS code page 863 (French Canadian).
|
||||
|
||||
-865
|
||||
Use DOS code page 865 (Nordic).
|
||||
|
||||
-7 Convert 8 bit characters to 7 bit space.
|
||||
|
||||
-b, --keep-bom
|
||||
Keep Byte Order Mark (BOM). When the input file has a BOM, write a
|
||||
BOM in the output file. This is the default behavior when converting
|
||||
to DOS line breaks. See also option "-r".
|
||||
|
||||
-c, --convmode CONVMODE
|
||||
Set conversion mode. Where CONVMODE is one of: *ascii*, *7bit*,
|
||||
*iso*, *mac* with ascii being the default.
|
||||
|
||||
-D, --display-enc ENCODING
|
||||
Set encoding of displayed text. Where ENCODING is one of: *ansi*,
|
||||
*unicode*, *unicodebom*, *utf8*, *utf8bom* with ansi being the
|
||||
default.
|
||||
|
||||
This option is only available in dos2unix for Windows with Unicode
|
||||
file name support. This option has no effect on the actual file
|
||||
names read and written, only on how they are displayed.
|
||||
|
||||
There are several methods for displaying text in a Windows console
|
||||
based on the encoding of the text. They all have their own
|
||||
advantages and disadvantages.
|
||||
|
||||
ansi
|
||||
dos2unix's default method is to use ANSI encoded text. The
|
||||
advantage is that it is backwards compatible. It works with
|
||||
raster and TrueType fonts. In some regions you may need to
|
||||
change the active DOS OEM code page to the Windows system ANSI
|
||||
code page using the "chcp" command, because dos2unix uses the
|
||||
Windows system code page.
|
||||
|
||||
The disadvantage of ansi is that international file names with
|
||||
characters not inside the system default code page are not
|
||||
displayed properly. You will see a question mark, or a wrong
|
||||
symbol instead. When you don't work with foreign file names this
|
||||
method is OK.
|
||||
|
||||
unicode, unicodebom
|
||||
The advantage of unicode (the Windows name for UTF-16) encoding
|
||||
is that text is usually properly displayed. There is no need to
|
||||
change the active code page. You may need to set the console's
|
||||
font to a TrueType font to have international characters
|
||||
displayed properly. When a character is not included in the
|
||||
TrueType font you usually see a small square, sometimes with a
|
||||
question mark in it.
|
||||
|
||||
When you use the ConEmu console all text is displayed properly,
|
||||
because ConEmu automatically selects a good font.
|
||||
|
||||
The disadvantage of unicode is that it is not compatible with
|
||||
ASCII. The output is not easy to handle when you redirect it to
|
||||
another program.
|
||||
|
||||
When method "unicodebom" is used the Unicode text will be
|
||||
preceded with a BOM (Byte Order Mark). A BOM is required for
|
||||
correct redirection or piping in PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
The advantage of utf8 is that it is compatible with ASCII. You
|
||||
need to set the console's font to a TrueType font. With a
|
||||
TrueType font the text is displayed similar as with the
|
||||
"unicode" encoding.
|
||||
|
||||
The disadvantage is that when you use the default raster font
|
||||
all non-ASCII characters are displayed wrong. Not only unicode
|
||||
file names, but also translated messages become unreadable. On
|
||||
Windows configured for an East-Asian region you may see a lot of
|
||||
flickering of the console when the messages are displayed.
|
||||
|
||||
In a ConEmu console the utf8 encoding method works well.
|
||||
|
||||
When method "utf8bom" is used the UTF-8 text will be preceded
|
||||
with a BOM (Byte Order Mark). A BOM is required for correct
|
||||
redirection or piping in PowerShell.
|
||||
|
||||
The default encoding can be changed with environment variable
|
||||
DOS2UNIX_DISPLAY_ENC by setting it to "unicode", "unicodebom",
|
||||
"utf8", or "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Add a line break to the last line if there isn't one. This works for
|
||||
every conversion.
|
||||
|
||||
A file converted from DOS to Unix format may lack a line break on
|
||||
the last line. There are text editors that write text files without
|
||||
a line break on the last line. Some Unix programs have problems
|
||||
processing these files, because the POSIX standard defines that
|
||||
every line in a text file must end with a terminating newline
|
||||
character. For instance concatenating files may not give the
|
||||
expected result.
|
||||
|
||||
--error-binary
|
||||
Return an error if a binary file is skipped.
|
||||
|
||||
-f, --force
|
||||
Force conversion of binary files.
|
||||
|
||||
-gb, --gb18030
|
||||
On Windows UTF-16 files are by default converted to UTF-8,
|
||||
regardless of the locale setting. Use this option to convert UTF-16
|
||||
files to GB18030. This option is only available on Windows. See also
|
||||
section GB18030.
|
||||
|
||||
-h, --help
|
||||
Display help and exit.
|
||||
|
||||
-i[FLAGS], --info[=FLAGS] FILE ...
|
||||
Display file information. No conversion is done.
|
||||
|
||||
The following information is printed, in this order: number of DOS
|
||||
line breaks, number of Unix line breaks, number of Mac line breaks,
|
||||
byte order mark, text or binary, file name.
|
||||
|
||||
Example output:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Note that sometimes a binary file can be mistaken for a text file.
|
||||
See also option "-s".
|
||||
|
||||
If in addition option "-e" or "--add-eol" is used also the type of
|
||||
the line break of the last line is printed, or "noeol" if there is
|
||||
none.
|
||||
|
||||
Example output:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Optionally extra flags can be set to change the output. One or more
|
||||
flags can be added.
|
||||
|
||||
0 Print the file information lines followed by a null character
|
||||
instead of a newline character. This enables correct
|
||||
interpretation of file names with spaces or quotes when flag c
|
||||
is used. Use this flag in combination with xargs(1) option -0 or
|
||||
"--null".
|
||||
|
||||
d Print number of DOS line breaks.
|
||||
|
||||
u Print number of Unix line breaks.
|
||||
|
||||
m Print number of Mac line breaks.
|
||||
|
||||
b Print the byte order mark.
|
||||
|
||||
t Print if file is text or binary.
|
||||
|
||||
e Print the type of the line break of the last line, or "noeol" if
|
||||
there is none.
|
||||
|
||||
c Print only the files that would be converted.
|
||||
|
||||
With the "c" flag dos2unix will print only the files that
|
||||
contain DOS line breaks, unix2dos will print only file names
|
||||
that have Unix line breaks.
|
||||
|
||||
If in addition option "-e" or "--add-eol" is used also the files
|
||||
that lack a line break on the last line will be printed.
|
||||
|
||||
h Print a header.
|
||||
|
||||
p Show file names without path.
|
||||
|
||||
Examples:
|
||||
|
||||
Show information for all *.txt files:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Show only the number of DOS line breaks and Unix line breaks:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Show only the byte order mark:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
List the files that have DOS line breaks:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
List the files that have Unix line breaks:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
List the files that have DOS line breaks or lack a line break on the
|
||||
last line:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Convert only files that have DOS line breaks and leave the other
|
||||
files untouched:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Find text files that have DOS line breaks:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Keep the date stamp of output file same as input file.
|
||||
|
||||
-L, --license
|
||||
Display program's license.
|
||||
|
||||
-l, --newline
|
||||
Add additional newline.
|
||||
|
||||
dos2unix: Only DOS line breaks are changed to two Unix line breaks.
|
||||
In Mac mode only Mac line breaks are changed to two Unix line
|
||||
breaks.
|
||||
|
||||
unix2dos: Only Unix line breaks are changed to two DOS line breaks.
|
||||
In Mac mode Unix line breaks are changed to two Mac line breaks.
|
||||
|
||||
-m, --add-bom
|
||||
Write a Byte Order Mark (BOM) in the output file. By default an
|
||||
UTF-8 BOM is written.
|
||||
|
||||
When the input file is UTF-16, and the option "-u" is used, an
|
||||
UTF-16 BOM will be written.
|
||||
|
||||
Never use this option when the output encoding is other than UTF-8,
|
||||
UTF-16, or GB18030. See also section UNICODE.
|
||||
|
||||
-n, --newfile INFILE OUTFILE ...
|
||||
New file mode. Convert file INFILE and write output to file OUTFILE.
|
||||
File names must be given in pairs and wildcard names should *not* be
|
||||
used or you *will* lose your files.
|
||||
|
||||
The person who starts the conversion in new file (paired) mode will
|
||||
be the owner of the converted file. The read/write permissions of
|
||||
the new file will be the permissions of the original file minus the
|
||||
umask(1) of the person who runs the conversion.
|
||||
|
||||
--no-allow-chown
|
||||
Don't allow file ownership change in old file mode (default).
|
||||
|
||||
Abort conversion when the user and/or group ownership of the
|
||||
original file can't be preserved in old file mode. See also options
|
||||
"-o" and "-n". This option is only available if dos2unix has support
|
||||
for preserving the user and group ownership of files.
|
||||
|
||||
--no-add-eol
|
||||
Do not add a line break to the last line if there isn't one
|
||||
(default).
|
||||
|
||||
--no-error-binary
|
||||
Do not return an error if a binary file is skipped (default).
|
||||
|
||||
-O, --to-stdout
|
||||
Write to standard output, like a Unix filter. Use option "-o" to go
|
||||
back to old file (in-place) mode.
|
||||
|
||||
Combined with option "-e" files can be properly concatenated. No
|
||||
merged last and first lines, and no Unicode byte order marks in the
|
||||
middle of the concatenated file. Example:
|
||||
|
||||
dos2unix -e -O file1.txt file2.txt > output.txt
|
||||
|
||||
-o, --oldfile FILE ...
|
||||
Old file mode. Convert file FILE and overwrite output to it. The
|
||||
program defaults to run in this mode. Wildcard names may be used.
|
||||
|
||||
In old file (in-place) mode the converted file gets the same owner,
|
||||
group, and read/write permissions as the original file. Also when
|
||||
the file is converted by another user who has write permissions on
|
||||
the file (e.g. user root). The conversion will be aborted when it is
|
||||
not possible to preserve the original values. Change of owner could
|
||||
mean that the original owner is not able to read the file any more.
|
||||
Change of group could be a security risk, the file could be made
|
||||
readable for persons for whom it is not intended. Preservation of
|
||||
owner, group, and read/write permissions is only supported on Unix.
|
||||
|
||||
To check if dos2unix has support for preserving the user and group
|
||||
ownership of files type "dos2unix -V".
|
||||
|
||||
Conversion is always done via a temporary file. When an error occurs
|
||||
halfway the conversion, the temporary file is deleted and the
|
||||
original file stays intact. When the conversion is successful, the
|
||||
original file is replaced with the temporary file. You may have
|
||||
write permission on the original file, but no permission to put the
|
||||
same user and/or group ownership properties on the temporary file as
|
||||
the original file has. This means you are not able to preserve the
|
||||
user and/or group ownership of the original file. In this case you
|
||||
can use option "--allow-chown" to continue with the conversion:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Another option is to use new file mode:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
The advantage of the "--allow-chown" option is that you can use
|
||||
wildcards, and the ownership properties will be preserved when
|
||||
possible.
|
||||
|
||||
-q, --quiet
|
||||
Quiet mode. Suppress all warnings and messages. The return value is
|
||||
zero. Except when wrong command-line options are used.
|
||||
|
||||
-r, --remove-bom
|
||||
Remove Byte Order Mark (BOM). Do not write a BOM in the output file.
|
||||
This is the default behavior when converting to Unix line breaks.
|
||||
See also option "-b".
|
||||
|
||||
-s, --safe
|
||||
Skip binary files (default).
|
||||
|
||||
The skipping of binary files is done to avoid accidental mistakes.
|
||||
Be aware that the detection of binary files is not 100% foolproof.
|
||||
Input files are scanned for binary symbols which are typically not
|
||||
found in text files. It is possible that a binary file contains only
|
||||
normal text characters. Such a binary file will mistakenly be seen
|
||||
as a text file.
|
||||
|
||||
By default, no error is returned when a binary file is skipped. When
|
||||
the "--error-binary" option is used, an error is returned.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Assume that the input file format is UTF-16LE.
|
||||
|
||||
When there is a Byte Order Mark in the input file the BOM has
|
||||
priority over this option.
|
||||
|
||||
When you made a wrong assumption (the input file was not in UTF-16LE
|
||||
format) and the conversion succeeded, you will get an UTF-8 output
|
||||
file with wrong text. You can undo the wrong conversion with
|
||||
iconv(1) by converting the UTF-8 output file back to UTF-16LE. This
|
||||
will bring back the original file.
|
||||
|
||||
The assumption of UTF-16LE works as a *conversion mode*. By
|
||||
switching to the default *ascii* mode the UTF-16LE assumption is
|
||||
turned off.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Assume that the input file format is UTF-16BE.
|
||||
|
||||
This option works the same as option "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Display verbose messages. Extra information is displayed about Byte
|
||||
Order Marks and the amount of converted line breaks.
|
||||
|
||||
-F, --follow-symlink
|
||||
Follow symbolic links and convert the targets.
|
||||
|
||||
-R, --replace-symlink
|
||||
Replace symbolic links with converted files (original target files
|
||||
remain unchanged).
|
||||
|
||||
-S, --skip-symlink
|
||||
Keep symbolic links and targets unchanged (default).
|
||||
|
||||
-V, --version
|
||||
Display version information and exit.
|
||||
|
||||
MAC MODE
|
||||
By default line breaks are converted from DOS to Unix and vice versa.
|
||||
Mac line breaks are not converted.
|
||||
|
||||
In Mac mode line breaks are converted from Mac to Unix and vice versa.
|
||||
DOS line breaks are not changed.
|
||||
|
||||
To run in Mac mode use the command-line option "-c mac" or use the
|
||||
commands "mac2unix" or "unix2mac".
|
||||
|
||||
CONVERSION MODES
|
||||
ascii
|
||||
This is the default conversion mode. This mode is for converting
|
||||
ASCII and ASCII-compatible encoded files, like UTF-8. Enabling ascii
|
||||
mode disables 7bit and iso mode.
|
||||
|
||||
If dos2unix has UTF-16 support, UTF-16 encoded files are converted
|
||||
to the current locale character encoding on POSIX systems and to
|
||||
UTF-8 on Windows. Enabling ascii mode disables the option to keep
|
||||
UTF-16 encoding ("-u") and the options to assume UTF-16 input ("-ul"
|
||||
and "-ub"). To see if dos2unix has UTF-16 support type "dos2unix
|
||||
-V". See also section UNICODE.
|
||||
|
||||
7bit
|
||||
In this mode all 8 bit non-ASCII characters (with values from 128 to
|
||||
255) are converted to a 7 bit space.
|
||||
|
||||
iso Characters are converted between a DOS character set (code page) and
|
||||
ISO character set ISO-8859-1 (Latin-1) on Unix. DOS characters
|
||||
without ISO-8859-1 equivalent, for which conversion is not possible,
|
||||
are converted to a dot. The same counts for ISO-8859-1 characters
|
||||
without DOS counterpart.
|
||||
|
||||
When only option "-iso" is used dos2unix will try to determine the
|
||||
active code page. When this is not possible dos2unix will use
|
||||
default code page CP437, which is mainly used in the USA. To force a
|
||||
specific code page use options -437 (US), -850 (Western European),
|
||||
-860 (Portuguese), -863 (French Canadian), or -865 (Nordic). Windows
|
||||
code page CP1252 (Western European) is also supported with option
|
||||
-1252. For other code pages use dos2unix in combination with
|
||||
iconv(1). Iconv can convert between a long list of character
|
||||
encodings.
|
||||
|
||||
Never use ISO conversion on Unicode text files. It will corrupt
|
||||
UTF-8 encoded files.
|
||||
|
||||
Some examples:
|
||||
|
||||
Convert from DOS default code page to Unix Latin-1:
|
||||
|
||||
dos2unix -iso -n in.txt out.txt
|
||||
|
||||
Convert from DOS CP850 to Unix Latin-1:
|
||||
|
||||
dos2unix -850 -n in.txt out.txt
|
||||
|
||||
Convert from Windows CP1252 to Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n in.txt out.txt
|
||||
|
||||
Convert from Windows CP1252 to Unix UTF-8 (Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
|
||||
|
||||
Convert from Unix Latin-1 to DOS default code page:
|
||||
|
||||
unix2dos -iso -n in.txt out.txt
|
||||
|
||||
Convert from Unix Latin-1 to DOS CP850:
|
||||
|
||||
unix2dos -850 -n in.txt out.txt
|
||||
|
||||
Convert from Unix Latin-1 to Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n in.txt out.txt
|
||||
|
||||
Convert from Unix UTF-8 (Unicode) to Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Encodings
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversion
|
||||
Unicode text files can have DOS, Unix or Mac line breaks, like ASCII
|
||||
text files.
|
||||
|
||||
All versions of dos2unix and unix2dos can convert UTF-8 encoded files,
|
||||
because UTF-8 was designed for backward compatibility with ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
On Unix/Linux UTF-16 encoded files are converted to the locale character
|
||||
encoding. Use the locale(1) command to find out what the locale
|
||||
character encoding is. When conversion is not possible a conversion
|
||||
error will occur and the file will be skipped.
|
||||
|
||||
On Windows UTF-16 files are by default converted to UTF-8. UTF-8
|
||||
formatted text files are well supported on both Windows and Unix/Linux.
|
||||
|
||||
UTF-16 and UTF-8 encoding are fully compatible, there will no text be
|
||||
lost in the conversion. When an UTF-16 to UTF-8 conversion error occurs,
|
||||
for instance when the UTF-16 input file contains an error, the file will
|
||||
be skipped.
|
||||
|
||||
When option "-u" is used, the output file will be written in the same
|
||||
UTF-16 encoding as the input file. Option "-u" prevents conversion to
|
||||
UTF-8.
|
||||
|
||||
dos2unix and unix2dos have no option to convert UTF-8 files to UTF-16.
|
||||
|
||||
ISO and 7-bit mode conversion do not work on UTF-16 files.
|
||||
|
||||
Byte Order Mark
|
||||
On Windows Unicode text files typically have a Byte Order Mark (BOM),
|
||||
because many Windows programs (including Notepad) add BOMs by default.
|
||||
See also <https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
On Unix Unicode files typically don't have a BOM. It is assumed that
|
||||
text files are encoded in the locale character encoding.
|
||||
|
||||
dos2unix can only detect if a file is in UTF-16 format if the file has a
|
||||
BOM. When an UTF-16 file doesn't have a BOM, dos2unix will see the file
|
||||
as a binary file.
|
||||
|
||||
Use option "-ul" or "-ub" to convert an UTF-16 file without BOM.
|
||||
|
||||
dos2unix writes by default no BOM in the output file. With option "-b"
|
||||
dos2unix writes a BOM when the input file has a BOM.
|
||||
|
||||
unix2dos writes by default a BOM in the output file when the input file
|
||||
has a BOM. Use option "-r" to remove the BOM.
|
||||
|
||||
dos2unix and unix2dos write always a BOM when option "-m" is used.
|
||||
|
||||
Unicode file names on Windows
|
||||
dos2unix has optional support for reading and writing Unicode file names
|
||||
in the Windows Command Prompt. That means that dos2unix can open files
|
||||
that have characters in the name that are not part of the default system
|
||||
ANSI code page. To see if dos2unix for Windows was built with Unicode
|
||||
file name support type "dos2unix -V".
|
||||
|
||||
There are some issues with displaying Unicode file names in a Windows
|
||||
console. See option "-D", "--display-enc". The file names may be
|
||||
displayed wrongly in the console, but the files will be written with the
|
||||
correct name.
|
||||
|
||||
Unicode examples
|
||||
Convert from Windows UTF-16 (with BOM) to Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt out.txt
|
||||
|
||||
Convert from Windows UTF-16LE (without BOM) to Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n in.txt out.txt
|
||||
|
||||
Convert from Unix UTF-8 to Windows UTF-8 with BOM:
|
||||
|
||||
unix2dos -m -n in.txt out.txt
|
||||
|
||||
Convert from Unix UTF-8 to Windows UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
|
||||
|
||||
GB18030
|
||||
GB18030 is a Chinese government standard. A mandatory subset of the
|
||||
GB18030 standard is officially required for all software products sold
|
||||
in China. See also <https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 is fully compatible with Unicode, and can be considered an
|
||||
unicode transformation format. Like UTF-8, GB18030 is compatible with
|
||||
ASCII. GB18030 is also compatible with Windows code page 936, also known
|
||||
as GBK.
|
||||
|
||||
On Unix/Linux UTF-16 files are converted to GB18030 when the locale
|
||||
encoding is set to GB18030. Note that this will only work if the locale
|
||||
is supported by the system. Use command "locale -a" to get the list of
|
||||
supported locales.
|
||||
|
||||
On Windows you need to use option "-gb" to convert UTF-16 files to
|
||||
GB18030.
|
||||
|
||||
GB18030 encoded files can have a Byte Order Mark, like Unicode files.
|
||||
|
||||
EXAMPLES
|
||||
Read input from 'stdin' and write output to 'stdout':
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Convert and replace a.txt. Convert and replace b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Convert and replace a.txt in ascii conversion mode:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Convert and replace a.txt in ascii conversion mode, convert and replace
|
||||
b.txt in 7bit conversion mode:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Convert a.txt from Mac to Unix format:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Convert a.txt from Unix to Mac format:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Convert and replace a.txt while keeping original date stamp:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Convert a.txt and write to e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Convert a.txt and write to e.txt, keep date stamp of e.txt same as
|
||||
a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Convert and replace a.txt, convert b.txt and write to e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Convert c.txt and write to e.txt, convert and replace a.txt, convert and
|
||||
replace b.txt, convert d.txt and write to f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
RECURSIVE CONVERSION
|
||||
In a Unix shell the find(1) and xargs(1) commands can be used to run
|
||||
dos2unix recursively over all text files in a directory tree. For
|
||||
instance to convert all .txt files in the directory tree under the
|
||||
current directory type:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
The find(1) option "-print0" and corresponding xargs(1) option -0 are
|
||||
needed when there are files with spaces or quotes in the name. Otherwise
|
||||
these options can be omitted. Another option is to use find(1) with the
|
||||
"-exec" option:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
In a Windows Command Prompt the following command can be used:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
PowerShell users can use the following command in Windows PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOCALIZATION
|
||||
LANG
|
||||
The primary language is selected with the environment variable LANG.
|
||||
The LANG variable consists out of several parts. The first part is
|
||||
in small letters the language code. The second is optional and is
|
||||
the country code in capital letters, preceded with an underscore.
|
||||
There is also an optional third part: character encoding, preceded
|
||||
with a dot. A few examples for POSIX standard type shells:
|
||||
|
||||
export LANG=nl Dutch
|
||||
export LANG=nl_NL Dutch, The Netherlands
|
||||
export LANG=nl_BE Dutch, Belgium
|
||||
export LANG=es_ES Spanish, Spain
|
||||
export LANG=es_MX Spanish, Mexico
|
||||
export LANG=en_US.iso88591 English, USA, Latin-1 encoding
|
||||
export LANG=en_GB.UTF-8 English, UK, UTF-8 encoding
|
||||
|
||||
For a complete list of language and country codes see the gettext
|
||||
manual:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
On Unix systems you can use the command locale(1) to get locale
|
||||
specific information.
|
||||
|
||||
LANGUAGE
|
||||
With the LANGUAGE environment variable you can specify a priority
|
||||
list of languages, separated by colons. dos2unix gives preference to
|
||||
LANGUAGE over LANG. For instance, first Dutch and then German:
|
||||
"LANGUAGE=nl:de". You have to first enable localization, by setting
|
||||
LANG (or LC_ALL) to a value other than "C", before you can use a
|
||||
language priority list through the LANGUAGE variable. See also the
|
||||
gettext manual:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
If you select a language which is not available you will get the
|
||||
standard English messages.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
With the environment variable DOS2UNIX_LOCALEDIR the LOCALEDIR set
|
||||
during compilation can be overruled. LOCALEDIR is used to find the
|
||||
language files. The GNU default value is "/usr/local/share/locale".
|
||||
Option --version will display the LOCALEDIR that is used.
|
||||
|
||||
Example (POSIX shell):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
RETURN VALUE
|
||||
On success, zero is returned. When a system error occurs the last system
|
||||
error will be returned. For other errors 1 is returned.
|
||||
|
||||
The return value is always zero in quiet mode, except when wrong
|
||||
command-line options are used.
|
||||
|
||||
STANDARDS
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTHORS
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix
|
||||
mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) -
|
||||
<wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl>
|
||||
(maintainer)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge page: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
SEE ALSO
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/es/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/es/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - Convertidor de archivos de texto de formato DOS/Mac a Unix y viceversa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NOMBRE">NOMBRE</a></li>
|
||||
<li><a href="#SINOPSIS">SINOPSIS</a></li>
|
||||
<li><a href="#DESCRIPCI-N">DESCRIPCIÓN</a></li>
|
||||
<li><a href="#PAR-METROS">PARÁMETROS</a></li>
|
||||
<li><a href="#MODO-MAC">MODO MAC</a></li>
|
||||
<li><a href="#MODOS-DE-CONVERSI-N">MODOS DE CONVERSIÓN</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Codificaciones">Codificaciones</a></li>
|
||||
<li><a href="#Conversion">Conversion</a></li>
|
||||
<li><a href="#Marca-de-orden-de-bytes">Marca de orden de bytes</a></li>
|
||||
<li><a href="#Unicode-file-names-on-Windows">Unicode file names on Windows</a></li>
|
||||
<li><a href="#Ejemplos-Unicode">Ejemplos Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EJEMPLOS">EJEMPLOS</a></li>
|
||||
<li><a href="#CONVERSI-N-RECURSIVA">CONVERSIÓN RECURSIVA</a></li>
|
||||
<li><a href="#INTERNACIONALIZACI-N">INTERNACIONALIZACIÓN</a></li>
|
||||
<li><a href="#VALOR-DE-RETORNO">VALOR DE RETORNO</a></li>
|
||||
<li><a href="#EST-NDARES">ESTÁNDARES</a></li>
|
||||
<li><a href="#AUTORES">AUTORES</a></li>
|
||||
<li><a href="#V-ASE-TAMBI-N">VÉASE TAMBIÉN</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NOMBRE">NOMBRE</h1>
|
||||
|
||||
<p>dos2unix - Convertidor de archivos de texto de formato DOS/Mac a Unix y viceversa</p>
|
||||
|
||||
<h1 id="SINOPSIS">SINOPSIS</h1>
|
||||
|
||||
<pre><code>dos2unix [parámetros] [ARCHIVO ...] [-n ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...]
|
||||
unix2dos [parámetros] [ARCHIVO ...] [-n ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...]</code></pre>
|
||||
|
||||
<h1 id="DESCRIPCI-N">DESCRIPCIÓN</h1>
|
||||
|
||||
<p>The dos2unix package includes utilities <code>dos2unix</code> and <code>unix2dos</code> to convert plain text files in DOS or Mac format to Unix format and vice versa.</p>
|
||||
|
||||
<p>En archivos de texto DOS/Windows, un salto de línea, también conocido como nueva línea, es una combinación de dos caracteres: un retorno de carro (CR) seguido por un salto de línea (LF). En archivos de texto Unix, un salto de línea es solamente un carácter: el salto de línea (LF). En archivos de texto Mac, antes de Mac OS X, un salto de línea era sólo un carácter retorno de carro (CR). Actualmente, Mac OS usa el estilo Unix de saltos de línea (LF).</p>
|
||||
|
||||
<p>Besides line breaks dos2unix can also convert the encoding of files. A few DOS code pages can be converted to Unix Latin-1. And Windows Unicode (UTF-16) files can be converted to Unix Unicode (UTF-8) files.</p>
|
||||
|
||||
<p>Los archivos binarios son ignorados automáticamente, a menos que se fuerce su conversión.</p>
|
||||
|
||||
<p>Los archivos no regulares, tales como directorios y FIFO, son ignorados automáticamente.</p>
|
||||
|
||||
<p>Los enlaces simbólicos y sus destinos no son modificados por defecto. Los enlaces simbólicos pueden opcionalmente ser reemplazados, o la salida puede ser escrita al destino simbólico del enlace. En Windows no está soportada la escritura a enlaces simbólicos.</p>
|
||||
|
||||
<p>dos2unix was modelled after dos2unix under SunOS/Solaris. There is one important difference with the original SunOS/Solaris version. This version does by default in-place conversion (old file mode), while the original SunOS/Solaris version only supports paired conversion (new file mode). See also options <code>-o</code> and <code>-n</code>. Another difference is that the SunOS/Solaris version uses by default <i>iso</i> mode conversion while this version uses by default <i>ascii</i> mode conversion.</p>
|
||||
|
||||
<h1 id="PAR-METROS">PARÁMETROS</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Todos los parámetros siguientes son tratados como nombres de archivo. Use este parámetro si desea convertir archivos cuyos nombres inician con un guión. Por ejemplo para convertir un archivoo llamado "-foo", use este comando:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>O en modo de archivo nuevo:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Allow file ownership change in old file mode.</p>
|
||||
|
||||
<p>When this option is used, the conversion will not be aborted when the user and/or group ownership of the original file can't be preserved in old file mode. Conversion will continue and the converted file will get the same new ownership as if it was converted in new file mode. See also options <code>-o</code> and <code>-n</code>. This option is only available if dos2unix has support for preserving the user and group ownership of files.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Default conversion mode. See also section CONVERSION MODES.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversión entre el conjunto de caracteres DOS e ISO-8859-1. Véase también la sección MODOS DE CONVERSIÓN.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos Windows 1252 (Europa Occidental).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos DOS 437 (EE. UU.). Está es la página de códigos usada por defecto para conversión ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos DOS 850 (Europa Occidental).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos DOS 860 (Portugués).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos DOS 863 (Francocanadiense).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa la página de códigos DOS 865 (Nórdico).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convierte caracteres de 8 bits al espacio de 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mantiene la Marca de Orden de Byte (BOM). Cuando el archivo de entrada tiene BOM, escribe BOM en el archivo de salida. Este es el comportamiento por defecto en la conversión a saltos de línea DOS. Vea también la opción <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-CONVMODE"><b>-c, --convmode CONVMODE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Establece el modo de conversión, Donde CONVMODE puede ser: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> siendo ascii el valor por defecto.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-ENCODING"><b>-D, --display-enc ENCODING</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Set encoding of displayed text. Where ENCODING is one of: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i> with ansi being the default.</p>
|
||||
|
||||
<p>This option is only available in dos2unix for Windows with Unicode file name support. This option has no effect on the actual file names read and written, only on how they are displayed.</p>
|
||||
|
||||
<p>There are several methods for displaying text in a Windows console based on the encoding of the text. They all have their own advantages and disadvantages.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix's default method is to use ANSI encoded text. The advantage is that it is backwards compatible. It works with raster and TrueType fonts. In some regions you may need to change the active DOS OEM code page to the Windows system ANSI code page using the <code>chcp</code> command, because dos2unix uses the Windows system code page.</p>
|
||||
|
||||
<p>The disadvantage of ansi is that international file names with characters not inside the system default code page are not displayed properly. You will see a question mark, or a wrong symbol instead. When you don't work with foreign file names this method is OK.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>The advantage of unicode (the Windows name for UTF-16) encoding is that text is usually properly displayed. There is no need to change the active code page. You may need to set the console's font to a TrueType font to have international characters displayed properly. When a character is not included in the TrueType font you usually see a small square, sometimes with a question mark in it.</p>
|
||||
|
||||
<p>When you use the ConEmu console all text is displayed properly, because ConEmu automatically selects a good font.</p>
|
||||
|
||||
<p>The disadvantage of unicode is that it is not compatible with ASCII. The output is not easy to handle when you redirect it to another program.</p>
|
||||
|
||||
<p>When method <code>unicodebom</code> is used the Unicode text will be preceded with a BOM (Byte Order Mark). A BOM is required for correct redirection or piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>The advantage of utf8 is that it is compatible with ASCII. You need to set the console's font to a TrueType font. With a TrueType font the text is displayed similar as with the <code>unicode</code> encoding.</p>
|
||||
|
||||
<p>The disadvantage is that when you use the default raster font all non-ASCII characters are displayed wrong. Not only unicode file names, but also translated messages become unreadable. On Windows configured for an East-Asian region you may see a lot of flickering of the console when the messages are displayed.</p>
|
||||
|
||||
<p>In a ConEmu console the utf8 encoding method works well.</p>
|
||||
|
||||
<p>When method <code>utf8bom</code> is used the UTF-8 text will be preceded with a BOM (Byte Order Mark). A BOM is required for correct redirection or piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>The default encoding can be changed with environment variable DOS2UNIX_DISPLAY_ENC by setting it to <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code>, or <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Add a line break to the last line if there isn't one. This works for every conversion.</p>
|
||||
|
||||
<p>A file converted from DOS to Unix format may lack a line break on the last line. There are text editors that write text files without a line break on the last line. Some Unix programs have problems processing these files, because the POSIX standard defines that every line in a text file must end with a terminating newline character. For instance concatenating files may not give the expected result.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Return an error if a binary file is skipped.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Fuerza la conversión de archivos binarios.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>En Windows los archivos UTF-16 se convierten por defecto a UTF-8, sin tener en cuenta la configuración local. Use esta opción para convertir archivos UTF-16 a GB18030. Esta opción sólo está disponible en Windows.l Véase también la sección GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Despiega la ayuda y termina el programa.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-MARCAS---info-MARCAS-ARCHIVO"><b>-i[MARCAS], --info[= MARCAS] ARCHIVO ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra la información del archivo. No se realiza ninguna conversión.</p>
|
||||
|
||||
<p>Se muestra la siguiente información, en este orden: número de saltos de línea DOS, número de saltos de línea Unix, número de saltos de línea Mac, Marca de Orden de Byte, de texto o binario, nombre del archivo.</p>
|
||||
|
||||
<p>Ejemplo de salida:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Note that sometimes a binary file can be mistaken for a text file. See also option <code>-s</code>.</p>
|
||||
|
||||
<p>If in addition option <code>-e</code> or <code>--add-eol</code> is used also the type of the line break of the last line is printed, or <code>noeol</code> if there is none.</p>
|
||||
|
||||
<p>Ejemplo de salida:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Se pueden utilizar marcas extras opcionales para modificar la salida. Se pueden añadir una o más marcas.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print the file information lines followed by a null character instead of a newline character. This enables correct interpretation of file names with spaces or quotes when flag c is used. Use this flag in combination with xargs(1) option <code>-0</code> or <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra el número de saltos de línea DOS.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra el número de saltos de línea Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra el número de saltos de línea Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra la Marca de Orden de Byte.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra si el archivo es de texto o binario.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print the type of the line break of the last line, or <code>noeol</code> if there is none.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra sólo los archivos que pueden ser convertidos.</p>
|
||||
|
||||
<p>Con la marca <code>c</code> dos2unix sólo mostrará los archivos que contengan saltos de línea DOS, unix2dos sólo mostrará los nombres de archivo que tengan saltos de línea Unix.</p>
|
||||
|
||||
<p>If in addition option <code>-e</code> or <code>--add-eol</code> is used also the files that lack a line break on the last line will be printed.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Print a header.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Show file names without path.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Ejemplos:</p>
|
||||
|
||||
<p>Muestra información para todos los archivos *.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Muestra sólo el número de saltos de línea de DOS y de Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Muestra sólo la Marca de Orden de Byte.</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Muestra los archivos que tienen saltos de línea DOS:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Muestra los archivos que tienen saltos de línea Unix:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>List the files that have DOS line breaks or lack a line break on the last line:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Convert only files that have DOS line breaks and leave the other files untouched:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Find text files that have DOS line breaks:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mantiene la fecha del archivo de salida igual a la del archivo de entrada.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Muestra la licencia del programa.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Añade salto de línea adicional.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Sólo los saltos de línea DOS son cambiados por dos saltos de línea Unix. En modo Mac sólo los saltos de línea Mac son cambiados por dos saltos de línea Unix.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Sólo los saltos de línea Unix son cambiados por dos saltos de línea DOS. En modo Mac los saltos de línea Unix son cambiados por dos saltos de línea Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Escribe una Marca de Orden de Bytes (BOM) en el archivo de salida. Por defecto se escribe una BOM UTF-8.</p>
|
||||
|
||||
<p>Cuando el archivo de entrada es UTF-16 y se usa la opción <code>-u</code>, se escribirá un BOM UTF-16.</p>
|
||||
|
||||
<p>No utilice esta opción cuando la codificación de salida sea distinta de UTF-8, UTF-16 o GB18030. Véase también la sección UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-ARCHIVO_DE_ENTRADA-ARCHIVO_DE_SALIDA"><b>-n, --newfile ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo de archivo nuevo. Convierte el archivo ARCHIVO_DE_ENTRADA y escribe la salida al archivo ARCHIVO_DE_SALIDA. Los nombres de archivo deben ser dados en pares y los comodines <i>no</i> deben ser usados o <i>perderá</i> sus archivos.</p>
|
||||
|
||||
<p>La persona que inicia la conversión en el modo de archivo nuevo (emparejado) será el propietario del archivo convertido. Los permisos de lectura/escritura del archivo nuevo serán los permisos del archivo original menos la umask(1) de la persona que ejecute la conversión.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Don't allow file ownership change in old file mode (default).</p>
|
||||
|
||||
<p>Abort conversion when the user and/or group ownership of the original file can't be preserved in old file mode. See also options <code>-o</code> and <code>-n</code>. This option is only available if dos2unix has support for preserving the user and group ownership of files.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not add a line break to the last line if there isn't one (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not return an error if a binary file is skipped (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Write to standard output, like a Unix filter. Use option <code>-o</code> to go back to old file (in-place) mode.</p>
|
||||
|
||||
<p>Combined with option <code>-e</code> files can be properly concatenated. No merged last and first lines, and no Unicode byte order marks in the middle of the concatenated file. Example:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O file1.txt file2.txt > output.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-FILE"><b>-o, --oldfile FILE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo de archivo antiguo. Convierte el archivo ARCHIVO y lo sobrescribe con la salida. El programa por defecto se ejecuta en este modo. Se pueden emplear comodines.</p>
|
||||
|
||||
<p>En modo de archivo antiguo (in situ), el archivo convertido tiene el mismo propietario, grupo y permisos de lectura/escritura que el archivo original. Lo mismo aplica cuando el archivo es convertido por otro usuario que tiene permiso de lectura en el archivo (p.e. usuario root). La conversión será abortada cuando no sea posible preservar los valores originales. Cambiar el propietario implicaría que el propietario original ya no podrá leer el archivo. Cambiar el grupo podría ser un riesgo de seguridad, ya que el archivo podría ser accesible a personas inadecuadas. La preservación del propietario, grupo, y permisos de lectura/escritura sólo está soportada bajo Unix.</p>
|
||||
|
||||
<p>To check if dos2unix has support for preserving the user and group ownership of files type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Conversion is always done via a temporary file. When an error occurs halfway the conversion, the temporary file is deleted and the original file stays intact. When the conversion is successful, the original file is replaced with the temporary file. You may have write permission on the original file, but no permission to put the same user and/or group ownership properties on the temporary file as the original file has. This means you are not able to preserve the user and/or group ownership of the original file. In this case you can use option <code>--allow-chown</code> to continue with the conversion:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Another option is to use new file mode:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>The advantage of the <code>--allow-chown</code> option is that you can use wildcards, and the ownership properties will be preserved when possible.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo silencioso. Suprime todas las advertencias y mensajes. El valor retornado es cero. Excepto cuando se emplean parámetros incorrectos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Elimina la Marca de Orden de Byte (BOM). No escribe el BOM en el archivo de salida. Este es el comportamiento por defecto al convertir a saltos de línea Unix. Vea también la opción <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ignora los archivos binarios (por defecto).</p>
|
||||
|
||||
<p>The skipping of binary files is done to avoid accidental mistakes. Be aware that the detection of binary files is not 100% foolproof. Input files are scanned for binary symbols which are typically not found in text files. It is possible that a binary file contains only normal text characters. Such a binary file will mistakenly be seen as a text file.</p>
|
||||
|
||||
<p>By default, no error is returned when a binary file is skipped. When the <code>--error-binary</code> option is used, an error is returned.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Se asume que el formato de archivo de entrada es UTF-16LE.</p>
|
||||
|
||||
<p>Cuando existe una Marca de Orden de Bytes (BOM) en el archivo de entrada, la BOM tiene prioridad sobre esta opción.</p>
|
||||
|
||||
<p>Cuando se hace una suposición incorrecta (el archivo de entrada no estaba en formato UTF-16LE) y la conversión tiene éxito, obtendrá un archivo UTF-8 de salida con el texto erróneo. La conversión errónea puede deshacerse con iconv(1) convirtiendo el archivo UTF-8 de salida de vuelta a UTF-16LE. Esto restaurará el archivo original.</p>
|
||||
|
||||
<p>El supuesto de UTF-16LE funciona como un <i>modo de conversión</i>. Al cambiar al modo por defecto <i>ascii</i> el supuesto UTF-16LE es deshabilitado.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Se asume que el formato del archivo de entrada es UTF-16BE.</p>
|
||||
|
||||
<p>Esta opción funciona igual que la opción <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mostrar mensajes detallados. Se muestra información extra acerca de Marcas de Orden de Bytes (BOM) y el número de saltos de línea convertidos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Sigue los enlaces simbólicos y convierte los destinos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reemplaza los enlaces simbólicos con los archivos convertidos (los archivos destino originales no se alteran).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>No altera los enlaces simbólicos ni sus destinos (por defecto).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Despiega la información de la versión y termina el programa.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MODO-MAC">MODO MAC</h1>
|
||||
|
||||
<p>By default line breaks are converted from DOS to Unix and vice versa. Mac line breaks are not converted.</p>
|
||||
|
||||
<p>En modo Mac los saltos de línea son convertidos de Mac a Unix y viceversa. Los saltos de línea DOS no son modificados.</p>
|
||||
|
||||
<p>Para ejecutar en modo Mac use el modificador <code>-c mac</code> o use los comandos <code>mac2unix</code> o <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="MODOS-DE-CONVERSI-N">MODOS DE CONVERSIÓN</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>This is the default conversion mode. This mode is for converting ASCII and ASCII-compatible encoded files, like UTF-8. Enabling <b>ascii</b> mode disables <b>7bit</b> and <b>iso</b> mode.</p>
|
||||
|
||||
<p>If dos2unix has UTF-16 support, UTF-16 encoded files are converted to the current locale character encoding on POSIX systems and to UTF-8 on Windows. Enabling <b>ascii</b> mode disables the option to keep UTF-16 encoding (<code>-u</code>) and the options to assume UTF-16 input (<code>-ul</code> and <code>-ub</code>). To see if dos2unix has UTF-16 support type <code>dos2unix -V</code>. See also section UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>En este modo todos los caracteres no ASCII de 8 bits (con valores de 128 a 255) son convertidos al espacio de 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Los caracteres son convertidos entre un conjunto de caracteres DOS (página de códigos) y el conjunto de caracteres ISO-8859-1 (Latín-1) de Unix. Los caracteres DOS sin equivalente ISO-8859-1, para los cuales la conversión es imposible, son convertidos en un punto. Lo mismo se aplica para caracteres ISO-8859-1 sin contraparte DOS.</p>
|
||||
|
||||
<p>Cuando sólo se emplea el parámetro <code>-iso</code>, dos2unix intentará determinar la página de códigos activa. Cuando esto no sea posible, dos2unix utilizará la página de códigos 437 por defecto, la cual es empleada principalmente en EE. UU. Para forzar una página de códigos específica emplee los parámetros <code>-437</code> (EE. UU.), <code>-850</code> (Europa Occidental), <code>-860</code> (Portugués), <code>-863</code> (Francocanadiense), o <code>-865</code> (Nórdico). La página de códigos Windows 1252 (Europa Occidental) también está soportada con el parámetro <code>-1252</code>. Para acceder a otras páginas de códigos use dos2unix en combinación con iconv(1). Iconv puede convertir entre una larga lista de codificaciones de caracteres.</p>
|
||||
|
||||
<p>No use la conversión ISO en archivos de texto Unicode. Esto corrompería los archivos codificados como UTF-8.</p>
|
||||
|
||||
<p>Algunos ejemplos:</p>
|
||||
|
||||
<p>Convierte de la página de códigos por defecto de DOS a Latín-1 de Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de DOS CP850 a Unix Latín-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Windows CP1252 a Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Windows CP1252 a Unix UTF-8 (Unicode).</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Unix Latin-1 a la página de códigos por defecto de DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Unix Latin-1 a DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Unix Latin-1 a Windows CP1252.</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convierte de Unix UTF-8 (Unicode) a Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Codificaciones">Codificaciones</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Conversion">Conversion</h2>
|
||||
|
||||
<p>Unicode text files can have DOS, Unix or Mac line breaks, like ASCII text files.</p>
|
||||
|
||||
<p>Todas las versiones de dos2unix y unix2dos pueden convertir archivos codificados como UTF-8, debido a que UTF-8 fue diseñado para retro-compatibilidad con ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>En Unix/Linux los archivos codificados con UTF-16 se convierten a la codificación de caracteres local. Use el comando locale(1) para averiguar la codificación de caracteres local. Cuando no se puede hacer la conversión se obtendrá un error de conversión y se omitirá el archivo.</p>
|
||||
|
||||
<p>En Windows los archivos UTF-16 se convierten por defecto a UTF-8. Los archivos de texto forrajeados con UTF-8 están soportados tanto en Windows como en Unix/Linux.</p>
|
||||
|
||||
<p>Las codificaciones UTF-16 y UTF-8 son totalmente compatibles, no se perderá ningún texto en la conversión. Cuando ocurre un error de conversión de UTF-16 a UTF-8, por ejemplo cuando el archivo de entrada UTF-16 contiene un error, se omitirá el archivo.</p>
|
||||
|
||||
<p>Cuando se usa la opción <code>-u</code>, el archivo de salida se escribirá en la misma codificación UTF-16 que el archivo de entrada. La opción <code>-u</code> previene la conversión a UTF-8.</p>
|
||||
|
||||
<p>dos2unix and unix2dos have no option to convert UTF-8 files to UTF-16.</p>
|
||||
|
||||
<p>La conversión en modos ISO y 7-bit no funciona en archivos UTF-16.</p>
|
||||
|
||||
<h2 id="Marca-de-orden-de-bytes">Marca de orden de bytes</h2>
|
||||
|
||||
<p>On Windows Unicode text files typically have a Byte Order Mark (BOM), because many Windows programs (including Notepad) add BOMs by default. See also <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>En Unix los archivos Unicode no suelen tener BOM. Se supone que los archivos de texto son codificados en la codificación local de caracteres.</p>
|
||||
|
||||
<p>dos2unix can only detect if a file is in UTF-16 format if the file has a BOM. When an UTF-16 file doesn't have a BOM, dos2unix will see the file as a binary file.</p>
|
||||
|
||||
<p>Use la opción <code>-ul</code> o <code>-ub</code> para convertir un archivo UTF-16 sin BOM.</p>
|
||||
|
||||
<p>dos2unix writes by default no BOM in the output file. With option <code>-b</code> dos2unix writes a BOM when the input file has a BOM.</p>
|
||||
|
||||
<p>unix2dos writes by default a BOM in the output file when the input file has a BOM. Use option <code>-r</code> to remove the BOM.</p>
|
||||
|
||||
<p>dos2unix and unix2dos write always a BOM when option <code>-m</code> is used.</p>
|
||||
|
||||
<h2 id="Unicode-file-names-on-Windows">Unicode file names on Windows</h2>
|
||||
|
||||
<p>dos2unix has optional support for reading and writing Unicode file names in the Windows Command Prompt. That means that dos2unix can open files that have characters in the name that are not part of the default system ANSI code page. To see if dos2unix for Windows was built with Unicode file name support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>There are some issues with displaying Unicode file names in a Windows console. See option <code>-D</code>, <code>--display-enc</code>. The file names may be displayed wrongly in the console, but the files will be written with the correct name.</p>
|
||||
|
||||
<h2 id="Ejemplos-Unicode">Ejemplos Unicode</h2>
|
||||
|
||||
<p>Convertir de Windows UTF-16 (con una BOM) a Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convertir de Windows UTF-16LE (sin una BOM) a Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convertir de Unix UTF-8 a Windows UTF-8 sin una BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Convertir de Unix UTF-8 a Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 is a Chinese government standard. A mandatory subset of the GB18030 standard is officially required for all software products sold in China. See also <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 es totalmente compatible con Unicode y puede considerarse como formato de transformación Unicode. Como ocurre con UTF-8, GB18030 es compatible con ASCII. GB18030 también es compatible con la página de códigos de Windows 936, también conocida como GBK.</p>
|
||||
|
||||
<p>En Unix/Linux los archivos UTF-16 se convierten a GB18030 cuando la codificación local se establece en GB18030. Tenga en cuenta que esto sólo funcionará si la configuración local es soportada por el sistema. Utilice <code>locale -a</code> para obtener el listado de configuraciones regionales admitidas.</p>
|
||||
|
||||
<p>Use la opción <code>-ul</code> o <code>-ub</code> para convertir un archivo UTF-16 sin BOM.</p>
|
||||
|
||||
<p>Los archivos codificados como GB18030 pueden tener una Marca de Orden de Bytes, como ocurre con los archivos Unicode.</p>
|
||||
|
||||
<h1 id="EJEMPLOS">EJEMPLOS</h1>
|
||||
|
||||
<p>Lee la entrada desde 'stdin' y escribe la salida a 'stdout':</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Convierte y reemplaza a.txt. Convierte y reemplaza b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Convierte y reemplaza a.txt empleando modo de conversión ascii:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Convierte y reemplaza a.txt empleando modo de conversión ascii, convierte y reemplaza b.txt empleando modo de conversión de 7bits:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Convierte a.txt del formato de Mac a Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Convierte a.txt del formato de Unix a Mac:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Convierte y reemplaza a.txt manteniendo la fecha del archivo original:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Convierte a.txt y escribe la salida en e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convierte a.txt y escribe la salida en e.txt, manteniendo la fecha de e.txt igual a la de a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convierte y reemplaza a.txt, convierte b.txt y escribe en e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Convierte c.txt y escribe en e.txt, convierte y reemplaza a.txt, convierte y reemplaza b.txt, convierte d.txt y escribe en f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="CONVERSI-N-RECURSIVA">CONVERSIÓN RECURSIVA</h1>
|
||||
|
||||
<p>In a Unix shell the find(1) and xargs(1) commands can be used to run dos2unix recursively over all text files in a directory tree. For instance to convert all .txt files in the directory tree under the current directory type:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>The find(1) option <code>-print0</code> and corresponding xargs(1) option <code>-0</code> are needed when there are files with spaces or quotes in the name. Otherwise these options can be omitted. Another option is to use find(1) with the <code>-exec</code> option:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>In a Windows Command Prompt the following command can be used:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>PowerShell users can use the following command in Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="INTERNACIONALIZACI-N">INTERNACIONALIZACIÓN</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>El idioma principal se selecciona con la variable de entorno LANG. La variable LANG consiste de varias partes. La primer parte es el código del idioma en minúsculas. La segunda es opcional y es el código del país en mayúsculas, precedido por un guión bajo. Existe también una tercera parte opcional: la codificación de caracteres, precedida por un punto. Unos cuantos ejemplos para intérpretes de comandos tipo POSIX estándar:</p>
|
||||
|
||||
<pre><code>export LANG=nl Neerlandés
|
||||
export LANG=nl_NL Neerlandés, Países Bajos
|
||||
export LANG=nl_BE Neerlandés, Bélgica
|
||||
export LANG=es_ES Español, España
|
||||
export LANG=es_MX Español, México
|
||||
export LANG=en_US.iso88591 Ingles, EE. UU., codificación Latín-1
|
||||
export LANG=en_GB.UTF-8 Ingles, Reino Unido, codificación UTF-8</code></pre>
|
||||
|
||||
<p>For a complete list of language and country codes see the gettext manual: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>En sistemas Unix puede emplear el comando locale(1) para obtener información específica de locale.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>With the LANGUAGE environment variable you can specify a priority list of languages, separated by colons. dos2unix gives preference to LANGUAGE over LANG. For instance, first Dutch and then German: <code>LANGUAGE=nl:de</code>. You have to first enable localization, by setting LANG (or LC_ALL) to a value other than "C", before you can use a language priority list through the LANGUAGE variable. See also the gettext manual: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Si selecciona un idioma que no está disponible el programa funcionará en ingles.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Con la variable de entorno DOS2UNIX_LOCALEDIR el LOCALEDIR asignado durante la compilación puede ser modificado. LOCALEDIR es usado para encontrar los archivos de idioma. El valor por defecto de GNU es <code>/usr/local/share/locale</code>. El parámetro <b>--version</b> mostrará el LOCALEDIR en uso.</p>
|
||||
|
||||
<p>Ejemplo (intérprete de comandos POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="VALOR-DE-RETORNO">VALOR DE RETORNO</h1>
|
||||
|
||||
<p>Se regresa cero cuando el programa termina exitosamente. Cuando ocurre un error del sistema se regresará el último número de error del sistema. Para otros errores se regresa 1.</p>
|
||||
|
||||
<p>El valor de retorno es siempre cero en modo silencioso, excepto cuando se emplean parámetros incorrectos.</p>
|
||||
|
||||
<h1 id="EST-NDARES">ESTÁNDARES</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTORES">AUTORES</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (maintainer)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge page: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="V-ASE-TAMBI-N">VÉASE TAMBIÉN</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
840
Agent-Windows/OGP64/usr/share/doc/dos2unix/es/dos2unix.txt
Normal file
840
Agent-Windows/OGP64/usr/share/doc/dos2unix/es/dos2unix.txt
Normal file
|
|
@ -0,0 +1,840 @@
|
|||
NOMBRE
|
||||
dos2unix - Convertidor de archivos de texto de formato DOS/Mac a Unix y
|
||||
viceversa
|
||||
|
||||
SINOPSIS
|
||||
dos2unix [parámetros] [ARCHIVO ...] [-n ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...]
|
||||
unix2dos [parámetros] [ARCHIVO ...] [-n ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...]
|
||||
|
||||
DESCRIPCIÓN
|
||||
The dos2unix package includes utilities "dos2unix" and "unix2dos" to
|
||||
convert plain text files in DOS or Mac format to Unix format and vice
|
||||
versa.
|
||||
|
||||
En archivos de texto DOS/Windows, un salto de línea, también conocido
|
||||
como nueva línea, es una combinación de dos caracteres: un retorno de
|
||||
carro (CR) seguido por un salto de línea (LF). En archivos de texto
|
||||
Unix, un salto de línea es solamente un carácter: el salto de línea
|
||||
(LF). En archivos de texto Mac, antes de Mac OS X, un salto de línea era
|
||||
sólo un carácter retorno de carro (CR). Actualmente, Mac OS usa el
|
||||
estilo Unix de saltos de línea (LF).
|
||||
|
||||
Besides line breaks dos2unix can also convert the encoding of files. A
|
||||
few DOS code pages can be converted to Unix Latin-1. And Windows Unicode
|
||||
(UTF-16) files can be converted to Unix Unicode (UTF-8) files.
|
||||
|
||||
Los archivos binarios son ignorados automáticamente, a menos que se
|
||||
fuerce su conversión.
|
||||
|
||||
Los archivos no regulares, tales como directorios y FIFO, son ignorados
|
||||
automáticamente.
|
||||
|
||||
Los enlaces simbólicos y sus destinos no son modificados por defecto.
|
||||
Los enlaces simbólicos pueden opcionalmente ser reemplazados, o la
|
||||
salida puede ser escrita al destino simbólico del enlace. En Windows no
|
||||
está soportada la escritura a enlaces simbólicos.
|
||||
|
||||
dos2unix was modelled after dos2unix under SunOS/Solaris. There is one
|
||||
important difference with the original SunOS/Solaris version. This
|
||||
version does by default in-place conversion (old file mode), while the
|
||||
original SunOS/Solaris version only supports paired conversion (new file
|
||||
mode). See also options "-o" and "-n". Another difference is that the
|
||||
SunOS/Solaris version uses by default *iso* mode conversion while this
|
||||
version uses by default *ascii* mode conversion.
|
||||
|
||||
PARÁMETROS
|
||||
-- Todos los parámetros siguientes son tratados como nombres de
|
||||
archivo. Use este parámetro si desea convertir archivos cuyos
|
||||
nombres inician con un guión. Por ejemplo para convertir un archivoo
|
||||
llamado "-foo", use este comando:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
O en modo de archivo nuevo:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
Allow file ownership change in old file mode.
|
||||
|
||||
When this option is used, the conversion will not be aborted when
|
||||
the user and/or group ownership of the original file can't be
|
||||
preserved in old file mode. Conversion will continue and the
|
||||
converted file will get the same new ownership as if it was
|
||||
converted in new file mode. See also options "-o" and "-n". This
|
||||
option is only available if dos2unix has support for preserving the
|
||||
user and group ownership of files.
|
||||
|
||||
-ascii
|
||||
Default conversion mode. See also section CONVERSION MODES.
|
||||
|
||||
-iso
|
||||
Conversión entre el conjunto de caracteres DOS e ISO-8859-1. Véase
|
||||
también la sección MODOS DE CONVERSIÓN.
|
||||
|
||||
-1252
|
||||
Usa la página de códigos Windows 1252 (Europa Occidental).
|
||||
|
||||
-437
|
||||
Usa la página de códigos DOS 437 (EE. UU.). Está es la página de
|
||||
códigos usada por defecto para conversión ISO.
|
||||
|
||||
-850
|
||||
Usa la página de códigos DOS 850 (Europa Occidental).
|
||||
|
||||
-860
|
||||
Usa la página de códigos DOS 860 (Portugués).
|
||||
|
||||
-863
|
||||
Usa la página de códigos DOS 863 (Francocanadiense).
|
||||
|
||||
-865
|
||||
Usa la página de códigos DOS 865 (Nórdico).
|
||||
|
||||
-7 Convierte caracteres de 8 bits al espacio de 7 bits.
|
||||
|
||||
-b, --keep-bom
|
||||
Mantiene la Marca de Orden de Byte (BOM). Cuando el archivo de
|
||||
entrada tiene BOM, escribe BOM en el archivo de salida. Este es el
|
||||
comportamiento por defecto en la conversión a saltos de línea DOS.
|
||||
Vea también la opción "-r".
|
||||
|
||||
-c, --convmode CONVMODE
|
||||
Establece el modo de conversión, Donde CONVMODE puede ser: *ascii*,
|
||||
*7bit*, *iso*, *mac* siendo ascii el valor por defecto.
|
||||
|
||||
-D, --display-enc ENCODING
|
||||
Set encoding of displayed text. Where ENCODING is one of: *ansi*,
|
||||
*unicode*, *unicodebom*, *utf8*, *utf8bom* with ansi being the
|
||||
default.
|
||||
|
||||
This option is only available in dos2unix for Windows with Unicode
|
||||
file name support. This option has no effect on the actual file
|
||||
names read and written, only on how they are displayed.
|
||||
|
||||
There are several methods for displaying text in a Windows console
|
||||
based on the encoding of the text. They all have their own
|
||||
advantages and disadvantages.
|
||||
|
||||
ansi
|
||||
dos2unix's default method is to use ANSI encoded text. The
|
||||
advantage is that it is backwards compatible. It works with
|
||||
raster and TrueType fonts. In some regions you may need to
|
||||
change the active DOS OEM code page to the Windows system ANSI
|
||||
code page using the "chcp" command, because dos2unix uses the
|
||||
Windows system code page.
|
||||
|
||||
The disadvantage of ansi is that international file names with
|
||||
characters not inside the system default code page are not
|
||||
displayed properly. You will see a question mark, or a wrong
|
||||
symbol instead. When you don't work with foreign file names this
|
||||
method is OK.
|
||||
|
||||
unicode, unicodebom
|
||||
The advantage of unicode (the Windows name for UTF-16) encoding
|
||||
is that text is usually properly displayed. There is no need to
|
||||
change the active code page. You may need to set the console's
|
||||
font to a TrueType font to have international characters
|
||||
displayed properly. When a character is not included in the
|
||||
TrueType font you usually see a small square, sometimes with a
|
||||
question mark in it.
|
||||
|
||||
When you use the ConEmu console all text is displayed properly,
|
||||
because ConEmu automatically selects a good font.
|
||||
|
||||
The disadvantage of unicode is that it is not compatible with
|
||||
ASCII. The output is not easy to handle when you redirect it to
|
||||
another program.
|
||||
|
||||
When method "unicodebom" is used the Unicode text will be
|
||||
preceded with a BOM (Byte Order Mark). A BOM is required for
|
||||
correct redirection or piping in PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
The advantage of utf8 is that it is compatible with ASCII. You
|
||||
need to set the console's font to a TrueType font. With a
|
||||
TrueType font the text is displayed similar as with the
|
||||
"unicode" encoding.
|
||||
|
||||
The disadvantage is that when you use the default raster font
|
||||
all non-ASCII characters are displayed wrong. Not only unicode
|
||||
file names, but also translated messages become unreadable. On
|
||||
Windows configured for an East-Asian region you may see a lot of
|
||||
flickering of the console when the messages are displayed.
|
||||
|
||||
In a ConEmu console the utf8 encoding method works well.
|
||||
|
||||
When method "utf8bom" is used the UTF-8 text will be preceded
|
||||
with a BOM (Byte Order Mark). A BOM is required for correct
|
||||
redirection or piping in PowerShell.
|
||||
|
||||
The default encoding can be changed with environment variable
|
||||
DOS2UNIX_DISPLAY_ENC by setting it to "unicode", "unicodebom",
|
||||
"utf8", or "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Add a line break to the last line if there isn't one. This works for
|
||||
every conversion.
|
||||
|
||||
A file converted from DOS to Unix format may lack a line break on
|
||||
the last line. There are text editors that write text files without
|
||||
a line break on the last line. Some Unix programs have problems
|
||||
processing these files, because the POSIX standard defines that
|
||||
every line in a text file must end with a terminating newline
|
||||
character. For instance concatenating files may not give the
|
||||
expected result.
|
||||
|
||||
--error-binary
|
||||
Return an error if a binary file is skipped.
|
||||
|
||||
-f, --force
|
||||
Fuerza la conversión de archivos binarios.
|
||||
|
||||
-gb, --gb18030
|
||||
En Windows los archivos UTF-16 se convierten por defecto a UTF-8,
|
||||
sin tener en cuenta la configuración local. Use esta opción para
|
||||
convertir archivos UTF-16 a GB18030. Esta opción sólo está
|
||||
disponible en Windows.l Véase también la sección GB18030.
|
||||
|
||||
-h, --help
|
||||
Despiega la ayuda y termina el programa.
|
||||
|
||||
-i[MARCAS], --info[= MARCAS] ARCHIVO ...
|
||||
Muestra la información del archivo. No se realiza ninguna
|
||||
conversión.
|
||||
|
||||
Se muestra la siguiente información, en este orden: número de saltos
|
||||
de línea DOS, número de saltos de línea Unix, número de saltos de
|
||||
línea Mac, Marca de Orden de Byte, de texto o binario, nombre del
|
||||
archivo.
|
||||
|
||||
Ejemplo de salida:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Note that sometimes a binary file can be mistaken for a text file.
|
||||
See also option "-s".
|
||||
|
||||
If in addition option "-e" or "--add-eol" is used also the type of
|
||||
the line break of the last line is printed, or "noeol" if there is
|
||||
none.
|
||||
|
||||
Ejemplo de salida:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Se pueden utilizar marcas extras opcionales para modificar la
|
||||
salida. Se pueden añadir una o más marcas.
|
||||
|
||||
0 Print the file information lines followed by a null character
|
||||
instead of a newline character. This enables correct
|
||||
interpretation of file names with spaces or quotes when flag c
|
||||
is used. Use this flag in combination with xargs(1) option -0 or
|
||||
"--null".
|
||||
|
||||
d Muestra el número de saltos de línea DOS.
|
||||
|
||||
u Muestra el número de saltos de línea Unix.
|
||||
|
||||
m Muestra el número de saltos de línea Mac.
|
||||
|
||||
b Muestra la Marca de Orden de Byte.
|
||||
|
||||
t Muestra si el archivo es de texto o binario.
|
||||
|
||||
e Print the type of the line break of the last line, or "noeol" if
|
||||
there is none.
|
||||
|
||||
c Muestra sólo los archivos que pueden ser convertidos.
|
||||
|
||||
Con la marca "c" dos2unix sólo mostrará los archivos que
|
||||
contengan saltos de línea DOS, unix2dos sólo mostrará los
|
||||
nombres de archivo que tengan saltos de línea Unix.
|
||||
|
||||
If in addition option "-e" or "--add-eol" is used also the files
|
||||
that lack a line break on the last line will be printed.
|
||||
|
||||
h Print a header.
|
||||
|
||||
p Show file names without path.
|
||||
|
||||
Ejemplos:
|
||||
|
||||
Muestra información para todos los archivos *.txt:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Muestra sólo el número de saltos de línea de DOS y de Unix:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Muestra sólo la Marca de Orden de Byte.
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Muestra los archivos que tienen saltos de línea DOS:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Muestra los archivos que tienen saltos de línea Unix:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
List the files that have DOS line breaks or lack a line break on the
|
||||
last line:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Convert only files that have DOS line breaks and leave the other
|
||||
files untouched:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Find text files that have DOS line breaks:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Mantiene la fecha del archivo de salida igual a la del archivo de
|
||||
entrada.
|
||||
|
||||
-L, --license
|
||||
Muestra la licencia del programa.
|
||||
|
||||
-l, --newline
|
||||
Añade salto de línea adicional.
|
||||
|
||||
dos2unix: Sólo los saltos de línea DOS son cambiados por dos saltos
|
||||
de línea Unix. En modo Mac sólo los saltos de línea Mac son
|
||||
cambiados por dos saltos de línea Unix.
|
||||
|
||||
unix2dos: Sólo los saltos de línea Unix son cambiados por dos saltos
|
||||
de línea DOS. En modo Mac los saltos de línea Unix son cambiados por
|
||||
dos saltos de línea Mac.
|
||||
|
||||
-m, --add-bom
|
||||
Escribe una Marca de Orden de Bytes (BOM) en el archivo de salida.
|
||||
Por defecto se escribe una BOM UTF-8.
|
||||
|
||||
Cuando el archivo de entrada es UTF-16 y se usa la opción "-u", se
|
||||
escribirá un BOM UTF-16.
|
||||
|
||||
No utilice esta opción cuando la codificación de salida sea distinta
|
||||
de UTF-8, UTF-16 o GB18030. Véase también la sección UNICODE.
|
||||
|
||||
-n, --newfile ARCHIVO_DE_ENTRADA ARCHIVO_DE_SALIDA ...
|
||||
Modo de archivo nuevo. Convierte el archivo ARCHIVO_DE_ENTRADA y
|
||||
escribe la salida al archivo ARCHIVO_DE_SALIDA. Los nombres de
|
||||
archivo deben ser dados en pares y los comodines *no* deben ser
|
||||
usados o *perderá* sus archivos.
|
||||
|
||||
La persona que inicia la conversión en el modo de archivo nuevo
|
||||
(emparejado) será el propietario del archivo convertido. Los
|
||||
permisos de lectura/escritura del archivo nuevo serán los permisos
|
||||
del archivo original menos la umask(1) de la persona que ejecute la
|
||||
conversión.
|
||||
|
||||
--no-allow-chown
|
||||
Don't allow file ownership change in old file mode (default).
|
||||
|
||||
Abort conversion when the user and/or group ownership of the
|
||||
original file can't be preserved in old file mode. See also options
|
||||
"-o" and "-n". This option is only available if dos2unix has support
|
||||
for preserving the user and group ownership of files.
|
||||
|
||||
--no-add-eol
|
||||
Do not add a line break to the last line if there isn't one
|
||||
(default).
|
||||
|
||||
--no-error-binary
|
||||
Do not return an error if a binary file is skipped (default).
|
||||
|
||||
-O, --to-stdout
|
||||
Write to standard output, like a Unix filter. Use option "-o" to go
|
||||
back to old file (in-place) mode.
|
||||
|
||||
Combined with option "-e" files can be properly concatenated. No
|
||||
merged last and first lines, and no Unicode byte order marks in the
|
||||
middle of the concatenated file. Example:
|
||||
|
||||
dos2unix -e -O file1.txt file2.txt > output.txt
|
||||
|
||||
-o, --oldfile FILE ...
|
||||
Modo de archivo antiguo. Convierte el archivo ARCHIVO y lo
|
||||
sobrescribe con la salida. El programa por defecto se ejecuta en
|
||||
este modo. Se pueden emplear comodines.
|
||||
|
||||
En modo de archivo antiguo (in situ), el archivo convertido tiene el
|
||||
mismo propietario, grupo y permisos de lectura/escritura que el
|
||||
archivo original. Lo mismo aplica cuando el archivo es convertido
|
||||
por otro usuario que tiene permiso de lectura en el archivo (p.e.
|
||||
usuario root). La conversión será abortada cuando no sea posible
|
||||
preservar los valores originales. Cambiar el propietario implicaría
|
||||
que el propietario original ya no podrá leer el archivo. Cambiar el
|
||||
grupo podría ser un riesgo de seguridad, ya que el archivo podría
|
||||
ser accesible a personas inadecuadas. La preservación del
|
||||
propietario, grupo, y permisos de lectura/escritura sólo está
|
||||
soportada bajo Unix.
|
||||
|
||||
To check if dos2unix has support for preserving the user and group
|
||||
ownership of files type "dos2unix -V".
|
||||
|
||||
Conversion is always done via a temporary file. When an error occurs
|
||||
halfway the conversion, the temporary file is deleted and the
|
||||
original file stays intact. When the conversion is successful, the
|
||||
original file is replaced with the temporary file. You may have
|
||||
write permission on the original file, but no permission to put the
|
||||
same user and/or group ownership properties on the temporary file as
|
||||
the original file has. This means you are not able to preserve the
|
||||
user and/or group ownership of the original file. In this case you
|
||||
can use option "--allow-chown" to continue with the conversion:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Another option is to use new file mode:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
The advantage of the "--allow-chown" option is that you can use
|
||||
wildcards, and the ownership properties will be preserved when
|
||||
possible.
|
||||
|
||||
-q, --quiet
|
||||
Modo silencioso. Suprime todas las advertencias y mensajes. El valor
|
||||
retornado es cero. Excepto cuando se emplean parámetros incorrectos.
|
||||
|
||||
-r, --remove-bom
|
||||
Elimina la Marca de Orden de Byte (BOM). No escribe el BOM en el
|
||||
archivo de salida. Este es el comportamiento por defecto al
|
||||
convertir a saltos de línea Unix. Vea también la opción "-b".
|
||||
|
||||
-s, --safe
|
||||
Ignora los archivos binarios (por defecto).
|
||||
|
||||
The skipping of binary files is done to avoid accidental mistakes.
|
||||
Be aware that the detection of binary files is not 100% foolproof.
|
||||
Input files are scanned for binary symbols which are typically not
|
||||
found in text files. It is possible that a binary file contains only
|
||||
normal text characters. Such a binary file will mistakenly be seen
|
||||
as a text file.
|
||||
|
||||
By default, no error is returned when a binary file is skipped. When
|
||||
the "--error-binary" option is used, an error is returned.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Se asume que el formato de archivo de entrada es UTF-16LE.
|
||||
|
||||
Cuando existe una Marca de Orden de Bytes (BOM) en el archivo de
|
||||
entrada, la BOM tiene prioridad sobre esta opción.
|
||||
|
||||
Cuando se hace una suposición incorrecta (el archivo de entrada no
|
||||
estaba en formato UTF-16LE) y la conversión tiene éxito, obtendrá un
|
||||
archivo UTF-8 de salida con el texto erróneo. La conversión errónea
|
||||
puede deshacerse con iconv(1) convirtiendo el archivo UTF-8 de
|
||||
salida de vuelta a UTF-16LE. Esto restaurará el archivo original.
|
||||
|
||||
El supuesto de UTF-16LE funciona como un *modo de conversión*. Al
|
||||
cambiar al modo por defecto *ascii* el supuesto UTF-16LE es
|
||||
deshabilitado.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Se asume que el formato del archivo de entrada es UTF-16BE.
|
||||
|
||||
Esta opción funciona igual que la opción "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Mostrar mensajes detallados. Se muestra información extra acerca de
|
||||
Marcas de Orden de Bytes (BOM) y el número de saltos de línea
|
||||
convertidos.
|
||||
|
||||
-F, --follow-symlink
|
||||
Sigue los enlaces simbólicos y convierte los destinos.
|
||||
|
||||
-R, --replace-symlink
|
||||
Reemplaza los enlaces simbólicos con los archivos convertidos (los
|
||||
archivos destino originales no se alteran).
|
||||
|
||||
-S, --skip-symlink
|
||||
No altera los enlaces simbólicos ni sus destinos (por defecto).
|
||||
|
||||
-V, --version
|
||||
Despiega la información de la versión y termina el programa.
|
||||
|
||||
MODO MAC
|
||||
By default line breaks are converted from DOS to Unix and vice versa.
|
||||
Mac line breaks are not converted.
|
||||
|
||||
En modo Mac los saltos de línea son convertidos de Mac a Unix y
|
||||
viceversa. Los saltos de línea DOS no son modificados.
|
||||
|
||||
Para ejecutar en modo Mac use el modificador "-c mac" o use los comandos
|
||||
"mac2unix" o "unix2mac".
|
||||
|
||||
MODOS DE CONVERSIÓN
|
||||
ascii
|
||||
This is the default conversion mode. This mode is for converting
|
||||
ASCII and ASCII-compatible encoded files, like UTF-8. Enabling ascii
|
||||
mode disables 7bit and iso mode.
|
||||
|
||||
If dos2unix has UTF-16 support, UTF-16 encoded files are converted
|
||||
to the current locale character encoding on POSIX systems and to
|
||||
UTF-8 on Windows. Enabling ascii mode disables the option to keep
|
||||
UTF-16 encoding ("-u") and the options to assume UTF-16 input ("-ul"
|
||||
and "-ub"). To see if dos2unix has UTF-16 support type "dos2unix
|
||||
-V". See also section UNICODE.
|
||||
|
||||
7bit
|
||||
En este modo todos los caracteres no ASCII de 8 bits (con valores de
|
||||
128 a 255) son convertidos al espacio de 7 bits.
|
||||
|
||||
iso Los caracteres son convertidos entre un conjunto de caracteres DOS
|
||||
(página de códigos) y el conjunto de caracteres ISO-8859-1 (Latín-1)
|
||||
de Unix. Los caracteres DOS sin equivalente ISO-8859-1, para los
|
||||
cuales la conversión es imposible, son convertidos en un punto. Lo
|
||||
mismo se aplica para caracteres ISO-8859-1 sin contraparte DOS.
|
||||
|
||||
Cuando sólo se emplea el parámetro "-iso", dos2unix intentará
|
||||
determinar la página de códigos activa. Cuando esto no sea posible,
|
||||
dos2unix utilizará la página de códigos 437 por defecto, la cual es
|
||||
empleada principalmente en EE. UU. Para forzar una página de códigos
|
||||
específica emplee los parámetros -437 (EE. UU.), -850 (Europa
|
||||
Occidental), -860 (Portugués), -863 (Francocanadiense), o -865
|
||||
(Nórdico). La página de códigos Windows 1252 (Europa Occidental)
|
||||
también está soportada con el parámetro -1252. Para acceder a otras
|
||||
páginas de códigos use dos2unix en combinación con iconv(1). Iconv
|
||||
puede convertir entre una larga lista de codificaciones de
|
||||
caracteres.
|
||||
|
||||
No use la conversión ISO en archivos de texto Unicode. Esto
|
||||
corrompería los archivos codificados como UTF-8.
|
||||
|
||||
Algunos ejemplos:
|
||||
|
||||
Convierte de la página de códigos por defecto de DOS a Latín-1 de
|
||||
Unix:
|
||||
|
||||
dos2unix -iso -n in.txt out.txt
|
||||
|
||||
Convierte de DOS CP850 a Unix Latín-1:
|
||||
|
||||
dos2unix -850 -n in.txt out.txt
|
||||
|
||||
Convierte de Windows CP1252 a Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n in.txt out.txt
|
||||
|
||||
Convierte de Windows CP1252 a Unix UTF-8 (Unicode).
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
|
||||
|
||||
Convierte de Unix Latin-1 a la página de códigos por defecto de DOS:
|
||||
|
||||
unix2dos -iso -n in.txt out.txt
|
||||
|
||||
Convierte de Unix Latin-1 a DOS CP850:
|
||||
|
||||
unix2dos -850 -n in.txt out.txt
|
||||
|
||||
Convierte de Unix Latin-1 a Windows CP1252.
|
||||
|
||||
unix2dos -1252 -n in.txt out.txt
|
||||
|
||||
Convierte de Unix UTF-8 (Unicode) a Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Codificaciones
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversion
|
||||
Unicode text files can have DOS, Unix or Mac line breaks, like ASCII
|
||||
text files.
|
||||
|
||||
Todas las versiones de dos2unix y unix2dos pueden convertir archivos
|
||||
codificados como UTF-8, debido a que UTF-8 fue diseñado para
|
||||
retro-compatibilidad con ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
En Unix/Linux los archivos codificados con UTF-16 se convierten a la
|
||||
codificación de caracteres local. Use el comando locale(1) para
|
||||
averiguar la codificación de caracteres local. Cuando no se puede hacer
|
||||
la conversión se obtendrá un error de conversión y se omitirá el
|
||||
archivo.
|
||||
|
||||
En Windows los archivos UTF-16 se convierten por defecto a UTF-8. Los
|
||||
archivos de texto forrajeados con UTF-8 están soportados tanto en
|
||||
Windows como en Unix/Linux.
|
||||
|
||||
Las codificaciones UTF-16 y UTF-8 son totalmente compatibles, no se
|
||||
perderá ningún texto en la conversión. Cuando ocurre un error de
|
||||
conversión de UTF-16 a UTF-8, por ejemplo cuando el archivo de entrada
|
||||
UTF-16 contiene un error, se omitirá el archivo.
|
||||
|
||||
Cuando se usa la opción "-u", el archivo de salida se escribirá en la
|
||||
misma codificación UTF-16 que el archivo de entrada. La opción "-u"
|
||||
previene la conversión a UTF-8.
|
||||
|
||||
dos2unix and unix2dos have no option to convert UTF-8 files to UTF-16.
|
||||
|
||||
La conversión en modos ISO y 7-bit no funciona en archivos UTF-16.
|
||||
|
||||
Marca de orden de bytes
|
||||
On Windows Unicode text files typically have a Byte Order Mark (BOM),
|
||||
because many Windows programs (including Notepad) add BOMs by default.
|
||||
See also <https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
En Unix los archivos Unicode no suelen tener BOM. Se supone que los
|
||||
archivos de texto son codificados en la codificación local de
|
||||
caracteres.
|
||||
|
||||
dos2unix can only detect if a file is in UTF-16 format if the file has a
|
||||
BOM. When an UTF-16 file doesn't have a BOM, dos2unix will see the file
|
||||
as a binary file.
|
||||
|
||||
Use la opción "-ul" o "-ub" para convertir un archivo UTF-16 sin BOM.
|
||||
|
||||
dos2unix writes by default no BOM in the output file. With option "-b"
|
||||
dos2unix writes a BOM when the input file has a BOM.
|
||||
|
||||
unix2dos writes by default a BOM in the output file when the input file
|
||||
has a BOM. Use option "-r" to remove the BOM.
|
||||
|
||||
dos2unix and unix2dos write always a BOM when option "-m" is used.
|
||||
|
||||
Unicode file names on Windows
|
||||
dos2unix has optional support for reading and writing Unicode file names
|
||||
in the Windows Command Prompt. That means that dos2unix can open files
|
||||
that have characters in the name that are not part of the default system
|
||||
ANSI code page. To see if dos2unix for Windows was built with Unicode
|
||||
file name support type "dos2unix -V".
|
||||
|
||||
There are some issues with displaying Unicode file names in a Windows
|
||||
console. See option "-D", "--display-enc". The file names may be
|
||||
displayed wrongly in the console, but the files will be written with the
|
||||
correct name.
|
||||
|
||||
Ejemplos Unicode
|
||||
Convertir de Windows UTF-16 (con una BOM) a Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt out.txt
|
||||
|
||||
Convertir de Windows UTF-16LE (sin una BOM) a Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n in.txt out.txt
|
||||
|
||||
Convertir de Unix UTF-8 a Windows UTF-8 sin una BOM:
|
||||
|
||||
unix2dos -m -n in.txt out.txt
|
||||
|
||||
Convertir de Unix UTF-8 a Windows UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
|
||||
|
||||
GB18030
|
||||
GB18030 is a Chinese government standard. A mandatory subset of the
|
||||
GB18030 standard is officially required for all software products sold
|
||||
in China. See also <https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 es totalmente compatible con Unicode y puede considerarse como
|
||||
formato de transformación Unicode. Como ocurre con UTF-8, GB18030 es
|
||||
compatible con ASCII. GB18030 también es compatible con la página de
|
||||
códigos de Windows 936, también conocida como GBK.
|
||||
|
||||
En Unix/Linux los archivos UTF-16 se convierten a GB18030 cuando la
|
||||
codificación local se establece en GB18030. Tenga en cuenta que esto
|
||||
sólo funcionará si la configuración local es soportada por el sistema.
|
||||
Utilice "locale -a" para obtener el listado de configuraciones
|
||||
regionales admitidas.
|
||||
|
||||
Use la opción "-ul" o "-ub" para convertir un archivo UTF-16 sin BOM.
|
||||
|
||||
Los archivos codificados como GB18030 pueden tener una Marca de Orden de
|
||||
Bytes, como ocurre con los archivos Unicode.
|
||||
|
||||
EJEMPLOS
|
||||
Lee la entrada desde 'stdin' y escribe la salida a 'stdout':
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Convierte y reemplaza a.txt. Convierte y reemplaza b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Convierte y reemplaza a.txt empleando modo de conversión ascii:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Convierte y reemplaza a.txt empleando modo de conversión ascii,
|
||||
convierte y reemplaza b.txt empleando modo de conversión de 7bits:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Convierte a.txt del formato de Mac a Unix:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Convierte a.txt del formato de Unix a Mac:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Convierte y reemplaza a.txt manteniendo la fecha del archivo original:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Convierte a.txt y escribe la salida en e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Convierte a.txt y escribe la salida en e.txt, manteniendo la fecha de
|
||||
e.txt igual a la de a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Convierte y reemplaza a.txt, convierte b.txt y escribe en e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Convierte c.txt y escribe en e.txt, convierte y reemplaza a.txt,
|
||||
convierte y reemplaza b.txt, convierte d.txt y escribe en f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
CONVERSIÓN RECURSIVA
|
||||
In a Unix shell the find(1) and xargs(1) commands can be used to run
|
||||
dos2unix recursively over all text files in a directory tree. For
|
||||
instance to convert all .txt files in the directory tree under the
|
||||
current directory type:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
The find(1) option "-print0" and corresponding xargs(1) option -0 are
|
||||
needed when there are files with spaces or quotes in the name. Otherwise
|
||||
these options can be omitted. Another option is to use find(1) with the
|
||||
"-exec" option:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
In a Windows Command Prompt the following command can be used:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
PowerShell users can use the following command in Windows PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
INTERNACIONALIZACIÓN
|
||||
LANG
|
||||
El idioma principal se selecciona con la variable de entorno LANG.
|
||||
La variable LANG consiste de varias partes. La primer parte es el
|
||||
código del idioma en minúsculas. La segunda es opcional y es el
|
||||
código del país en mayúsculas, precedido por un guión bajo. Existe
|
||||
también una tercera parte opcional: la codificación de caracteres,
|
||||
precedida por un punto. Unos cuantos ejemplos para intérpretes de
|
||||
comandos tipo POSIX estándar:
|
||||
|
||||
export LANG=nl Neerlandés
|
||||
export LANG=nl_NL Neerlandés, Países Bajos
|
||||
export LANG=nl_BE Neerlandés, Bélgica
|
||||
export LANG=es_ES Español, España
|
||||
export LANG=es_MX Español, México
|
||||
export LANG=en_US.iso88591 Ingles, EE. UU., codificación Latín-1
|
||||
export LANG=en_GB.UTF-8 Ingles, Reino Unido, codificación UTF-8
|
||||
|
||||
For a complete list of language and country codes see the gettext
|
||||
manual:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
En sistemas Unix puede emplear el comando locale(1) para obtener
|
||||
información específica de locale.
|
||||
|
||||
LANGUAGE
|
||||
With the LANGUAGE environment variable you can specify a priority
|
||||
list of languages, separated by colons. dos2unix gives preference to
|
||||
LANGUAGE over LANG. For instance, first Dutch and then German:
|
||||
"LANGUAGE=nl:de". You have to first enable localization, by setting
|
||||
LANG (or LC_ALL) to a value other than "C", before you can use a
|
||||
language priority list through the LANGUAGE variable. See also the
|
||||
gettext manual:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Si selecciona un idioma que no está disponible el programa
|
||||
funcionará en ingles.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Con la variable de entorno DOS2UNIX_LOCALEDIR el LOCALEDIR asignado
|
||||
durante la compilación puede ser modificado. LOCALEDIR es usado para
|
||||
encontrar los archivos de idioma. El valor por defecto de GNU es
|
||||
"/usr/local/share/locale". El parámetro --version mostrará el
|
||||
LOCALEDIR en uso.
|
||||
|
||||
Ejemplo (intérprete de comandos POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
VALOR DE RETORNO
|
||||
Se regresa cero cuando el programa termina exitosamente. Cuando ocurre
|
||||
un error del sistema se regresará el último número de error del sistema.
|
||||
Para otros errores se regresa 1.
|
||||
|
||||
El valor de retorno es siempre cero en modo silencioso, excepto cuando
|
||||
se emplean parámetros incorrectos.
|
||||
|
||||
ESTÁNDARES
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTORES
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix
|
||||
mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) -
|
||||
<wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl>
|
||||
(maintainer)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge page: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
VÉASE TAMBIÉN
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
839
Agent-Windows/OGP64/usr/share/doc/dos2unix/fr/dos2unix.htm
Normal file
839
Agent-Windows/OGP64/usr/share/doc/dos2unix/fr/dos2unix.htm
Normal file
|
|
@ -0,0 +1,839 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - Convertit les fichiers textes du format DOS/Mac vers Unix et inversement</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NOM">NOM</a></li>
|
||||
<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
|
||||
<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
|
||||
<li><a href="#OPTIONS">OPTIONS</a></li>
|
||||
<li><a href="#MODE-MAC">MODE MAC</a></li>
|
||||
<li><a href="#MODES-DE-CONVERSION">MODES DE CONVERSION</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Codages">Codages</a></li>
|
||||
<li><a href="#Conversion">Conversion</a></li>
|
||||
<li><a href="#Marque-dordre-des-octets">Marque d'ordre des octets</a></li>
|
||||
<li><a href="#Noms-de-fichiers-unicode-sous-Windows">Noms de fichiers unicode sous Windows</a></li>
|
||||
<li><a href="#Exemples-Unicode">Exemples Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EXEMPLES">EXEMPLES</a></li>
|
||||
<li><a href="#CONVERSIONS-R-CURSIVES">CONVERSIONS RÉCURSIVES</a></li>
|
||||
<li><a href="#PARAM-TRES-LINGUISTIQUES">PARAMÈTRES LINGUISTIQUES</a></li>
|
||||
<li><a href="#VALEUR-DE-RETOUR">VALEUR DE RETOUR</a></li>
|
||||
<li><a href="#STANDARDS">STANDARDS</a></li>
|
||||
<li><a href="#AUTEURS">AUTEURS</a></li>
|
||||
<li><a href="#VOIR-AUSSI">VOIR AUSSI</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NOM">NOM</h1>
|
||||
|
||||
<p>dos2unix - Convertit les fichiers textes du format DOS/Mac vers Unix et inversement</p>
|
||||
|
||||
<h1 id="SYNOPSIS">SYNOPSIS</h1>
|
||||
|
||||
<pre><code>dos2unix [options] [FICHIER …] [-n FICHIER_ENTRÉE FICHIER_SORTIE …]
|
||||
unix2dos [options] [FICHIER …] [-n FICHIER_ENTRÉE FICHIER_SORTIE …]</code></pre>
|
||||
|
||||
<h1 id="DESCRIPTION">DESCRIPTION</h1>
|
||||
|
||||
<p>Le package dos2unix inclut les utilitaires <code>dos2unix</code> et <code>unix2dos</code> pour convertir des fichiers textes au format DOS ou Mac vers le format Unix et inversement.</p>
|
||||
|
||||
<p>Dans les fichiers textes DOS/Windows, un saut de ligne est une combinaison de deux caractères: un retour de chariot (CR) suivi d'un saut de ligne (LF). Dans les fichiers textes Unix, le saut de ligne est un seul caractère: le saut de ligne (LF). Les fichiers textes Mac, avant Mac OS X, utilisaient le retour chariot (CR) comme seul caractère. De nos jours, Mac OS utilise le même style de saut de ligne que Unix (LF).</p>
|
||||
|
||||
<p>Outre les sauts de lignes, dos2unix convertit aussi le codage des fichiers. Quelques codes page DOS peuvent être convertis en Latin-1 sous Unix. L'Unicode des fichiers Windows (UTF-16) peut être converti en Unicode Unix (UTF-8).</p>
|
||||
|
||||
<p>Les fichiers binaires sont automatiquement ignorés à moins que la conversion soit forcée.</p>
|
||||
|
||||
<p>Les fichiers non réguliers tels que les répertoires et les FIFOs sont automatiquement ignorés.</p>
|
||||
|
||||
<p>Les liens symboliques et leur cible sont, par défaut, inchangés. En option, les liens symboliques peuvent être remplacés ou, au choix, la sortie peut être écrite dans la cible du lien symbolique. Écrire dans la cible d'un lien symbolique n'est pas supporté sous Windows.</p>
|
||||
|
||||
<p>dos2unix a été conçu comme dos2unix sous SunOS/Solaris. Il y a une différence importante avec la version originale de SunOS/Solaris. Cette version effectue les conversions en place (ancien mode de fichier) tandis que la version originale de SunOS/Solaris ne supporte que la conversion par paire (nouveau mode de fichier). Voyez aussi les options <code>-o</code> et <code>-n</code>. Une autre différence est que SunOS/Solaris utilise par défaut le mode de conversion <i>iso</i> tandis que cette version utilise par défaut le mode de conversion <i>ascii</i>.</p>
|
||||
|
||||
<h1 id="OPTIONS">OPTIONS</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Traites toutes les options à sa suite comme étant des noms de fichiers. Utilisez cette option si vous voulez convertir des fichiers dont le nom commence par un tiret. Par exemple, pour convertir un fichier nommé « -foo », vous pouvez utiliser cette commande:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Ou dans le style des nouveaux fichiers:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo sortie.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Autoriser le changement de propriétaire dans l'ancien mode de fichier.</p>
|
||||
|
||||
<p>Quand cette option est utilisée, la conversion n'est pas interrompue si l'utilisateur ou le groupe propriétaire du fichier original ne peut pas être préservé dans l'ancien mode de fichier. La conversion continuera et le fichier converti aura le même nouveau propriétaire que si il avait été converti par le nouveau mode de fichier. Voyez aussi les options <code>-o</code> et <code>-n</code>. Cette option est uniquement disponible si dos2unix dispose des fonctionnalités pour préserver l'utilisateur ou le groupe propriétaire des fichiers.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mode de conversion par défaut. Voyez aussi la section des MODES DE CONVERSION.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convertit le jeu de caractères du DOS vers ISO-8859-1. Voyez aussi la section des MODES DE CONVERSION.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 1252 de Windows (Europe de l'ouest).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 437 du DOS (US). C'est le code page par défaut pour les conversions ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 850 du DOS (Europe de l'ouest).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 860 du DOS (portugais).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 863 du DOS (français canadien).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilise le code page 865 du DOS (nordique).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convertit les caractères 8 bits vers l'espace 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conserve la marque d'ordre des octets (BOM). Si le fichier d'entrée a une BOM, elle est écrite dans le fichier de sortie. C'est le comportement par défaut quand les sauts de lignes sont convertis au format DOS. Consultez aussi l'option <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-MODE_CONV"><b>-c, --convmode MODE_CONV</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Change le mode de conversion. MODE_CONV prend l'une des valeurs: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i>. Ascii est la valeur par défaut.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-ENCODAGE"><b>-D, --display-enc ENCODAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Choisi l'encodage des textes affichés. L'ENCODAGE peut être : <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i>. La valeur par défaut est ansi.</p>
|
||||
|
||||
<p>Cette option est uniquement disponible dans dos2unix pour Windows avec support pour les noms de fichiers Unicode. Cette option n'a aucun effet sur les noms de fichiers lus et écrits. Son effet se limite à leur affichage.</p>
|
||||
|
||||
<p>Il existe plusieurs méthodes pour afficher du texte dans une console Windows selon l'encodage du texte. Elles ont toutes leurs propres avantages et désavantages.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>La méthode par défaut de dos2unix est d'utiliser du texte encodé en ANSI. Elle a l'avantage d'être rétro compatible. Elle fonctionne avec des polices raster ou TrueType. Dans certaines régions, vous pouvez avoir besoin d'utiliser la commande <code>chcp</code> pour remplacer le code page DOS OEM actif par le code ANSI système de Windows car dos2unix utilise le code page système de Windows.</p>
|
||||
|
||||
<p>Le désavantage de ansi est que les noms de fichiers internationaux avec des caractères en dehors du code page système par défaut ne sont pas affichés correctement. Vous verrez un point d'interrogation ou un mauvais symbole à leur place. Cette méthode est acceptable si vous ne travaillez pas avec des noms de fichiers étrangers.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>L'avantage de l'encodage unicode (le nom de Windows pour UTF-16) est que le texte est habituellement affiché correctement. Il n'est pas nécessaire de changer le code page actif. Vous pouvez avoir besoin de remplacer la police de la console par une police TrueType pour afficher les caractères internationaux correctement. Lorsqu'un caractère n'est pas inclus dans la police TrueType, il sera généralement remplacé par un petit carré, parfois avec un point d'interrogation à l'intérieur.</p>
|
||||
|
||||
<p>Lorsque vous utilisez la console ConEmu, les textes sont affichés correctement car ConEmu sélectionne automatiquement une bonne police.</p>
|
||||
|
||||
<p>Le désavantage de unicode est qu'il n'est pas compatible avec ASCII. La sortie n'est pas facile à gérer quand vous la redirigez vers un autre programme.</p>
|
||||
|
||||
<p>Quand la méthode <code>unicodebom</code> est utilisée, le texte Unicode est précédé d'une BOM (Byte Order Mark=marque d'ordre des octets). Une BOM est nécessaire pour la redirection correcte ou le pipelining dans PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>L'avantage de utf8 est qu'il est compatible avec ASCII. Vous devez utiliser une police TrueType dans la console. Avec une police TrueType, le texte est affiché comme avec un encodage <code>unicode</code>.</p>
|
||||
|
||||
<p>Le désavantage est que, si vous utilisez la police raster par défaut, tous les caractères non ASCII sont mal affichés. Pas uniquement les noms de fichiers unicode ! Les messages traduits deviennent inintelligibles. Sous Windows configuré pour une région de l'est de l'Asie, vous pouvez observer énormément de scintillements dans la console quand des messages sont affichés.</p>
|
||||
|
||||
<p>Dans une console ConEmu, l'encodage utf8 fonctionne bien.</p>
|
||||
|
||||
<p>Quand la méthode <code>utf8bom</code> est utilisée, le texte UTF-8 est précédé d'une BOM (Byte Order Mark=marque d'ordre des octets). Une BOM est nécessaire pour la redirection correcte ou le pipelining dans PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>L'encodage par défaut peut être changé en assignant la valeur <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> ou <code>utf8bom</code> à la variable d'environnement DOS2UNIX_DISPLAY_ENC.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ajoute un saut de ligne à la dernière ligne si elle n'en a pas déjà un. Cela fonctionne avec toutes les conversions.</p>
|
||||
|
||||
<p>Un fichier converti de DOS vers le format Unix peut ne pas avoir de saut de ligne à la dernière ligne. Il existe des éditeurs de texte qui écrivent le fichier texte sans saut de ligne à la dernière ligne. Certains programmes Unix ont des difficultés à traiter ces fichiers car le standard POSIX défini que chaque ligne d'un fichier texte doit être terminé par le caractère de nouvelle ligne. Par exemple, concaténer des fichiers peut ne pas donner le résultat attendu.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Retourner une erreur si un fichier binaire est ignoré.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Force la conversion de fichiers binaires.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Sous Windows, les fichiers UTF-16 sont convertis en UTF-8 par défaut sans considération pour les paramètres de la localisation. Utilisez cette option pour convertir UTF-16 en GB18030. Cette option n'est disponible que sous Windows. Consultez aussi la section GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche l'aide et s'arrête.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-FANIONS---info-FANIONS-FICHIER"><b>-i[FANIONS], --info[=FANIONS] FICHIER …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche les informations du fichier. Aucune conversion n'est réalisée.</p>
|
||||
|
||||
<p>Les informations suivantes sont affichées dans cet ordre: le nombre de sauts de ligne DOS, le nombre de sauts de ligne Unix, le nombre de sauts de ligne Mac, la marque d'ordre des octets, texte ou binaire, nom du fichier.</p>
|
||||
|
||||
<p>Exemple de sortie :</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Notez qu'un fichier binaire peut parfois être considéré à tord comme un fichier texte. Voyez aussi l'option <code>-s</code>.</p>
|
||||
|
||||
<p>Si l'option <code>-e</code> ou <code>--add-eol</code> est également utilisée, le type du saut de ligne de la dernière ligne est affiché ou <code>noeol</code> est affiché s'il n'y en a pas.</p>
|
||||
|
||||
<p>Exemple de sortie :</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Des fanions facultatifs peuvent être ajoutés pour changer la sortie. Un ou plusieurs fanions peuvent être ajoutés.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afficher les lignes d'information du fichier suivies d'un caractère nul au lieu d'un saut de ligne. Cela permet d'interpréter correctement les noms de fichiers avec des espaces ou des guillemets quand le fanion c est utilisé. Utilisez ce fanion avec les options <code>-0</code> ou <code>--null</code> de xargs(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche le nombre de sauts de ligne DOS.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche le nombre de sauts de ligne Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche le nombre de sauts de ligne Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afficher la marque d'ordre des octets.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche si le fichier est texte ou binaire.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche le type du saut de ligne de la dernière ligne ou <code>noeol</code> s'il n'y en a pas.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche uniquement les fichiers qui seraient convertis.</p>
|
||||
|
||||
<p>Avec le fanion <code>c</code>, dos2unix n'affichera que les fichiers contenant des sauts de ligne DOS alors que unix2dos n'affichera que les noms des fichiers aillant des sauts de ligne Unix.</p>
|
||||
|
||||
<p>Si l'option <code>-e</code> ou <code>--add-eol</code> est également utilisée, les fichiers qui n'ont pas de saut de ligne à la dernière ligne seront affichés.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afficher un en-tête.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Montrer les noms des fichiers sans le chemin.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Exemples:</p>
|
||||
|
||||
<p>Afficher les informations pour tous les fichier *.txt :</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Afficher uniquement le nombre de sauts de ligne DOS et Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Montrer uniquement la marque d'ordre des octets :</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Liste les fichiers qui ont des sauts de ligne DOS :</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Liste les fichiers qui ont des sauts de ligne Unix :</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Liste les fichiers qui ont des sauts de ligne DOS ou qui n'ont pas de saut de ligne à la dernière ligne.</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Ne converti que les fichiers qui ont des sauts de lignes DOS et laisse les autres fichiers inchangés:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Trouve les fichiers texte qui ont des sauts de ligne DOS :</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>La date du fichier de sortie est la même que celle du fichier d'entrée.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche la licence du programme.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ajoute des sauts de lignes additionnels.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Seuls les sauts de lignes du DOS sont changés en deux sauts de lignes de Unix. En mode Mac, seuls les sauts de lignes Mac sont changés en deux sauts de lignes Unix.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Seuls les sauts de lignes Unix sont changés en deux sauts de lignes du DOS. En mode Mac, les sauts de lignes Unix sont remplacés par deux sauts de lignes Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Écrit une marque d'ordre des octets (BOM) dans le fichier de sortie. Par défaut une BOM UTF-8 est écrite.</p>
|
||||
|
||||
<p>Lorsque le fichier d'entrée est en UTF-16 et que l'option <code>-u</code> est utilisée, une BOM UTF-16 est écrite.</p>
|
||||
|
||||
<p>N'utilisez jamais cette option quand l'encodage du fichier de sortie n'est ni UTF-8 ni UTF-16 ni GB18030. Consultez également la section UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-FICHIER_ENTR-E-FICHIER_SORTIE"><b>-n, --newfile FICHIER_ENTRÉE FICHIER_SORTIE …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nouveau mode de fichiers. Convertit le fichier FICHER_ENTRÉE et écrit la sortie dans le fichier FICHIER_SORTIE. Les noms des fichiers doivent être indiqués par paires. Les caractères de remplacement <i>ne</i> doivent <i>pas</i> être utilisés ou vous <i>perdrez</i> vos fichiers.</p>
|
||||
|
||||
<p>La personne qui démarre la conversion dans le nouveau mode (pairé) des fichiers sera le propriétaire du fichier converti. Les permissions de lecture/écriture du nouveau fichier seront les permissions du fichier original moins le umask(1) de la personne qui exécute la conversion.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ne pas autoriser le changement du propriétaire du fichier dans l'ancien mode de fichier (par défaut).</p>
|
||||
|
||||
<p>Interrompt la conversion si l'utilisateur ou le groupe propriétaire du fichier original ne peuvent pas être préservés dans l'ancien mode de fichier. Voyez aussi les options <code>-o</code> et <code>-n</code>. Cette option est uniquement présente si dos2unix dispose des fonctionnalités pour préserver l'utilisateur ou le groupe propriétaire des fichiers.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>N'ajoute pas de saut de ligne à la dernière ligne s'il n'y en a pas (par défaut).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ne pas retourner une erreur si un fichier binaire est ignoré (par défaut).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Écrit vers la sortie standard, comme un filtre Unix. Utilisez l'option <code>-o</code> pour revenir au mode de l'ancien fichier (en place).</p>
|
||||
|
||||
<p>Combiné avec l'option <code>-e</code>, les fichiers peuvent être concaténés correctement. Les première et dernière lignes ne sont pas fusionnées et il n'y a pas de marque d'ordre des octets au milieu du fichier concaténé. Exemple :</p>
|
||||
|
||||
<pre><code>dos2unix -e -O fichier1.txt fichier2.txt > sortie.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-FICHIER"><b>-o, --oldfile FICHIER …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ancien mode de fichiers. Convertit le fichier FICHIER et écrit la sortie dedans. Le programme fonctionne dans ce mode par défaut. Les noms avec des caractères de remplacement peuvent être utilisés.</p>
|
||||
|
||||
<p>Dans l'ancien mode (en place) des fichiers, les fichiers convertis ont le même propriétaire, groupe et permissions lecture/écriture que le fichier original. Idem quand le fichier est converti par un utilisateur qui a la permission d'écrire dans le fichier (par exemple, root). La conversion est interrompue si il n'est pas possible de conserver les valeurs d'origine. Le changement de propriétaire pourrait signifier que le propriétaire original n'est plus en mesure de lire le fichier. Le changement de groupe pourrait être un risque pour la sécurité. Le fichier pourrait être rendu accessible en lecture par des personnes à qui il n'est pas destiné. La conservation du propriétaire, du groupe et des permissions de lecture/écriture n'est supportée que sous Unix.</p>
|
||||
|
||||
<p>Pour vérifier si dos2unix dispose des fonctions pour préserver l'utilisateur et le groupe propriétaire du fichier, tapez <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>La conversion est toujours réalisée via un fichier temporaire. Quand une erreur survient au milieu de la conversion, le fichier temporaire est effacé et le fichier original reste inchangé. Quand la conversion réussi, le fichier original est remplacé par le fichier temporaire. Vous pourriez avoir la permission d'écrire dans le fichier original mais ne pas avoir la permission de remplacer les propriétés de l'utilisateur et du groupe propriétaires sur le fichier temporaire telles qu'elles sont définies sur le fichier original. Cela signifie que vous n'êtes pas en mesure de préserver l'utilisateur ou le groupe propriétaire du fichier original. Dans ce cas, vous pouvez utiliser l'option <code>--allow-chown</code> pour continuer la conversion.</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown toto.txt</code></pre>
|
||||
|
||||
<p>Une autre option consiste à utiliser le nouveau mode de fichier:</p>
|
||||
|
||||
<pre><code>dos2unix -n toto.txt toto.txt</code></pre>
|
||||
|
||||
<p>L'avantage de l'option <code>--allow-chown</code> est que vous pouvez utiliser des caractères de remplacement et les propriétaires seront préservés dans la mesure du possible.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mode silencieux. Supprime les avertissements et les messages. La valeur de sortie est zéro sauf quand de mauvaises options sont utilisées sur la ligne de commande.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Supprime la marque d'ordre des octets (BOM). N'écrit pas la BOM dans le fichier de sortie. Ceci est le comportement par défaut lorsque les sauts de lignes sont convertis au format Unix. Consultez aussi l'option <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ignore les fichiers binaires (par défaut).</p>
|
||||
|
||||
<p>Ignorer les fichiers binaires sert à éviter les erreurs accidentelles. Attention que la détection de fichiers binaires n'est pas fiable à 100%. Les fichiers en entrée sont analysés pour y trouver des symboles binaires qui ne sont habituellement pas rencontrés dans des fichiers textes. Il est cependant possible qu'un fichier binaire ne contienne que des caractères textes normaux. Un tel fichier serait erronément traité comme un fichier texte.</p>
|
||||
|
||||
<p>Par défaut, aucune erreur n'est retournée quand un fichier binaire est ignoré. Si l'option <code>--error-binary</code> est utilisée, une erreur est retournée.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Suppose que le fichier d'entrée est au format UTF-16LE.</p>
|
||||
|
||||
<p>Quand il y a un indicateur d'ordre des octets dans le fichier d'entrée, l'indicateur a priorité sur cette option.</p>
|
||||
|
||||
<p>Si vous vous êtes trompé sur le format du fichier d'entrée (par exemple, ce n'était pas un fichier UTF16-LE) et que la conversion réussi, vous obtiendrez un fichier UTF-8 contenant le mauvais texte. Vous pouvez récupérer le fichier original avec iconv(1) en convertissant le fichier de sortie UTF-8 vers du UTF-16LE.</p>
|
||||
|
||||
<p>La présupposition de l'UTF-16LE fonctionne comme un <i>mode de conversion</i>. En utilisant le mode <i>ascii</i> par défaut, UTF-16LE n'est plus présupposé.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Suppose que le fichier d'entrée est au format UTF-16BE.</p>
|
||||
|
||||
<p>Cette option fonctionne comme l'option <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche des messages verbeux. Des informations supplémentaires sont affichées à propos des marques d'ordre des octets et du nombre de sauts de lignes convertis.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Suit les liens symboliques et convertit les cibles.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Remplace les liens symboliques par les fichiers convertis (les fichiers cibles originaux restent inchangés).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ne change pas les liens symboliques ni les cibles (par défaut).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Affiche les informations de version puis arrête.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MODE-MAC">MODE MAC</h1>
|
||||
|
||||
<p>Par défaut, les sauts de lignes sont convertis du DOS vers Unix et inversement. Les sauts de lignes Mac ne sont pas convertis.</p>
|
||||
|
||||
<p>En mode Mac, les sauts de lignes sont convertis du format Mac au format Unix et inversement. Les sauts de lignes DOS ne sont pas changés.</p>
|
||||
|
||||
<p>Pour fonctionner en mode Mac, utilisez l'option en ligne de commande <code>-c mac</code> ou utilisez les commandes <code>mac2unix</code> ou <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="MODES-DE-CONVERSION">MODES DE CONVERSION</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ceci est le mode de conversion par défaut. Ce mode convertit les fichiers ASCII en fichiers compatibles avec l'ASCII tel que UTF-9. Activer le mode <b>ascii</b> désactive les modes <b>7bit</b> et <b>iso</b>.</p>
|
||||
|
||||
<p>Si dos2unix supporte UTF-16, les fichiers encodés en UTF-16 sont convertis vers l'encodage des caractères des paramètres linguistiques courants sur les systèmes POSIX et vers UTF-8 sous Windows. Activer le mode <b>ascii</b> désactive l'option pour garder l'encodage UTF-8 (<code>-u</code>) et les options qui supposent une entrée en UTF-16 (<code>-ul</code> et <code>-ub</code>). Pour voir si dos2unix supporte UTF-16, tapez <code>dos2unix -V</code>. Consultez aussi la section UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Dans ce mode, tous les caractères 8 bits non ASCII (avec des valeurs entre 128 et 255) sont remplacés par une espace 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Les caractères sont convertis entre un jeu de caractères DOS (code page) et le jeu de caractères ISO-8859-1 (Latin-1) de Unix. Les caractères DOS sans équivalent ISO-8859-1, pour lesquels la conversion n'est pas possible, sont remplacés par un point. La même chose est valable pour les caractères ISO-8859-1 sans équivalent DOS.</p>
|
||||
|
||||
<p>Quand seule l'option <code>-iso</code> est utilisée, dos2unix essaie de déterminer le code page actif. Quand ce n'est pas possible, dos2unix utilise le code page CP437 par défaut qui est surtout utilisé aux USA. Pour forcer l'utilisation d'un code page spécifique, utilisez les options <code>-437</code> (US), <code>-850</code> (Europe de l'ouest), <code>-860</code> (portugais), <code>-863</code> (français canadien) ou <code>-865</code> (nordique). Le code page CP1252 de Windows (Europe de l'ouest) est également supporté avec l'option <code>-1252</code>. Pour d'autres codes pages, utilisez dos2unix avec iconv(1). Iconv supporte une longue liste de codages de caractères.</p>
|
||||
|
||||
<p>N'utilisez jamais la conversion ISO sur des fichiers textes Unicode. Cela va corrompre les fichiers encodés en UTF-8.</p>
|
||||
|
||||
<p>Quelques exemples:</p>
|
||||
|
||||
<p>Convertir du code page par défaut du DOS au Latin-1 Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir du CP850 du DOS au Latin-1 Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir du CP1252 de Windows au Latin-1 de Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir le CP1252 de Windows en UTF-8 de Unix (Unicode) :</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 entrée.txt | dos2unix > sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir du Latin-1 de Unix au code page par défaut de DOS :</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir le Latin-1 de Unix en CP850 du DOS :</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir le Latin-1 de Unix en CP1252 de Windows :</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir le UTF-8 de Unix (Unicode) en CP1252 de Windows :</p>
|
||||
|
||||
<pre><code>unix2dos < entrée.txt | iconv -f UTF-8 -t CP1252 > sortie.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Codages">Codages</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Conversion">Conversion</h2>
|
||||
|
||||
<p>Les fichiers textes Unicode peuvent avoir des sauts de lignes DOS, Unix ou Mac, tout comme les fichiers textes ASCII.</p>
|
||||
|
||||
<p>Toutes les versions de dos2unix et unix2dos peuvent convertir des fichiers codés en UTF-8 car UTF-8 a été conçu pour être rétro-compatible avec l'ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Sous Unix/Linux, les fichiers encodés en UTF-16 sont convertis vers l'encodage des caractères de la localisation. Utilisez locale(1) pour découvrir quel encodage de caractères est utilisé. Lorsque la conversion n'est pas possible, une erreur de conversion est produite et le fichier est abandonné.</p>
|
||||
|
||||
<p>Sous Windows, les fichiers UTF-16 sont convertis par défaut en UTF-8. Les fichiers textes formatés en UTF-8 sont bien supportés sous Windows et Unix/Linux.</p>
|
||||
|
||||
<p>Les codages UTF-16 et UTF-8 sont parfaitement compatibles. Il n'y a pas de pertes lors de la conversion. Lorsqu'une erreur de conversion UTF-16 vers UTF-8 survient, par exemple, quand le fichier d'entrée UTF-16 contient une erreur, le fichier est ignoré.</p>
|
||||
|
||||
<p>Quand l'option <code>-u</code> est utilisée, le fichier de sortie est écrit dans le même encodage UTF-16 que le fichier d'entrée. L'option <code>-u</code> empêche la conversion en UTF-8.</p>
|
||||
|
||||
<p>dos2unix et unix2dos n'ont pas d'option pour convertir des fichiers UTF-8 en UTF-16.</p>
|
||||
|
||||
<p>Les modes de conversion ISO et 7 bits ne fonctionnent pas sur des fichiers UTF-16.</p>
|
||||
|
||||
<h2 id="Marque-dordre-des-octets">Marque d'ordre des octets</h2>
|
||||
|
||||
<p>Les fichiers textes Unicode sous Windows on généralement un indicateur d'ordre des octets (BOM) car de nombreux programmes Windows (y compris Notepad) ajoutent cet indicateur par défaut. Consultez aussi <a href="https://fr.wikipedia.org/wiki/Indicateur_d%27ordre_des_octets">https://fr.wikipedia.org/wiki/Indicateur_d%27ordre_des_octets</a>.</p>
|
||||
|
||||
<p>Sous Unix, les fichiers Unicodes n'ont habituellement pas de BOM. Il est supposé que les fichiers textes sont codés selon le codage de l'environnement linguistique.</p>
|
||||
|
||||
<p>dos2unix ne peut détecter que le fichier est au format UTF-16 si le fichier n'a pas de BOM. Quand le fichier UTF-16 n'a pas cet indicateur, dos2unix voit le fichier comme un fichier binaire.</p>
|
||||
|
||||
<p>Utilisez l'option <code>-ul</code> ou <code>-ub</code> pour convertir un fichier UTF-16 sans BOM.</p>
|
||||
|
||||
<p>dos2unix, par défaut, n'écrit pas de BOM dans le fichier de sortie. Avec l'option <code>-b</code>, dos2unix écrit une BOM quand le fichier d'entrée a une BOM.</p>
|
||||
|
||||
<p>unix2dos écrit par défaut une BOM dans le fichier de sortie quand le fichier d'entrée a une BOM. Utilisez l'option <code>-r</code> pour supprimer la BOM.</p>
|
||||
|
||||
<p>dos2unix et unix2dos écrivent toujours une BOM quand l'option <code>-m</code> est utilisée.</p>
|
||||
|
||||
<h2 id="Noms-de-fichiers-unicode-sous-Windows">Noms de fichiers unicode sous Windows</h2>
|
||||
|
||||
<p>dos2unix supporte, en option, la lecture et l'écriture de noms de fichiers Unicode dans la ligne de commande de Windows. Cela signifie que dos2unix peut ouvrir des fichiers qui ont, dans leur nom, des caractères n'appartenant pas au code page système ANSI par défaut. Pour voir si dos2unix pour Windows a été compilé avec le support des noms de fichiers Unicode, tapez <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Il y a quelques soucis avec l'affichage de noms de fichiers Unicode dans une console Windows. Voyez l'option <code>-D</code>, <code>--display-enc</code>. Les noms de fichiers peuvent être mal affichés dans la console mais les fichiers seront écrits avec les bons noms.</p>
|
||||
|
||||
<h2 id="Exemples-Unicode">Exemples Unicode</h2>
|
||||
|
||||
<p>Convertir de l'UTF-16 Windows (avec BOM) vers l'UTF-8 de Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir de l'UTF-16LE de Windows (sans BOM) vers l'UTF-8 de Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir de l'UTF-8 de Unix vers l'UTF-8 de Windows avec BOM :</p>
|
||||
|
||||
<pre><code>unix2dos -m -n entrée.txt sortie.txt</code></pre>
|
||||
|
||||
<p>Convertir de l'UTF-8 de Unix vers l'UTF-16 de Windows :</p>
|
||||
|
||||
<pre><code>unix2dos < entrée.txt | iconv -f UTF-8 -t UTF-16 > sortie.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 est un standard du gouvernement chinois. Tout logiciel vendu en Chine doit officiellement supporter un sous ensemble obligatoire du standard GB18030. Consultez <a href="https://fr.wikipedia.org/wiki/GB_18030">https://fr.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 est entièrement compatible avec Unicode et peut être considéré comme étant un format de transformation unicode. Comme UTF-8, GB18030 est compatible avec ASCII. GB18030 est aussi compatible avec le code page 936 de Windows aussi connu comme GBK.</p>
|
||||
|
||||
<p>Sous Unix/Linux, les fichiers UTF-16 sont convertis en GB18030 quand l'encodage de l'environnement linguistique est GB18030. Notez que cela ne fonctionnera que si l'environnement linguistique est supporté par le système. Utilisez la commande <code>locale -a</code> pour obtenir la liste des environnements linguistiques supportés.</p>
|
||||
|
||||
<p>Sous Windows, vous avez besoin de l'option <code>-gb</code> pour convertir UTF-16 en GB18030.</p>
|
||||
|
||||
<p>Les fichiers encodés en GB18030 peuvent avoir une marque d'ordre des octets, comme les fichiers Unicode.</p>
|
||||
|
||||
<h1 id="EXEMPLES">EXEMPLES</h1>
|
||||
|
||||
<p>Lire l'entrée depuis « stdin » et écrire la sortie vers « stdout » :</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Convertir et remplacer a.txt. Convertir et remplace b.txt :</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Convertir et remplacer a.txt en mode de conversion ascii :</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Convertir et remplacer a.txt en mode de conversion ascii. Convertir et remplacer b.txt en mode de conversion 7 bits :</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Convertir a.txt depuis le format Mac vers le format Unix :</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Convertir a.txt du format Unix au format Mac :</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Convertir et remplacer a.txt tout en conservant la date originale :</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Convertir a.txt et écrire dans e.txt :</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertir a.txt et écrire dans e.txt. La date de e.txt est la même que celle de a.txt :</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertir et remplacer a.txt. Convertir b.txt et écrire dans e.txt :</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertir c.txt et écrire dans e.txt. Convertir et remplacer a.txt. Convertir et remplacer b.txt. Convertir d.txt et écrire dans f.txt :</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="CONVERSIONS-R-CURSIVES">CONVERSIONS RÉCURSIVES</h1>
|
||||
|
||||
<p>Dans un shell Unix, les commandes find(1) et xargs(1) peuvent être utilisées pour exécuter dos2unix récursivement sur tous les fichiers textes dans une arborescence de répertoires. Par exemple, pour convertir tous les fichiers .txt dans les répertoires sous le répertoire courant, tapez:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>L'option <code>-print0</code> de find(1) et l'option correspondante <code>-0</code> de xargs(1) sont nécessaires quand il y a des fichiers avec des espaces ou des guillemets dans leur nom. Sinon, ces options peuvent être omises. Une autre possibilité est d'utiliser find(1) avec l'option <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>En ligne de commande sous Windows, la commande suivante peut être utilisée :</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"
|
||||
find /R %G in </code></pre>
|
||||
|
||||
<p>Les utilisateurs de PowerShell peuvent utiliser la commande suivante dans le PowerShell de Windows :</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="PARAM-TRES-LINGUISTIQUES">PARAMÈTRES LINGUISTIQUES</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>La langue principale est sélectionnée par la variable d'environnement LANG. La variable LANG est composée de plusieurs parties. La première partie est le code de la langue en minuscules. La deuxième partie est le code du pays en majuscules précédé d'un souligné. Elle est facultative. Il y a aussi une troisième partie facultative qui est le codage des caractères précédé par un point. Voici quelques exemples pour un shell au standard POSIX:</p>
|
||||
|
||||
<pre><code>export LANG=fr Français
|
||||
export LANG=fr_CA Français, Canada
|
||||
export LANG=fr_BE Français, Belgique
|
||||
export LANG=es_ES Espagnol, Espagne
|
||||
export LANG=es_MX Espagnol, Mexique
|
||||
export LANG=en_US.iso88591 Anglais, USA, codage Latin-1
|
||||
export LANG=en_GB.UTF-8 Anglais, UK, codage UTF-8</code></pre>
|
||||
|
||||
<p>La liste complète des codes de langues et de pays est dans le manuel de gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>Sur les systèmes Unix, vous pouvez utiliser la commande locale(1) pour obtenir des informations sur l'environnement linguistique.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUE"><b>LANGUE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Avec la variable d'environnement LANGUAGE, vous pouvez spécifier une liste de langues prioritaires séparées par des deux-points. dos2unix fait passer LANGUAGE avant LANG. Par exemple, pour utiliser le français avant l'anglais: <code>LANGUAGE=fr:en</code>. Vous devez d'abord activer l'environnement linguistique en assignant une valeur autre que « C » à LANG (ou LC_ALL). Ensuite, vous pourrez utiliser la liste de priorité avec la variable LANGUAGE. Voyez également le manuel de gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Si vous sélectionnez une langue qui n'est pas disponible, vous obtiendrez des messages en anglais standard.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Grâce à la variable d'environnement DOS2UNIX_LOCALEDIR, la variable LOCALEDIR compilée dans l'application peut être remplacée. LOCALEDIR est utilisée pour trouver les fichiers de langue. La valeur par défaut de GNU est <code>/usr/local/share/locale</code>. L'option <b>--version</b> affiche la valeur de LOCALEDIR utilisée.</p>
|
||||
|
||||
<p>Exemple (shell POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="VALEUR-DE-RETOUR">VALEUR DE RETOUR</h1>
|
||||
|
||||
<p>Zéro est retourné en cas de succès. Si une erreur système se produit, la dernière erreur système est retournée. Pour les autres erreurs, 1 est renvoyé.</p>
|
||||
|
||||
<p>La valeur de sortie est toujours zéro en mode silencieux sauf quand de mauvaises options sont utilisées sur la ligne de commande.</p>
|
||||
|
||||
<h1 id="STANDARDS">STANDARDS</h1>
|
||||
|
||||
<p><a href="https://fr.wikipedia.org/wiki/Fichier_texte">https://fr.wikipedia.org/wiki/Fichier_texte</a></p>
|
||||
|
||||
<p><a href="https://fr.wikipedia.org/wiki/Retour_chariot">https://fr.wikipedia.org/wiki/Retour_chariot</a></p>
|
||||
|
||||
<p><a href="https://fr.wikipedia.org/wiki/Fin_de_ligne">https://fr.wikipedia.org/wiki/Fin_de_ligne</a></p>
|
||||
|
||||
<p><a href="https://fr.wikipedia.org/wiki/Unicode">https://fr.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTEURS">AUTEURS</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mode mac2unix) - <wuebben@kde.org>, Christian Wurll (ajout de saut de ligne supplémentaire) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (Mainteneur)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Page SourceForge: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="VOIR-AUSSI">VOIR AUSSI</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
883
Agent-Windows/OGP64/usr/share/doc/dos2unix/fr/dos2unix.txt
Normal file
883
Agent-Windows/OGP64/usr/share/doc/dos2unix/fr/dos2unix.txt
Normal file
|
|
@ -0,0 +1,883 @@
|
|||
NOM
|
||||
dos2unix - Convertit les fichiers textes du format DOS/Mac vers Unix et
|
||||
inversement
|
||||
|
||||
SYNOPSIS
|
||||
dos2unix [options] [FICHIER …] [-n FICHIER_ENTRÉE FICHIER_SORTIE …]
|
||||
unix2dos [options] [FICHIER …] [-n FICHIER_ENTRÉE FICHIER_SORTIE …]
|
||||
|
||||
DESCRIPTION
|
||||
Le package dos2unix inclut les utilitaires "dos2unix" et "unix2dos" pour
|
||||
convertir des fichiers textes au format DOS ou Mac vers le format Unix
|
||||
et inversement.
|
||||
|
||||
Dans les fichiers textes DOS/Windows, un saut de ligne est une
|
||||
combinaison de deux caractères: un retour de chariot (CR) suivi d'un
|
||||
saut de ligne (LF). Dans les fichiers textes Unix, le saut de ligne est
|
||||
un seul caractère: le saut de ligne (LF). Les fichiers textes Mac, avant
|
||||
Mac OS X, utilisaient le retour chariot (CR) comme seul caractère. De
|
||||
nos jours, Mac OS utilise le même style de saut de ligne que Unix (LF).
|
||||
|
||||
Outre les sauts de lignes, dos2unix convertit aussi le codage des
|
||||
fichiers. Quelques codes page DOS peuvent être convertis en Latin-1 sous
|
||||
Unix. L'Unicode des fichiers Windows (UTF-16) peut être converti en
|
||||
Unicode Unix (UTF-8).
|
||||
|
||||
Les fichiers binaires sont automatiquement ignorés à moins que la
|
||||
conversion soit forcée.
|
||||
|
||||
Les fichiers non réguliers tels que les répertoires et les FIFOs sont
|
||||
automatiquement ignorés.
|
||||
|
||||
Les liens symboliques et leur cible sont, par défaut, inchangés. En
|
||||
option, les liens symboliques peuvent être remplacés ou, au choix, la
|
||||
sortie peut être écrite dans la cible du lien symbolique. Écrire dans la
|
||||
cible d'un lien symbolique n'est pas supporté sous Windows.
|
||||
|
||||
dos2unix a été conçu comme dos2unix sous SunOS/Solaris. Il y a une
|
||||
différence importante avec la version originale de SunOS/Solaris. Cette
|
||||
version effectue les conversions en place (ancien mode de fichier)
|
||||
tandis que la version originale de SunOS/Solaris ne supporte que la
|
||||
conversion par paire (nouveau mode de fichier). Voyez aussi les options
|
||||
"-o" et "-n". Une autre différence est que SunOS/Solaris utilise par
|
||||
défaut le mode de conversion *iso* tandis que cette version utilise par
|
||||
défaut le mode de conversion *ascii*.
|
||||
|
||||
OPTIONS
|
||||
-- Traites toutes les options à sa suite comme étant des noms de
|
||||
fichiers. Utilisez cette option si vous voulez convertir des
|
||||
fichiers dont le nom commence par un tiret. Par exemple, pour
|
||||
convertir un fichier nommé « -foo », vous pouvez utiliser cette
|
||||
commande:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Ou dans le style des nouveaux fichiers:
|
||||
|
||||
dos2unix -n -- -foo sortie.txt
|
||||
|
||||
--allow-chown
|
||||
Autoriser le changement de propriétaire dans l'ancien mode de
|
||||
fichier.
|
||||
|
||||
Quand cette option est utilisée, la conversion n'est pas interrompue
|
||||
si l'utilisateur ou le groupe propriétaire du fichier original ne
|
||||
peut pas être préservé dans l'ancien mode de fichier. La conversion
|
||||
continuera et le fichier converti aura le même nouveau propriétaire
|
||||
que si il avait été converti par le nouveau mode de fichier. Voyez
|
||||
aussi les options "-o" et "-n". Cette option est uniquement
|
||||
disponible si dos2unix dispose des fonctionnalités pour préserver
|
||||
l'utilisateur ou le groupe propriétaire des fichiers.
|
||||
|
||||
-ascii
|
||||
Mode de conversion par défaut. Voyez aussi la section des MODES DE
|
||||
CONVERSION.
|
||||
|
||||
-iso
|
||||
Convertit le jeu de caractères du DOS vers ISO-8859-1. Voyez aussi
|
||||
la section des MODES DE CONVERSION.
|
||||
|
||||
-1252
|
||||
Utilise le code page 1252 de Windows (Europe de l'ouest).
|
||||
|
||||
-437
|
||||
Utilise le code page 437 du DOS (US). C'est le code page par défaut
|
||||
pour les conversions ISO.
|
||||
|
||||
-850
|
||||
Utilise le code page 850 du DOS (Europe de l'ouest).
|
||||
|
||||
-860
|
||||
Utilise le code page 860 du DOS (portugais).
|
||||
|
||||
-863
|
||||
Utilise le code page 863 du DOS (français canadien).
|
||||
|
||||
-865
|
||||
Utilise le code page 865 du DOS (nordique).
|
||||
|
||||
-7 Convertit les caractères 8 bits vers l'espace 7 bits.
|
||||
|
||||
-b, --keep-bom
|
||||
Conserve la marque d'ordre des octets (BOM). Si le fichier d'entrée
|
||||
a une BOM, elle est écrite dans le fichier de sortie. C'est le
|
||||
comportement par défaut quand les sauts de lignes sont convertis au
|
||||
format DOS. Consultez aussi l'option "-r".
|
||||
|
||||
-c, --convmode MODE_CONV
|
||||
Change le mode de conversion. MODE_CONV prend l'une des valeurs:
|
||||
*ascii*, *7bit*, *iso*, *mac*. Ascii est la valeur par défaut.
|
||||
|
||||
-D, --display-enc ENCODAGE
|
||||
Choisi l'encodage des textes affichés. L'ENCODAGE peut être :
|
||||
*ansi*, *unicode*, *unicodebom*, *utf8*, *utf8bom*. La valeur par
|
||||
défaut est ansi.
|
||||
|
||||
Cette option est uniquement disponible dans dos2unix pour Windows
|
||||
avec support pour les noms de fichiers Unicode. Cette option n'a
|
||||
aucun effet sur les noms de fichiers lus et écrits. Son effet se
|
||||
limite à leur affichage.
|
||||
|
||||
Il existe plusieurs méthodes pour afficher du texte dans une console
|
||||
Windows selon l'encodage du texte. Elles ont toutes leurs propres
|
||||
avantages et désavantages.
|
||||
|
||||
ansi
|
||||
La méthode par défaut de dos2unix est d'utiliser du texte encodé
|
||||
en ANSI. Elle a l'avantage d'être rétro compatible. Elle
|
||||
fonctionne avec des polices raster ou TrueType. Dans certaines
|
||||
régions, vous pouvez avoir besoin d'utiliser la commande "chcp"
|
||||
pour remplacer le code page DOS OEM actif par le code ANSI
|
||||
système de Windows car dos2unix utilise le code page système de
|
||||
Windows.
|
||||
|
||||
Le désavantage de ansi est que les noms de fichiers
|
||||
internationaux avec des caractères en dehors du code page
|
||||
système par défaut ne sont pas affichés correctement. Vous
|
||||
verrez un point d'interrogation ou un mauvais symbole à leur
|
||||
place. Cette méthode est acceptable si vous ne travaillez pas
|
||||
avec des noms de fichiers étrangers.
|
||||
|
||||
unicode, unicodebom
|
||||
L'avantage de l'encodage unicode (le nom de Windows pour UTF-16)
|
||||
est que le texte est habituellement affiché correctement. Il
|
||||
n'est pas nécessaire de changer le code page actif. Vous pouvez
|
||||
avoir besoin de remplacer la police de la console par une police
|
||||
TrueType pour afficher les caractères internationaux
|
||||
correctement. Lorsqu'un caractère n'est pas inclus dans la
|
||||
police TrueType, il sera généralement remplacé par un petit
|
||||
carré, parfois avec un point d'interrogation à l'intérieur.
|
||||
|
||||
Lorsque vous utilisez la console ConEmu, les textes sont
|
||||
affichés correctement car ConEmu sélectionne automatiquement une
|
||||
bonne police.
|
||||
|
||||
Le désavantage de unicode est qu'il n'est pas compatible avec
|
||||
ASCII. La sortie n'est pas facile à gérer quand vous la
|
||||
redirigez vers un autre programme.
|
||||
|
||||
Quand la méthode "unicodebom" est utilisée, le texte Unicode est
|
||||
précédé d'une BOM (Byte Order Mark=marque d'ordre des octets).
|
||||
Une BOM est nécessaire pour la redirection correcte ou le
|
||||
pipelining dans PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
L'avantage de utf8 est qu'il est compatible avec ASCII. Vous
|
||||
devez utiliser une police TrueType dans la console. Avec une
|
||||
police TrueType, le texte est affiché comme avec un encodage
|
||||
"unicode".
|
||||
|
||||
Le désavantage est que, si vous utilisez la police raster par
|
||||
défaut, tous les caractères non ASCII sont mal affichés. Pas
|
||||
uniquement les noms de fichiers unicode ! Les messages traduits
|
||||
deviennent inintelligibles. Sous Windows configuré pour une
|
||||
région de l'est de l'Asie, vous pouvez observer énormément de
|
||||
scintillements dans la console quand des messages sont affichés.
|
||||
|
||||
Dans une console ConEmu, l'encodage utf8 fonctionne bien.
|
||||
|
||||
Quand la méthode "utf8bom" est utilisée, le texte UTF-8 est
|
||||
précédé d'une BOM (Byte Order Mark=marque d'ordre des octets).
|
||||
Une BOM est nécessaire pour la redirection correcte ou le
|
||||
pipelining dans PowerShell.
|
||||
|
||||
L'encodage par défaut peut être changé en assignant la valeur
|
||||
"unicode", "unicodebom", "utf8" ou "utf8bom" à la variable
|
||||
d'environnement DOS2UNIX_DISPLAY_ENC.
|
||||
|
||||
-e, --add-eol
|
||||
Ajoute un saut de ligne à la dernière ligne si elle n'en a pas déjà
|
||||
un. Cela fonctionne avec toutes les conversions.
|
||||
|
||||
Un fichier converti de DOS vers le format Unix peut ne pas avoir de
|
||||
saut de ligne à la dernière ligne. Il existe des éditeurs de texte
|
||||
qui écrivent le fichier texte sans saut de ligne à la dernière
|
||||
ligne. Certains programmes Unix ont des difficultés à traiter ces
|
||||
fichiers car le standard POSIX défini que chaque ligne d'un fichier
|
||||
texte doit être terminé par le caractère de nouvelle ligne. Par
|
||||
exemple, concaténer des fichiers peut ne pas donner le résultat
|
||||
attendu.
|
||||
|
||||
--error-binary
|
||||
Retourner une erreur si un fichier binaire est ignoré.
|
||||
|
||||
-f, --force
|
||||
Force la conversion de fichiers binaires.
|
||||
|
||||
-gb, --gb18030
|
||||
Sous Windows, les fichiers UTF-16 sont convertis en UTF-8 par défaut
|
||||
sans considération pour les paramètres de la localisation. Utilisez
|
||||
cette option pour convertir UTF-16 en GB18030. Cette option n'est
|
||||
disponible que sous Windows. Consultez aussi la section GB18030.
|
||||
|
||||
-h, --help
|
||||
Affiche l'aide et s'arrête.
|
||||
|
||||
-i[FANIONS], --info[=FANIONS] FICHIER …
|
||||
Affiche les informations du fichier. Aucune conversion n'est
|
||||
réalisée.
|
||||
|
||||
Les informations suivantes sont affichées dans cet ordre: le nombre
|
||||
de sauts de ligne DOS, le nombre de sauts de ligne Unix, le nombre
|
||||
de sauts de ligne Mac, la marque d'ordre des octets, texte ou
|
||||
binaire, nom du fichier.
|
||||
|
||||
Exemple de sortie :
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Notez qu'un fichier binaire peut parfois être considéré à tord comme
|
||||
un fichier texte. Voyez aussi l'option "-s".
|
||||
|
||||
Si l'option "-e" ou "--add-eol" est également utilisée, le type du
|
||||
saut de ligne de la dernière ligne est affiché ou "noeol" est
|
||||
affiché s'il n'y en a pas.
|
||||
|
||||
Exemple de sortie :
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Des fanions facultatifs peuvent être ajoutés pour changer la sortie.
|
||||
Un ou plusieurs fanions peuvent être ajoutés.
|
||||
|
||||
0 Afficher les lignes d'information du fichier suivies d'un
|
||||
caractère nul au lieu d'un saut de ligne. Cela permet
|
||||
d'interpréter correctement les noms de fichiers avec des espaces
|
||||
ou des guillemets quand le fanion c est utilisé. Utilisez ce
|
||||
fanion avec les options -0 ou "--null" de xargs(1).
|
||||
|
||||
d Affiche le nombre de sauts de ligne DOS.
|
||||
|
||||
u Affiche le nombre de sauts de ligne Unix.
|
||||
|
||||
m Affiche le nombre de sauts de ligne Mac.
|
||||
|
||||
b Afficher la marque d'ordre des octets.
|
||||
|
||||
t Affiche si le fichier est texte ou binaire.
|
||||
|
||||
e Affiche le type du saut de ligne de la dernière ligne ou "noeol"
|
||||
s'il n'y en a pas.
|
||||
|
||||
c Affiche uniquement les fichiers qui seraient convertis.
|
||||
|
||||
Avec le fanion "c", dos2unix n'affichera que les fichiers
|
||||
contenant des sauts de ligne DOS alors que unix2dos n'affichera
|
||||
que les noms des fichiers aillant des sauts de ligne Unix.
|
||||
|
||||
Si l'option "-e" ou "--add-eol" est également utilisée, les
|
||||
fichiers qui n'ont pas de saut de ligne à la dernière ligne
|
||||
seront affichés.
|
||||
|
||||
h Afficher un en-tête.
|
||||
|
||||
p Montrer les noms des fichiers sans le chemin.
|
||||
|
||||
Exemples:
|
||||
|
||||
Afficher les informations pour tous les fichier *.txt :
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Afficher uniquement le nombre de sauts de ligne DOS et Unix :
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Montrer uniquement la marque d'ordre des octets :
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Liste les fichiers qui ont des sauts de ligne DOS :
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Liste les fichiers qui ont des sauts de ligne Unix :
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Liste les fichiers qui ont des sauts de ligne DOS ou qui n'ont pas
|
||||
de saut de ligne à la dernière ligne.
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Ne converti que les fichiers qui ont des sauts de lignes DOS et
|
||||
laisse les autres fichiers inchangés:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Trouve les fichiers texte qui ont des sauts de ligne DOS :
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
La date du fichier de sortie est la même que celle du fichier
|
||||
d'entrée.
|
||||
|
||||
-L, --license
|
||||
Affiche la licence du programme.
|
||||
|
||||
-l, --newline
|
||||
Ajoute des sauts de lignes additionnels.
|
||||
|
||||
dos2unix: Seuls les sauts de lignes du DOS sont changés en deux
|
||||
sauts de lignes de Unix. En mode Mac, seuls les sauts de lignes Mac
|
||||
sont changés en deux sauts de lignes Unix.
|
||||
|
||||
unix2dos: Seuls les sauts de lignes Unix sont changés en deux sauts
|
||||
de lignes du DOS. En mode Mac, les sauts de lignes Unix sont
|
||||
remplacés par deux sauts de lignes Mac.
|
||||
|
||||
-m, --add-bom
|
||||
Écrit une marque d'ordre des octets (BOM) dans le fichier de sortie.
|
||||
Par défaut une BOM UTF-8 est écrite.
|
||||
|
||||
Lorsque le fichier d'entrée est en UTF-16 et que l'option "-u" est
|
||||
utilisée, une BOM UTF-16 est écrite.
|
||||
|
||||
N'utilisez jamais cette option quand l'encodage du fichier de sortie
|
||||
n'est ni UTF-8 ni UTF-16 ni GB18030. Consultez également la section
|
||||
UNICODE.
|
||||
|
||||
-n, --newfile FICHIER_ENTRÉE FICHIER_SORTIE …
|
||||
Nouveau mode de fichiers. Convertit le fichier FICHER_ENTRÉE et
|
||||
écrit la sortie dans le fichier FICHIER_SORTIE. Les noms des
|
||||
fichiers doivent être indiqués par paires. Les caractères de
|
||||
remplacement *ne* doivent *pas* être utilisés ou vous *perdrez* vos
|
||||
fichiers.
|
||||
|
||||
La personne qui démarre la conversion dans le nouveau mode (pairé)
|
||||
des fichiers sera le propriétaire du fichier converti. Les
|
||||
permissions de lecture/écriture du nouveau fichier seront les
|
||||
permissions du fichier original moins le umask(1) de la personne qui
|
||||
exécute la conversion.
|
||||
|
||||
--no-allow-chown
|
||||
Ne pas autoriser le changement du propriétaire du fichier dans
|
||||
l'ancien mode de fichier (par défaut).
|
||||
|
||||
Interrompt la conversion si l'utilisateur ou le groupe propriétaire
|
||||
du fichier original ne peuvent pas être préservés dans l'ancien mode
|
||||
de fichier. Voyez aussi les options "-o" et "-n". Cette option est
|
||||
uniquement présente si dos2unix dispose des fonctionnalités pour
|
||||
préserver l'utilisateur ou le groupe propriétaire des fichiers.
|
||||
|
||||
--no-add-eol
|
||||
N'ajoute pas de saut de ligne à la dernière ligne s'il n'y en a pas
|
||||
(par défaut).
|
||||
|
||||
--no-error-binary
|
||||
Ne pas retourner une erreur si un fichier binaire est ignoré (par
|
||||
défaut).
|
||||
|
||||
-O, --to-stdout
|
||||
Écrit vers la sortie standard, comme un filtre Unix. Utilisez
|
||||
l'option "-o" pour revenir au mode de l'ancien fichier (en place).
|
||||
|
||||
Combiné avec l'option "-e", les fichiers peuvent être concaténés
|
||||
correctement. Les première et dernière lignes ne sont pas fusionnées
|
||||
et il n'y a pas de marque d'ordre des octets au milieu du fichier
|
||||
concaténé. Exemple :
|
||||
|
||||
dos2unix -e -O fichier1.txt fichier2.txt > sortie.txt
|
||||
|
||||
-o, --oldfile FICHIER …
|
||||
Ancien mode de fichiers. Convertit le fichier FICHIER et écrit la
|
||||
sortie dedans. Le programme fonctionne dans ce mode par défaut. Les
|
||||
noms avec des caractères de remplacement peuvent être utilisés.
|
||||
|
||||
Dans l'ancien mode (en place) des fichiers, les fichiers convertis
|
||||
ont le même propriétaire, groupe et permissions lecture/écriture que
|
||||
le fichier original. Idem quand le fichier est converti par un
|
||||
utilisateur qui a la permission d'écrire dans le fichier (par
|
||||
exemple, root). La conversion est interrompue si il n'est pas
|
||||
possible de conserver les valeurs d'origine. Le changement de
|
||||
propriétaire pourrait signifier que le propriétaire original n'est
|
||||
plus en mesure de lire le fichier. Le changement de groupe pourrait
|
||||
être un risque pour la sécurité. Le fichier pourrait être rendu
|
||||
accessible en lecture par des personnes à qui il n'est pas destiné.
|
||||
La conservation du propriétaire, du groupe et des permissions de
|
||||
lecture/écriture n'est supportée que sous Unix.
|
||||
|
||||
Pour vérifier si dos2unix dispose des fonctions pour préserver
|
||||
l'utilisateur et le groupe propriétaire du fichier, tapez "dos2unix
|
||||
-V".
|
||||
|
||||
La conversion est toujours réalisée via un fichier temporaire. Quand
|
||||
une erreur survient au milieu de la conversion, le fichier
|
||||
temporaire est effacé et le fichier original reste inchangé. Quand
|
||||
la conversion réussi, le fichier original est remplacé par le
|
||||
fichier temporaire. Vous pourriez avoir la permission d'écrire dans
|
||||
le fichier original mais ne pas avoir la permission de remplacer les
|
||||
propriétés de l'utilisateur et du groupe propriétaires sur le
|
||||
fichier temporaire telles qu'elles sont définies sur le fichier
|
||||
original. Cela signifie que vous n'êtes pas en mesure de préserver
|
||||
l'utilisateur ou le groupe propriétaire du fichier original. Dans ce
|
||||
cas, vous pouvez utiliser l'option "--allow-chown" pour continuer la
|
||||
conversion.
|
||||
|
||||
dos2unix --allow-chown toto.txt
|
||||
|
||||
Une autre option consiste à utiliser le nouveau mode de fichier:
|
||||
|
||||
dos2unix -n toto.txt toto.txt
|
||||
|
||||
L'avantage de l'option "--allow-chown" est que vous pouvez utiliser
|
||||
des caractères de remplacement et les propriétaires seront préservés
|
||||
dans la mesure du possible.
|
||||
|
||||
-q, --quiet
|
||||
Mode silencieux. Supprime les avertissements et les messages. La
|
||||
valeur de sortie est zéro sauf quand de mauvaises options sont
|
||||
utilisées sur la ligne de commande.
|
||||
|
||||
-r, --remove-bom
|
||||
Supprime la marque d'ordre des octets (BOM). N'écrit pas la BOM dans
|
||||
le fichier de sortie. Ceci est le comportement par défaut lorsque
|
||||
les sauts de lignes sont convertis au format Unix. Consultez aussi
|
||||
l'option "-b".
|
||||
|
||||
-s, --safe
|
||||
Ignore les fichiers binaires (par défaut).
|
||||
|
||||
Ignorer les fichiers binaires sert à éviter les erreurs
|
||||
accidentelles. Attention que la détection de fichiers binaires n'est
|
||||
pas fiable à 100%. Les fichiers en entrée sont analysés pour y
|
||||
trouver des symboles binaires qui ne sont habituellement pas
|
||||
rencontrés dans des fichiers textes. Il est cependant possible qu'un
|
||||
fichier binaire ne contienne que des caractères textes normaux. Un
|
||||
tel fichier serait erronément traité comme un fichier texte.
|
||||
|
||||
Par défaut, aucune erreur n'est retournée quand un fichier binaire
|
||||
est ignoré. Si l'option "--error-binary" est utilisée, une erreur
|
||||
est retournée.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Suppose que le fichier d'entrée est au format UTF-16LE.
|
||||
|
||||
Quand il y a un indicateur d'ordre des octets dans le fichier
|
||||
d'entrée, l'indicateur a priorité sur cette option.
|
||||
|
||||
Si vous vous êtes trompé sur le format du fichier d'entrée (par
|
||||
exemple, ce n'était pas un fichier UTF16-LE) et que la conversion
|
||||
réussi, vous obtiendrez un fichier UTF-8 contenant le mauvais texte.
|
||||
Vous pouvez récupérer le fichier original avec iconv(1) en
|
||||
convertissant le fichier de sortie UTF-8 vers du UTF-16LE.
|
||||
|
||||
La présupposition de l'UTF-16LE fonctionne comme un *mode de
|
||||
conversion*. En utilisant le mode *ascii* par défaut, UTF-16LE n'est
|
||||
plus présupposé.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Suppose que le fichier d'entrée est au format UTF-16BE.
|
||||
|
||||
Cette option fonctionne comme l'option "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Affiche des messages verbeux. Des informations supplémentaires sont
|
||||
affichées à propos des marques d'ordre des octets et du nombre de
|
||||
sauts de lignes convertis.
|
||||
|
||||
-F, --follow-symlink
|
||||
Suit les liens symboliques et convertit les cibles.
|
||||
|
||||
-R, --replace-symlink
|
||||
Remplace les liens symboliques par les fichiers convertis (les
|
||||
fichiers cibles originaux restent inchangés).
|
||||
|
||||
-S, --skip-symlink
|
||||
Ne change pas les liens symboliques ni les cibles (par défaut).
|
||||
|
||||
-V, --version
|
||||
Affiche les informations de version puis arrête.
|
||||
|
||||
MODE MAC
|
||||
Par défaut, les sauts de lignes sont convertis du DOS vers Unix et
|
||||
inversement. Les sauts de lignes Mac ne sont pas convertis.
|
||||
|
||||
En mode Mac, les sauts de lignes sont convertis du format Mac au format
|
||||
Unix et inversement. Les sauts de lignes DOS ne sont pas changés.
|
||||
|
||||
Pour fonctionner en mode Mac, utilisez l'option en ligne de commande "-c
|
||||
mac" ou utilisez les commandes "mac2unix" ou "unix2mac".
|
||||
|
||||
MODES DE CONVERSION
|
||||
ascii
|
||||
Ceci est le mode de conversion par défaut. Ce mode convertit les
|
||||
fichiers ASCII en fichiers compatibles avec l'ASCII tel que UTF-9.
|
||||
Activer le mode ascii désactive les modes 7bit et iso.
|
||||
|
||||
Si dos2unix supporte UTF-16, les fichiers encodés en UTF-16 sont
|
||||
convertis vers l'encodage des caractères des paramètres
|
||||
linguistiques courants sur les systèmes POSIX et vers UTF-8 sous
|
||||
Windows. Activer le mode ascii désactive l'option pour garder
|
||||
l'encodage UTF-8 ("-u") et les options qui supposent une entrée en
|
||||
UTF-16 ("-ul" et "-ub"). Pour voir si dos2unix supporte UTF-16,
|
||||
tapez "dos2unix -V". Consultez aussi la section UNICODE.
|
||||
|
||||
7bit
|
||||
Dans ce mode, tous les caractères 8 bits non ASCII (avec des valeurs
|
||||
entre 128 et 255) sont remplacés par une espace 7 bits.
|
||||
|
||||
iso Les caractères sont convertis entre un jeu de caractères DOS (code
|
||||
page) et le jeu de caractères ISO-8859-1 (Latin-1) de Unix. Les
|
||||
caractères DOS sans équivalent ISO-8859-1, pour lesquels la
|
||||
conversion n'est pas possible, sont remplacés par un point. La même
|
||||
chose est valable pour les caractères ISO-8859-1 sans équivalent
|
||||
DOS.
|
||||
|
||||
Quand seule l'option "-iso" est utilisée, dos2unix essaie de
|
||||
déterminer le code page actif. Quand ce n'est pas possible, dos2unix
|
||||
utilise le code page CP437 par défaut qui est surtout utilisé aux
|
||||
USA. Pour forcer l'utilisation d'un code page spécifique, utilisez
|
||||
les options -437 (US), -850 (Europe de l'ouest), -860 (portugais),
|
||||
-863 (français canadien) ou -865 (nordique). Le code page CP1252 de
|
||||
Windows (Europe de l'ouest) est également supporté avec l'option
|
||||
-1252. Pour d'autres codes pages, utilisez dos2unix avec iconv(1).
|
||||
Iconv supporte une longue liste de codages de caractères.
|
||||
|
||||
N'utilisez jamais la conversion ISO sur des fichiers textes Unicode.
|
||||
Cela va corrompre les fichiers encodés en UTF-8.
|
||||
|
||||
Quelques exemples:
|
||||
|
||||
Convertir du code page par défaut du DOS au Latin-1 Unix :
|
||||
|
||||
dos2unix -iso -n entrée.txt sortie.txt
|
||||
|
||||
Convertir du CP850 du DOS au Latin-1 Unix :
|
||||
|
||||
dos2unix -850 -n entrée.txt sortie.txt
|
||||
|
||||
Convertir du CP1252 de Windows au Latin-1 de Unix :
|
||||
|
||||
dos2unix -1252 -n entrée.txt sortie.txt
|
||||
|
||||
Convertir le CP1252 de Windows en UTF-8 de Unix (Unicode) :
|
||||
|
||||
iconv -f CP1252 -t UTF-8 entrée.txt | dos2unix > sortie.txt
|
||||
|
||||
Convertir du Latin-1 de Unix au code page par défaut de DOS :
|
||||
|
||||
unix2dos -iso -n entrée.txt sortie.txt
|
||||
|
||||
Convertir le Latin-1 de Unix en CP850 du DOS :
|
||||
|
||||
unix2dos -850 -n entrée.txt sortie.txt
|
||||
|
||||
Convertir le Latin-1 de Unix en CP1252 de Windows :
|
||||
|
||||
unix2dos -1252 -n entrée.txt sortie.txt
|
||||
|
||||
Convertir le UTF-8 de Unix (Unicode) en CP1252 de Windows :
|
||||
|
||||
unix2dos < entrée.txt | iconv -f UTF-8 -t CP1252 > sortie.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Codages
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversion
|
||||
Les fichiers textes Unicode peuvent avoir des sauts de lignes DOS, Unix
|
||||
ou Mac, tout comme les fichiers textes ASCII.
|
||||
|
||||
Toutes les versions de dos2unix et unix2dos peuvent convertir des
|
||||
fichiers codés en UTF-8 car UTF-8 a été conçu pour être rétro-compatible
|
||||
avec l'ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
Sous Unix/Linux, les fichiers encodés en UTF-16 sont convertis vers
|
||||
l'encodage des caractères de la localisation. Utilisez locale(1) pour
|
||||
découvrir quel encodage de caractères est utilisé. Lorsque la conversion
|
||||
n'est pas possible, une erreur de conversion est produite et le fichier
|
||||
est abandonné.
|
||||
|
||||
Sous Windows, les fichiers UTF-16 sont convertis par défaut en UTF-8.
|
||||
Les fichiers textes formatés en UTF-8 sont bien supportés sous Windows
|
||||
et Unix/Linux.
|
||||
|
||||
Les codages UTF-16 et UTF-8 sont parfaitement compatibles. Il n'y a pas
|
||||
de pertes lors de la conversion. Lorsqu'une erreur de conversion UTF-16
|
||||
vers UTF-8 survient, par exemple, quand le fichier d'entrée UTF-16
|
||||
contient une erreur, le fichier est ignoré.
|
||||
|
||||
Quand l'option "-u" est utilisée, le fichier de sortie est écrit dans le
|
||||
même encodage UTF-16 que le fichier d'entrée. L'option "-u" empêche la
|
||||
conversion en UTF-8.
|
||||
|
||||
dos2unix et unix2dos n'ont pas d'option pour convertir des fichiers
|
||||
UTF-8 en UTF-16.
|
||||
|
||||
Les modes de conversion ISO et 7 bits ne fonctionnent pas sur des
|
||||
fichiers UTF-16.
|
||||
|
||||
Marque d'ordre des octets
|
||||
Les fichiers textes Unicode sous Windows on généralement un indicateur
|
||||
d'ordre des octets (BOM) car de nombreux programmes Windows (y compris
|
||||
Notepad) ajoutent cet indicateur par défaut. Consultez aussi
|
||||
<https://fr.wikipedia.org/wiki/Indicateur_d%27ordre_des_octets>.
|
||||
|
||||
Sous Unix, les fichiers Unicodes n'ont habituellement pas de BOM. Il est
|
||||
supposé que les fichiers textes sont codés selon le codage de
|
||||
l'environnement linguistique.
|
||||
|
||||
dos2unix ne peut détecter que le fichier est au format UTF-16 si le
|
||||
fichier n'a pas de BOM. Quand le fichier UTF-16 n'a pas cet indicateur,
|
||||
dos2unix voit le fichier comme un fichier binaire.
|
||||
|
||||
Utilisez l'option "-ul" ou "-ub" pour convertir un fichier UTF-16 sans
|
||||
BOM.
|
||||
|
||||
dos2unix, par défaut, n'écrit pas de BOM dans le fichier de sortie. Avec
|
||||
l'option "-b", dos2unix écrit une BOM quand le fichier d'entrée a une
|
||||
BOM.
|
||||
|
||||
unix2dos écrit par défaut une BOM dans le fichier de sortie quand le
|
||||
fichier d'entrée a une BOM. Utilisez l'option "-r" pour supprimer la
|
||||
BOM.
|
||||
|
||||
dos2unix et unix2dos écrivent toujours une BOM quand l'option "-m" est
|
||||
utilisée.
|
||||
|
||||
Noms de fichiers unicode sous Windows
|
||||
dos2unix supporte, en option, la lecture et l'écriture de noms de
|
||||
fichiers Unicode dans la ligne de commande de Windows. Cela signifie que
|
||||
dos2unix peut ouvrir des fichiers qui ont, dans leur nom, des caractères
|
||||
n'appartenant pas au code page système ANSI par défaut. Pour voir si
|
||||
dos2unix pour Windows a été compilé avec le support des noms de fichiers
|
||||
Unicode, tapez "dos2unix -V".
|
||||
|
||||
Il y a quelques soucis avec l'affichage de noms de fichiers Unicode dans
|
||||
une console Windows. Voyez l'option "-D", "--display-enc". Les noms de
|
||||
fichiers peuvent être mal affichés dans la console mais les fichiers
|
||||
seront écrits avec les bons noms.
|
||||
|
||||
Exemples Unicode
|
||||
Convertir de l'UTF-16 Windows (avec BOM) vers l'UTF-8 de Unix :
|
||||
|
||||
dos2unix -n entrée.txt sortie.txt
|
||||
|
||||
Convertir de l'UTF-16LE de Windows (sans BOM) vers l'UTF-8 de Unix :
|
||||
|
||||
dos2unix -ul -n entrée.txt sortie.txt
|
||||
|
||||
Convertir de l'UTF-8 de Unix vers l'UTF-8 de Windows avec BOM :
|
||||
|
||||
unix2dos -m -n entrée.txt sortie.txt
|
||||
|
||||
Convertir de l'UTF-8 de Unix vers l'UTF-16 de Windows :
|
||||
|
||||
unix2dos < entrée.txt | iconv -f UTF-8 -t UTF-16 > sortie.txt
|
||||
|
||||
GB18030
|
||||
GB18030 est un standard du gouvernement chinois. Tout logiciel vendu en
|
||||
Chine doit officiellement supporter un sous ensemble obligatoire du
|
||||
standard GB18030. Consultez <https://fr.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 est entièrement compatible avec Unicode et peut être considéré
|
||||
comme étant un format de transformation unicode. Comme UTF-8, GB18030
|
||||
est compatible avec ASCII. GB18030 est aussi compatible avec le code
|
||||
page 936 de Windows aussi connu comme GBK.
|
||||
|
||||
Sous Unix/Linux, les fichiers UTF-16 sont convertis en GB18030 quand
|
||||
l'encodage de l'environnement linguistique est GB18030. Notez que cela
|
||||
ne fonctionnera que si l'environnement linguistique est supporté par le
|
||||
système. Utilisez la commande "locale -a" pour obtenir la liste des
|
||||
environnements linguistiques supportés.
|
||||
|
||||
Sous Windows, vous avez besoin de l'option "-gb" pour convertir UTF-16
|
||||
en GB18030.
|
||||
|
||||
Les fichiers encodés en GB18030 peuvent avoir une marque d'ordre des
|
||||
octets, comme les fichiers Unicode.
|
||||
|
||||
EXEMPLES
|
||||
Lire l'entrée depuis « stdin » et écrire la sortie vers « stdout » :
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Convertir et remplacer a.txt. Convertir et remplace b.txt :
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Convertir et remplacer a.txt en mode de conversion ascii :
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Convertir et remplacer a.txt en mode de conversion ascii. Convertir et
|
||||
remplacer b.txt en mode de conversion 7 bits :
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Convertir a.txt depuis le format Mac vers le format Unix :
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Convertir a.txt du format Unix au format Mac :
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Convertir et remplacer a.txt tout en conservant la date originale :
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Convertir a.txt et écrire dans e.txt :
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Convertir a.txt et écrire dans e.txt. La date de e.txt est la même que
|
||||
celle de a.txt :
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Convertir et remplacer a.txt. Convertir b.txt et écrire dans e.txt :
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Convertir c.txt et écrire dans e.txt. Convertir et remplacer a.txt.
|
||||
Convertir et remplacer b.txt. Convertir d.txt et écrire dans f.txt :
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
CONVERSIONS RÉCURSIVES
|
||||
Dans un shell Unix, les commandes find(1) et xargs(1) peuvent être
|
||||
utilisées pour exécuter dos2unix récursivement sur tous les fichiers
|
||||
textes dans une arborescence de répertoires. Par exemple, pour convertir
|
||||
tous les fichiers .txt dans les répertoires sous le répertoire courant,
|
||||
tapez:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
L'option "-print0" de find(1) et l'option correspondante -0 de xargs(1)
|
||||
sont nécessaires quand il y a des fichiers avec des espaces ou des
|
||||
guillemets dans leur nom. Sinon, ces options peuvent être omises. Une
|
||||
autre possibilité est d'utiliser find(1) avec l'option "-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
En ligne de commande sous Windows, la commande suivante peut être
|
||||
utilisée :
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
find /R %G in
|
||||
|
||||
Les utilisateurs de PowerShell peuvent utiliser la commande suivante
|
||||
dans le PowerShell de Windows :
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
PARAMÈTRES LINGUISTIQUES
|
||||
LANG
|
||||
La langue principale est sélectionnée par la variable
|
||||
d'environnement LANG. La variable LANG est composée de plusieurs
|
||||
parties. La première partie est le code de la langue en minuscules.
|
||||
La deuxième partie est le code du pays en majuscules précédé d'un
|
||||
souligné. Elle est facultative. Il y a aussi une troisième partie
|
||||
facultative qui est le codage des caractères précédé par un point.
|
||||
Voici quelques exemples pour un shell au standard POSIX:
|
||||
|
||||
export LANG=fr Français
|
||||
export LANG=fr_CA Français, Canada
|
||||
export LANG=fr_BE Français, Belgique
|
||||
export LANG=es_ES Espagnol, Espagne
|
||||
export LANG=es_MX Espagnol, Mexique
|
||||
export LANG=en_US.iso88591 Anglais, USA, codage Latin-1
|
||||
export LANG=en_GB.UTF-8 Anglais, UK, codage UTF-8
|
||||
|
||||
La liste complète des codes de langues et de pays est dans le manuel
|
||||
de gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
Sur les systèmes Unix, vous pouvez utiliser la commande locale(1)
|
||||
pour obtenir des informations sur l'environnement linguistique.
|
||||
|
||||
LANGUE
|
||||
Avec la variable d'environnement LANGUAGE, vous pouvez spécifier une
|
||||
liste de langues prioritaires séparées par des deux-points. dos2unix
|
||||
fait passer LANGUAGE avant LANG. Par exemple, pour utiliser le
|
||||
français avant l'anglais: "LANGUAGE=fr:en". Vous devez d'abord
|
||||
activer l'environnement linguistique en assignant une valeur autre
|
||||
que « C » à LANG (ou LC_ALL). Ensuite, vous pourrez utiliser la
|
||||
liste de priorité avec la variable LANGUAGE. Voyez également le
|
||||
manuel de gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Si vous sélectionnez une langue qui n'est pas disponible, vous
|
||||
obtiendrez des messages en anglais standard.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Grâce à la variable d'environnement DOS2UNIX_LOCALEDIR, la variable
|
||||
LOCALEDIR compilée dans l'application peut être remplacée. LOCALEDIR
|
||||
est utilisée pour trouver les fichiers de langue. La valeur par
|
||||
défaut de GNU est "/usr/local/share/locale". L'option --version
|
||||
affiche la valeur de LOCALEDIR utilisée.
|
||||
|
||||
Exemple (shell POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
VALEUR DE RETOUR
|
||||
Zéro est retourné en cas de succès. Si une erreur système se produit, la
|
||||
dernière erreur système est retournée. Pour les autres erreurs, 1 est
|
||||
renvoyé.
|
||||
|
||||
La valeur de sortie est toujours zéro en mode silencieux sauf quand de
|
||||
mauvaises options sont utilisées sur la ligne de commande.
|
||||
|
||||
STANDARDS
|
||||
<https://fr.wikipedia.org/wiki/Fichier_texte>
|
||||
|
||||
<https://fr.wikipedia.org/wiki/Retour_chariot>
|
||||
|
||||
<https://fr.wikipedia.org/wiki/Fin_de_ligne>
|
||||
|
||||
<https://fr.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTEURS
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mode
|
||||
mac2unix) - <wuebben@kde.org>, Christian Wurll (ajout de saut de ligne
|
||||
supplémentaire) - <wurll@ira.uka.de>, Erwin Waterlander -
|
||||
<waterlan@xs4all.nl> (Mainteneur)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Page SourceForge: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
VOIR AUSSI
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/ko/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/ko/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - DOS/맥 에서 유닉스에서, 그 반대로의 텍스트 파일 형식 변환 프로그램</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#pod">이름</a></li>
|
||||
<li><a href="#pod1">개요</a></li>
|
||||
<li><a href="#pod2">설명</a></li>
|
||||
<li><a href="#pod3">옵션</a></li>
|
||||
<li><a href="#pod5">맥 모드</a></li>
|
||||
<li><a href="#pod6">변환 모드</a></li>
|
||||
<li><a href="#pod7">유니코드</a>
|
||||
<ul>
|
||||
<li><a href="#pod8">인코딩</a></li>
|
||||
<li><a href="#pod9">변환</a></li>
|
||||
<li><a href="#BOM">바이트 순서 표시(BOM)</a></li>
|
||||
<li><a href="#pod10">윈도우의 유니코드 파일 이름</a></li>
|
||||
<li><a href="#pod11">유니코드 예제</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#pod12">예제</a></li>
|
||||
<li><a href="#pod13">재귀 변환</a></li>
|
||||
<li><a href="#pod14">지역화</a></li>
|
||||
<li><a href="#pod15">반환 값</a></li>
|
||||
<li><a href="#pod16">표준</a></li>
|
||||
<li><a href="#pod17">저자</a></li>
|
||||
<li><a href="#pod18">추가 참조</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="pod">이름</h1>
|
||||
|
||||
<p>dos2unix - DOS/맥 에서 유닉스로, 내지는 그 반대로의 텍스트 파일 형식 변환 프로그램</p>
|
||||
|
||||
<h1 id="pod1">개요</h1>
|
||||
|
||||
<pre><code>dos2unix [<옵션>] [<파일> ...] [-n <입력파일> <출력파일> ...]
|
||||
unix2dos [<옵션>] [<파일> ...] [-n <입력파일> <출력파일> ...]</code></pre>
|
||||
|
||||
<h1 id="pod2">설명</h1>
|
||||
|
||||
<p>dos2unix 패키지에는 DOS 또는 맥 형식을 유닉스 형식으로, 내지는 그 반대로 원시 텍스트 파일을 변환하는 <code>dos2unix</code> 유틸리티와 <code>unix2dos</code> 유틸리티가 들어있습니다.</p>
|
||||
|
||||
<p>DOS/윈도우 텍스트 개행 문자는 캐리지 리턴(CR)과 뒤따라오는 라인 피드(LF) 문자를 결합한 형태를 취합니다. 유닉스 텍스트 파일의 개행문자는 라인 피드(LF) 하나 뿐입니다. Mac OS X 이전의 맥 텍스트 파일은 캐리지 리턴(CR) 문자 하나 뿐이었습니다. 그러나 지금은 Mac OS에서도 유닉스 방식 (LF) 개행 문자를 취합니다.</p>
|
||||
|
||||
<p>개행 문자 관련하여 dos2unix에서는 파일 인코딩도 변환할 수 있습니다. 일부 DOS 코드 페이지는 유닉스 Latin-1 인코딩으로 변환할 수 있습니다. 그리고 윈도우 유니코드 (UTF-16) 파일은 유닉스 유니코드 (UTF-8) 파일로 변환할 수 있습니다.</p>
|
||||
|
||||
<p>이진 파일은 변환을 강제하지 않는 한 자동으로 건너뜁니다.</p>
|
||||
|
||||
<p>디렉터리와 FIFO 같은 일반 파일 외 요소는 자동으로 건너뜁니다.</p>
|
||||
|
||||
<p>심볼릭 링크와 대상은 보통 (완전히) 연결한 상태가 아닙니다. 심볼릭 링크는 별도로 바꿀 수 있거나, 심볼릭 링크 대상으로 기록할 수 있습니다. 심볼릭 링크 대상 기록은 윈도우에서 지원하지 않습니다.</p>
|
||||
|
||||
<p>dos2unix는 SunOS/솔라리스의 dos2unix가 나온 후 구성한 모델입니다. SunOS/솔라리스 버전과 한가지 중요한 차이가 있습니다. SunOS/솔라리스 버전은 페어링 변환(새 파일 모드)만 지원하지만, 이 버전은 자체 변환(이전 파일 모드)도 지원합니다. <code>-o</code>, <code>-n</code> 옵션도 참고하십시오. 다른 차이점이 있다면 SunOS/솔라리스 버전은 <i>iso</i> 모드 변환이 기본이지만 이 버전은 <i>ascii</i> 모드 변환이 기본입니다.</p>
|
||||
|
||||
<h1 id="pod3">옵션</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod4"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>뒤따라오는 모든 옵션은 파일 이름으로 간주합니다. 대시 문자로 시작하는 이름을 가진 파일을 변환하려면 이 옵션을 사용하십시오. 예를 들어 "-foo" 파일을 변환할 경우, 다음 명령을 사용할 수 있습니다:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>또는 새 파일 모드에서:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이전 파일 모드의 파일 소유권을 바꿀 수 있게 합니다.</p>
|
||||
|
||||
<p>이 옵션을 사용하면 이전 파일의 사용자 또는 그룹 소유권을 유지할 수 없을 때 변환을 멈추지 않습니다. 새 파일의 모드로 변환할 때 처럼 동일하게 변환한 파일에 새 소유권을 부여하면서 변환을 계속합니다. <code>-o</code>, <code>-n</code> 옵션도 참고하십시오. 이 옵션은 dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능이 있을 경우에만 사용할 수 있습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>기본 변환 모드입니다. 변환 모드 섹션을 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS와 ISO-8859-1 문자 세트 변환을 진행합니다. 변환 모드 섹션을 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>윈도우 코드 페이지 1252(서유럽어)를 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 코드 페이지 437(미합중국)을 활용합니다. ISO 변환시 기본 코드 페이지로 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 코드 페이지 850(서유럽어)을 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 코드 페이지 860(포르투갈어)을 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 코드 페이지 863(캐나다 프랑스어)을 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 코드 페이지 865(북유럽어)를 활용합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>8비트 문자를 7비트 영역으로 변환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>바이트 순서 표시(BOM)를 유지합니다. 입력 파일에 BOM이 들어있다면, 출력 파일에 BOM을 기록합니다. DOS 개행 문자를 변환할 때 기본 동작입니다. <code>-r</code>옵션 정보도 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode"><b>-c, --convmode <변환모드></b></dt>
|
||||
<dd>
|
||||
|
||||
<p>변환 모드를 설정합니다. <변환모드>는 <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> 값 중 하나이며 ascii가 기본값입니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc"><b>-D, --display-enc <인코딩></b></dt>
|
||||
<dd>
|
||||
|
||||
<p>표시 텍스트 인코딩을 설정합니다. <인코딩>은 <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i> 값 중 하나이며, ansi가 기본값입니다.</p>
|
||||
|
||||
<p>이 옵션은 유니코드 파일 이름을 지원하는 윈도우용 dos2unix에서만 사용할 수 있습니다. 이 옵션은 실제 파일 이름을 읽고 쓰는데 아무런 영향을 주지 않으며, 어떻게 나타내는 지에 대해서만 영향을 줍니다.</p>
|
||||
|
||||
<p>텍스트 인코딩 기반으로 윈도우 콘솔에서 텍스트를 나타내는 방법에는 여러가지가 있습니다. 각 방법에는 고유의 장점과 단점이 있습니다.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix의 기본 방식은 ANSI 인코딩 텍스트를 활용하는 방법입니다. 하위 호환성이 장점입니다. 래스터 및 트루타입 글꼴에 동작합니다. 일부 국가에서는 dos2unix에서 윈도우 시스템 코드 페이지를 사용하기 때문에 <code>chcp</code> 명령으로 윈도우 시스템 ANSI 코드 페이지로 DOS OEM 활성 코드 페이지를 바꾸어야 합니다.</p>
|
||||
|
||||
<p>ANSI 방식의 단점은 국제어 파일 이름이 시스템 기본 코드 페이지에 들어있지 않아 제대로 화면에 나타나지 않습니다. 물음표 기호 또는 잘못된 기호가 대신 나타날 수 있습니다. 타 언어 파일 이름으로 동작하지 않는다면 이 방식이 괜찮습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>유니코드(UTF-16의 윈도우 이름) 인코딩의 장점이란 텍스트가 보통 제대로 나타난다는 점입니다. 활성 코드 페이지를 바꿀 필요는 없습니다. 콘솔의 전세계 문자가 제대로 나타나려면 트루타입 글꼴을 선택해야합니다. 문자가 트루타입 글꼴 세트에 들어있지 않으면 작은 사각형 모양을 볼 수 있으며, 때로는 물음표로 나타나기도 합니다.</p>
|
||||
|
||||
<p>ConEmu 콘솔을 사용한다면 ConEmu에서 적절한 글꼴을 자동으로 선택하므로 모든 텍스트가 제대로 나타납니다.</p>
|
||||
|
||||
<p>유니코드 사용의 단점은 아스키와 호환성이 없다는 점입니다. 다른 프로그램으로 출력을 전달할 때 쉽게 처리할 수 없습니다.</p>
|
||||
|
||||
<p><code>unicodebom</code> 방식을 사용하면 BOM(바이트 순서 표시)을 텍스트 앞에 둡니다. BOM은 파워셸에서 출력 내용을 올바르게 전달 또는 파이핑할 때 필요합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>utf8의 장점은 아스키와의 호환성입니다. 콘솔의 글꼴을 트루타입 글꼴로 선택해야 합니다. 트루타입 글꼴로 설정하면 <code>unicode</code> 인코딩 때와 비슷하게 나타납니다.</p>
|
||||
|
||||
<p>단점은 래스터 글꼴을 기본으로 사용하면 아스키 인코딩을 하지 않는 문자를 잘못 나타낼 수 있습니다. 유니코드 파일 이름 뿐만 아니라 번역 메시지 조차 제대로 읽을 수 없습니다. 윈도우에서는 동아시아 지역으로 설정했을 경우 메시지가 나타날 때 콘솔 화면이 상당히 많이 깜빡거리는걸 볼 수 있습니다.</p>
|
||||
|
||||
<p>ConEmu 콘솔에서는 utf8 인코딩이 제대로 동작합니다.</p>
|
||||
|
||||
<p><code>utf8bom</code> 방식을 사용하면 UTF-8 텍스트 앞에 BOM(바이트 순서 표시)를 둡니다. BOM은 파워셸에서 출력 내용을 올바르게 전달 또는 파이핑할 때 필요합니다.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>기본 인코딩은 DOS2UNIX_DISPLAY_ENC 환경 변수를 <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code>, <code>utf8bom</code> 중 값 하나로 설정하여 바꿀 수 있습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>개행 문자가 줄 끝에 없을 경우 추가합니다. 모든 변환 과정에서 동작합니다.</p>
|
||||
|
||||
<p>DOS 형식에서 유닉스 형식으로 변환한 파일의 행 끝에 개행 문자가 빠질 수도 있습니다. 행 끝에 개행 문자가 빠진 채로 텍스트 파일을 기록하는 텍스트 편집기가 있습니다. 텍스트 파일의 모든 줄 끝에 반드시 개행 문자로 끝나야 하는게 POSIX 표준이기에, 일부 유닉스 프로그램에서는 이 파일을 처리하는 문제가 있습니다. 예를 들면, 파일 내용을 합칠 때 예상한 대로 결과가 나타나지 않습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이진 파일을 건너뛸 때 오류를 반환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>강제로 이진 파일을 변환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>윈도우에서는 로캘 설정 여부와 관계 없이 UTF-16 파일이 기본이기에 UTF-8로 변환합니다. 이 옵션을 사용하면 UTF-16 파일을 GB18030으로 변환합니다. 이 옵션은 윈도우에서만 사용할 수 있습니다. GB18030 섹션을 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>도움말을 표시하고 나갑니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i---info"><b>-i[<플래그>], --info[=<플래그>] <파일> ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>파일 정보를 표시합니다. 변환 동작은 하지 않습니다.</p>
|
||||
|
||||
<p>다음 정보를 DOS 개행 문자 수, 유닉스 개행 문자 수, 맥 개행 문자 수, 바이트 순서 표시, 텍스트 또는 이진 파일 여부, 파일 이름 순으로 정보를 출력합니다.</p>
|
||||
|
||||
<p>예제 출력:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>때로는 이진 파일을 텍스트 파일로 잘못 알아챌 수도 있습니다. <code>-s</code> 옵션도 참고하십시오.</p>
|
||||
|
||||
<p><code>-e</code> 또는 <code>--add-eol</code> 옵션을 추가로 사용하면 행 마지막 개행 문자 형식도 출력하며, 없다면 <code>noeol</code>을 출력합니다.</p>
|
||||
|
||||
<p>예제 출력:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>출력 방식을 바꿀 추가 플래그를 설정할 수 있습니다. 플래그 하나 이상을 추가할 수 있습니다.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>파일 정보 행 끝의 개행 문자 대신 널 문자를 출력합니다. c 플래그를 사용할 때 공백 또는 따옴표로 파일 이름 해석을 올바르게 할 수 있습니다. 이 플래그는 xargs(1) 옵션 <code>-0</code> 또는 <code>--null</code>을 함께 사용하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 개행 문자를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>유닉스 개행 문자를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>맥 개행 문자를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>바이트 순서 표시를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>파일의 텍스트 또는 이진 여부를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>행 마지막에 개행 문자 형식을 출력하거나, 없을 경우 <code>noeol</code>을 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>변환할 파일만 출력합니다.</p>
|
||||
|
||||
<p>dos2unix에 <code>c</code> 플래그를 사용하면 DOS 개행 문자가 들어간 파일만 출력합니다. unix2dos는 유닉스 개행 문자가 들어간 파일 이름만 출력합니다.</p>
|
||||
|
||||
<p><code>-e</code> 또는 <code>--add-eol</code> 옵션을 추가로 사용하면 행 마지막에 빠진 개행 문자를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>헤더를 출력합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>경로를 뺀 파일 이름을 나타냅니다.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>예제:</p>
|
||||
|
||||
<p>모든 *.txt 파일 정보 출력:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>DOS 개행 문자와 유닉스 개행 문자 갯수만 출력:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>바이트 순서 표시만 나타내기:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>DOS 개행 문자가 들어간 파일 목록 출력:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>유닉스 개행 문자가 들어간 파일 목록 출력:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>DOS 개행 문자가 들어갔거나 행 마지막에 개행 문자가 빠진 파일 목록 출력:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>DOS 개행 문자가 들어간 파일만 변환하며 다른 파일은 건드리지 않습니다:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>DOS 개행 문자가 들어간 텍스트 파일 찾기:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>출력 파일의 날짜 스탬프는 입력 파일과 동일하게 설정합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>프로그램 라이선스를 표시합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>부가 개행 문자를 추가합니다.</p>
|
||||
|
||||
<p><b>dos2unix</b>: DOS 개행 문자만을 유닉스 개행 문자 둘로 변환합니다. 맥 모드에서는 맥 개행 문자만을 유닉스 개행 문자 둘로 변환합니다.</p>
|
||||
|
||||
<p><b>unix2dos</b>: 유닉스 개행 문자만을 DOS 개행 문자 둘로 변환합니다. 맥 모드에서는 유닉스 개행 문자를 맥 개행 문자 둘로 변환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>바이트 순서 표시(BOM)를 출력 파일에 기록합니다. 기본적으로 UTF-8 BOM을 기록합니다.</p>
|
||||
|
||||
<p>입력 파일 인코딩이 UTF-16이고 <code>-u</code> 옵션을 사용했다면 UTF-16 BOM을 기록합니다.</p>
|
||||
|
||||
<p>출력 인코딩이 UTF-8, UTF-16, GB18030이 아니라면 이 옵션을 사용하지 마십시오. 유니코드 섹션도 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile"><b>-n, --newfile <입력파일> <출력파일> ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>새 파일 모드입니다. <입력파일>을 변환하여 <출력파일>에 기록합니다. 파일 이름은 짝으로 지정하며 와일드카드 이름은 사용하지 <i>말아야</i> 하며, 그렇지 않으면 파일을 <i>잃습니다</i>.</p>
|
||||
|
||||
<p>새 파일(짝)모드로 파일 변환을 시작한 사용자는 변환한 파일의 소유자가 됩니다. 새 파일의 읽기/쓰기 권한은 변환을 실행한 사용자의 umask(1)를 뺀 원본 파일의 권한으로 부여합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이전 파일 모드의 파일 소유권 변경을 허용하지 않습니다(기본 동작).</p>
|
||||
|
||||
<p>원본 파일의 사용자 또는 그룹 소유권을 이전 파일 모드에서 유지할 수 없다면 변환을 멈춥니다. <code>-o</code>, <code>-n</code> 옵션도 참고하십시오. 이 옵션은 dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능이 있을 경우에만 사용할 수 있습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>개행 문자가 줄 끝에 없을 경우 넣지 않습니다(기본 동작).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이진 파일을 건너뛸 때 오류를 반환하지 않습니다(기본 동작).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>유닉스 필터 동작과 비슷하게 표준 출력에 기록합니다. 이전 파일(기록) 모드로 돌아가려면 <code>-o</code> 옵션을 사용합니다.</p>
|
||||
|
||||
<p><code>-e</code> 옵션을 붙여 결합한 파일은 제대로 내용을 합칠 수 있습니다. 마지막 줄과 첫줄은 병합하지 않으며, 결합한 파일 내용 중간에 들어있는 유니코드 바이트 순서 표시는 들어가지 않습니다. 예를 들면:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O file1.txt file2.txt > output.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile"><b>-o, --oldfile <파일> ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이전 파일 모드. <파일>을 변환하고 출력을 <파일>에 덮어씁니다. 이 모드로의 실행이 프로그램 기본 동작입니다. 와일드카드 이름을 사용할 수도 있습니다.</p>
|
||||
|
||||
<p>이전 파일(자체 변환)모드에서 변환한 파일은 동일한 소유자, 그룹, 읽기 쓰기 권한을 원본 파일과 동일하게 유지합니다. 게다가 쓰기 권한이 있는 다른 사용자(예를 들어, root)가 파일을 변환했다 하더라도 마찬가지입니다. 원본 값을 그대로 유지할 수 없을 경우에는 변환을 멈춥니다. 소유권 변경이 가능하단건 곧 원본 소유자가 더이상 파일을 읽을 수 없음을 의미합니다. 소유그룹 변경은 원하지 않는 사용자가 파일을 읽게 할 수 있어 보안 문제를 야기할 수 있습니다. 소유자, 소유그룹, 읽기/쓰기 권한 유지는 유닉스에서만 지원합니다.</p>
|
||||
|
||||
<p>dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능을 지원하는지 확인하려면 <code>dos2unix -V</code>를 입력하십시오.</p>
|
||||
|
||||
<p>변환 동작은 항상 임시 파일로 처리합니다. 변환 과정 도중 오류가 발생하면, 임시 파일을 삭제하고 원본 파일을 그대로 둡니다. 변환이 끝나면 원본 파일을 임시 파일로 바꿉니다. 실행한 사용자는 원본 파일의 쓰기 권한을 가지겠지만, 원본 파일처럼 임시 파일에 사용자 또는 그룹 소유권을 동일하게 부여할 수는 없습니다. 즉, 원본 파일의 사용자 또는 그룹 권한을 그대로 대상 파일에 설정할 수는 없단 뜻입니다. 이 경우 <code>--allow-chown</code> 옵션을 사용하여 변환을 계속할 수 있습니다:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>다른 옵션은 새 파일 모드에서 사용합니다:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p><code>--allow-chown</code> 옵션의 장점은 와일드 카드를 사용할 수 있으며, 가능하다면 소유관 속성을 유지합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>미 출력 모드. 모든 경고와 메시지를 끕니다. 반환 값은 0입니다. 잘못된 명령행 옵션을 사용했을 때는 이 경우에서 제외합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>바이트 순서 표시(BOM)를 제거합니다. BOM을 출력 파일에 기록하지 않습니다. 유닉스 개행 문자로 변환할 때 기본 동작입니다. <code>-b</code> 옵션도 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이진 파일은 건너뜁니다 (기본 동작).</p>
|
||||
|
||||
<p>이진 파일 건너뛰기는 갑작스런 실수를 피하는 동작입니다. 이진 파일 감시는 100% 실패 예방을 하지 않습니다. 입력 파일에서 텍스트 파일에서 보통 찾을 수 없는 이진 심볼을 검색합니다. 이진 파일에도 일반 텍스트 문자만 들어있을 수 있습니다. 이런 이진 파일 종류는 (그래서) 텍스트 파일로 실수로 알아챌 수 있습니다.</p>
|
||||
|
||||
<p>이진 파일을 건너뛸 때 오류 미반환이 기본 동작입니다. <code>--error-binary</code> 옵션을 사용하면 오류를 반환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>입력 파일의 UTF-16 인코딩 원본을 유지합니다. 출력 파일은 동일한 UTF-16 인코딩을 리틀엔디언 또는 빅엔디언으로 입력 파일과 같이 기록합니다. 이는 UTF-8로의 변환을 막습니다. UTF-16 BOM은 원본을 따라 대상에 기록합니다. 이 옵션 동작은 <code>-ascii</code> 옵션으로 막을 수 있습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>입력 파일 형식을 UTF-16LE로 가정합니다.</p>
|
||||
|
||||
<p>바이트 순서 표시가 입력 파일에 있다면 BOM은 이 옵션보다 우선순위를 갖습니다.</p>
|
||||
|
||||
<p>잘못된 가정(입력 파일이 UTF-16LE 형식이 아니라거나)하에 변환에 성공했다면, 잘못된 내용이 들어간 UTF-8 출력 파일을 받을 수 있습니다. iconf(1) 명령을 활용하여 UTF-8 출력 파일을 UTF-16LE로 되돌려 변환하는 방식으로 잘못된 변환 결과를 되돌릴 수 있습니다. 이런 방법으로 원본 파일을 되돌릴 수 있습니다.</p>
|
||||
|
||||
<p>UTF-16LE가 <i>변환 모드</i>로 동작한다고 가정해보겠습니다. 기본 <i>ascii</i> 모드로 전환하면 UTF-16LE에 대한 가정은 꺼진 상태입니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>입력 파일 형식을 UTF-16BE로 가정합니다.</p>
|
||||
|
||||
<p>이 옵션은 <code>-ul</code>과 동일한 동작을 수행합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>자세한 메시지를 표시합니다. 추가로, 바이트 순서 표시 세부정보가 나타나며 변환 개행 문자가 나타납니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>심볼릭 링크를 따라가서 대상을 변환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>심볼릭 링크를 변환 파일로 바꿉니다(원시 대상 파일은 바뀌지 않은 상태로 둡니다).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>심볼릭 링크와 대상을 바뀌지 않게 그대로 둡니다 (기본 동작).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>버전 정보를 표시하고 나갑니다.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod5">맥 모드</h1>
|
||||
|
||||
<p>DOS 개행 문자와 유닉스 개행 문자를 서로 변환해주는 동작이 기본 동작이빈다. 맥 개행 문자는 변환하지 않습니다.</p>
|
||||
|
||||
<p>맥 모드에서 개행 문자를 맥에서 유닉스로, 내지는 그 반대로 변환합니다. DOS 개행 문자를 바꾸지 않습니다.</p>
|
||||
|
||||
<p>맥 모드를 실행하려면 <code>-c mac</code> 명령행 옵션을 사용하거나 <code>mac2unix</code> 명령 또는 <code>unix2mac</code> 명령을 사용하십시오.</p>
|
||||
|
||||
<h1 id="pod6">변환 모드</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>기본 변환 모드입니다. 이 모드는 아스키와 UTF-8과 같은 아스키 호환 인코딩 파일을 변환합니다. <b>ascii</b> 모드를 활성화하면 <b>7bit</b> 모드와 <b>iso</b> 모드를 사용하지 않습니다.</p>
|
||||
|
||||
<p>dos2unix에서 UTF-16을 지원하면 UTF-16 인코딩 파일을 POSIX 시스템의 현재 로캘 문자 인코딩과 윈도우의 UTF-8 인코딩으로 변환합니다. <b>ascii</b> 모드를 사용하면 UTF-16 인코딩 (<code>u</code>)을 유지하는 옵션과 UTF-16 입력(<code>-ul</code> 및 <code>-ub</code>)을 가정하는 옵션 값을 사용하지 않습니다. dos2unix에 UTF-16 을 지원하는지 알아보려면 <code>dos2unix -V</code>를 입력하십시오. 유니코드 섹션도 살펴보십시오.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>이 모드에서는 아스키 영역 밖(128~255 값)의 모든 8비트 문자를 7비트 영역으로 변환합니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS 문자 세트(코드 페이지)에서 유닉스 ISO 문자 세트 ISO-8859-1(Latin1)로 또는 그 반대로 문자를 변환합니다. ISO-8859-1에 대응하지 않는 DOS 문자는 변환할 수 없어 구두점으로 변환합니다. ISO-8859-1에서 DOS 문자 세트로 변환할 때도 마찬가지입니다.</p>
|
||||
|
||||
<p>dos2unix에 <code>-iso</code>옵션만 사용했을 경우 활성 코드 페이지 확인을 시도합니다. 불가능하다면 dos2unix는 미합중국에서 주로 사용하는 CP437 기본 코드 페이지를 사용합니다. 코드 페이지를 강제로 지정하려면 <code>-437</code> (US), <code>-850</code> (서유럽어), <code>-860</code> (포르투갈어), <code>-863</code> (캐나다 프랑스어), <code>-865</code> (북유럽어) 옵션 중 하나를 사용하십시오. 윈도우 코드 페이지 CP1252 (서유럽어)는 <code>-1252</code> 옵션으로 지원합니다. 다른 코드 페이지를 활용하려면 dos2unix와 iconv(1)를 함께 사용하십시오. iconv는 다양한 문자 인코딩을 변환할 수 있습니다.</p>
|
||||
|
||||
<p>유니코드 텍스트 파일을 ISO 방식으로 변환하지 마십시오. UTF-8 인코딩 파일이 깨집니다.</p>
|
||||
|
||||
<p>일부 예제:</p>
|
||||
|
||||
<p>DOS 기본 코드 페이지에서 유닉스 Latin-1으로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>DOS CP850에서 유닉스 Latin-1으로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>윈도우 CP1252에서 유닉스 Latin-1으로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>윈도우 CP1252에서 유닉스 UTF-8(유니코드)로 변환:</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt</code></pre>
|
||||
|
||||
<p>유닉스 Latin-1에서 DOS 기본 코드 페이지로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>유닉스 Latin-1에서 DOS CP850으로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>유닉스 Latin-1에서 윈도우 CP1252로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>유닉스 UTF-8(유니코드)에서 윈도우 CP1252로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt</code></pre>
|
||||
|
||||
<p><a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> 링크와 <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a> 링크도 참고하십시오.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod7">유니코드</h1>
|
||||
|
||||
<h2 id="pod8">인코딩</h2>
|
||||
|
||||
<p>제각기 다른 유니코드 인코딩이 있습니다. 유닉스와 리눅스 유니코드 파일은 보통 UTF-8 인코딩 방식으로 인코딩합니다. 윈도우에서는 유니코드 텍스트 파일을 UTF-8, UTF-16, UTF-16 빅엔디언 방식으로 인코딩할 수 있지만 대부분 UTF-16 형식으로 인코딩합니다.</p>
|
||||
|
||||
<h2 id="pod9">변환</h2>
|
||||
|
||||
<p>유니코드 텍스트 파일에는 DOS, 유닉스, 맥 개행 문자를 아스키 텍스트 파일처럼 가질 수 있습니다.</p>
|
||||
|
||||
<p>dos2unix와 unix2dos의 모든 버전에서는 UTF-8이 아스키와의 하위 호환성을 고려했기 때문에 UTF-8 인코딩 파일을 변환할 수 있습니다.</p>
|
||||
|
||||
<p>유니코드 UTF-16을 지원하는 dos2unix와 unix2dos는 UTF-16 리틀엔디언 및 빅엔디언 인코딩 텍스트 파일을 모두 읽을 수 있습니다. dos2unix에 UTF-16 지원 기능이 들어갔는지 확인하려면 <code>dos2unix -V</code> 명령을 입력하십시오.</p>
|
||||
|
||||
<p>유닉스/리눅스에서 UTF-16 인코딩 파일은 로캘 문자 인코딩으로 변환합니다. 어떤 로캘 문자 인코딩을 사용했는지 확인하려면 locale(1) 명령을 사용하십시오. 변환이 불가능할 경우 변환 오류가 나타나며, 해당 파일을 건너뜁니다.</p>
|
||||
|
||||
<p>윈도우에서 UTF-16 파일은 기본적으로 UTF-8로 변환합니다. UTF-8 형식 텍스트 파일은 윈도우, 유닉스, 리눅스에서 잘 읽힙니다.</p>
|
||||
|
||||
<p>UTF-16과 UTF-8 인코딩은 완전한 호환 관계이며, 변환 과정에 잃을 내용은 없습니다. UTF-16에서 UTF-8로 변환하던 중 오류가 나타났다면, 예를 들어 UTF-16 파일에 오류가 있다면, 해당 파일을 건너뜁니다.</p>
|
||||
|
||||
<p><code>-u</code> 옵션을 사용하면 입력 파일의 UTF-16 인코딩을 출력 파일에도 그대로 적용합니다. <code>-u</code> 옵션은 UTF-8로의 변환을 막습니다.</p>
|
||||
|
||||
<p>dos2unix와 unix2dos에는 UTF-8 파일을 UTF-16으로 변환하는 옵션이 없습니다.</p>
|
||||
|
||||
<p>ISO 및 7비트 모드 변환은 UTF-16 파일에 동작하지 않습니다.</p>
|
||||
|
||||
<h2 id="BOM">바이트 순서 표시(BOM)</h2>
|
||||
|
||||
<p>윈도우에서는 유니코드 텍스트 파일에 대부분 윈도우 프로그램(메모장 포함)에서 BOM을 기본으로 추가하기 때문에 보통 바이트 순서 표시(BOM)가 들어갑니다. <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a> 링크를 참고하십시오.</p>
|
||||
|
||||
<p>유닉스에서는 유니코드 파일에 BOM이 들어가지 않습니다. 텍스트 파일을 로캘 문자 인코딩으로 인코딩했다고 가정합니다.</p>
|
||||
|
||||
<p>dos2unix는 UTF-16 형식인지, BOM이 들어갔는지만 알 수 있습니다. UTF-16 파일에 BOM이 없다면 dos2unix는 이진 파일로 인식합니다.</p>
|
||||
|
||||
<p>UTF-16 파일을 BOM을 빼고 변환하려면 <code>-ul</code> 옵션 또는 <code>-ub</code> 옵션을 사용하십시오.</p>
|
||||
|
||||
<p>dos2unix에서는 기본적으로 출력 파일에 BOM을 기록하지 않습니다. 입력 파일에 BOM이 있다면 dos2unix에 <code>-b</code> 옵션을 지정했을 때 출력 파일에 BOM을 기록합니다.</p>
|
||||
|
||||
<p>unix2dos에서는 기본적으로 입력 파일에 BOM이 있다면 출력 파일에 BOM을 기록합니다. BOM을 제거하려면 <code>-r</code> 옵션을 사용하십시오.</p>
|
||||
|
||||
<p>dos2unix와 unix2dos에서 <code>-m</code> 옵션을 사용하면 항상 BOM을 기록합니다.</p>
|
||||
|
||||
<h2 id="pod10">윈도우의 유니코드 파일 이름</h2>
|
||||
|
||||
<p>dos2unix에서는 윈도우 명령 프롬프트의 유니코드 파일 이름을 읽고 쓰는 추가 기능을 지원합니다. dos2unix에서 기본 시스템 ANSI 코드 페이지의 일부가 아닌 문자가 들어간 이름일지라도 파일을 열 수 있다는 뜻입니다. 윈도우용 dos2unix에 유니코드 파일 이름 지원 기능이 들어있는지 확인하려면 <code>dos2unix -V</code> 명령을 입력하십시오.</p>
|
||||
|
||||
<p>윈도우 콘솔에 유니코드 파일 이름을 표시할 때 몇가지 문제가 있습니다. <code>-D</code>, <code>--display-enc</code> 옵션을 참고하십시오. 콘솔에서 파일 이름이 잘못 나타날 수는 있지만 파일은 (어쨌든) 올바른 이름으로 기록합니다.</p>
|
||||
|
||||
<h2 id="pod11">유니코드 예제</h2>
|
||||
|
||||
<p>윈도우 UTF-16(+BOM)을 유닉스 UTF-8로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>윈도우 UTF-16LE(-BOM)를 유닉스 UTF-8로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>유닉스 UTF-8을 윈도우 UTF-8(+BOM)로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>유닉스 UTF-8을 윈도우 UTF-16으로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030은 중화인민공화국 정부 표준입니다. GB18030 표준 하위 필수 세트는 중화인민공화국에서 판매하는 모든 프로그램 제품에 공식적으로 필요합니다. <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a> 링크를 참고하십시오.</p>
|
||||
|
||||
<p>GB18030은 유니코드와 완벽하게 호환하며, 유니코드 변환 형식으로 고려할 수 있습니다. UTF-8과 유사하게, GB18030은 아스키와 호환성을 지닙니다. GB18030은 또한 GBK로 알려진 윈도우 코드 페이지 936과도 호환성이 있습니다.</p>
|
||||
|
||||
<p>유닉스/리눅스에서 UTF-16 파일은 로캘 인코딩을 GB18030으로 설정하면 GB18030으로 변환합니다. 참고로 시스템에서 해당 로캘을 지원할 경우에만 동작합니다. 지원 로캘 목록을 살펴보려면 <code>locale -a</code> 명령을 사용하십시오.</p>
|
||||
|
||||
<p>윈도우에서는 UTF-16 파일을 GB18030으로 변환하려면 <code>-gb</code> 옵션을 사용해야합니다.</p>
|
||||
|
||||
<p>GB18030 인코딩 파일에는 유니코드 파일처럼 바이트 순서 표시가 들어갈 수 있습니다.</p>
|
||||
|
||||
<h1 id="pod12">예제</h1>
|
||||
|
||||
<p>'표준 입력'을 읽어 '표준 출력'에 출력:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>a.txt를 변환하고 내용 바꾸기. b.txt를 변환하고 내용 바꾸기:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>a.txt를 아스키 변환 모드로 변환하고 내용 바꾸기:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>a.txt를 아스키 변환 모드로 변환하고 내용 바꾸기, b.txt를 7비트 변환 모드로 변환하고 내용 바꾸기:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>a.txt를 맥 형식에서 유닉스 형식으로 변환:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>a.txt를 유닉스 형시에서 맥 형식으로 변환:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>a.txt의 날짜 스탬프를 유지하며 변환하고 내용 바꾸기:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>a.txt를 변환하여 e.txt로 기록:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>a.txt를 변환하고 e.txt로 기록, e.txt의 날짜 스탬프를 a.txt와 동일하게 설정:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>a.txt를 변환하고 내용 바꾸기, b.txt를 변환하고 e.txt에 기록:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>a.txt를 변환하여 e.txt로 기록, a.txt를 변환하고 내용 바꾸기, b.txt를 변환하고 내용 바꾸기, d.txt를 변환하고 f.txt로 기록:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="pod13">재귀 변환</h1>
|
||||
|
||||
<p>유닉스 셸에서 dos2unix로 하여금 디렉터리 트리의 모든 텍스트 파일을 재귀적으로 탐색하여 처리하려 할 때, find(1)와 xargs(1) 명령을 사용할 수 있습니다. 예를 들어 아래 형태를 갖춘 디렉터리 트리의 모든 .txt 파일을 변환하려면:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>find(1) 명령의 옵션 <code>-print0</code> 그리고 이에 해당하는 xargs(1) 명령의 <code>-0</code>옵션은 이름에 공백이나 따옴표가 있을 경우 필요합니다. 공백이나 따옴표가 없으면 이 옵션을 생략할 수 있습니다. 다른 옵션으로는 find(1)의 <code>-exec</code> 옵션이 있습니다:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>윈도우 명령 프롬프트에서 다음 명령을 활용할 수 없습니다:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>파워셸 사용자는 윈도우 파워셸에서 다음 명령을 활용할 수 있습니다:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="pod14">지역화</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>기본 언어는 LANG 환경 변수로 선택합니다. LANG 환경 변수는 몇가지 부분으로 구성합니다. 첫번째 부분은 언어 코드를 의미하는 몇가지 문자입니다. 두번제 부분은 대문자로 이루어진 국가 코드입니다. 두 코드 사이에는 밑줄 문자가 들어갑니다. 마지막으로 추가하는 부분은 점이 앞서 오는 문자 인코딩입니다. POSIX 표준 형 셸에서 몇가지 예제를 보여드리도록 하겠습니다:</p>
|
||||
|
||||
<pre><code>export LANG=nl Dutch
|
||||
export LANG=nl_NL Dutch, The Netherlands
|
||||
export LANG=nl_BE Dutch, Belgium
|
||||
export LANG=es_ES Spanish, Spain
|
||||
export LANG=es_MX Spanish, Mexico
|
||||
export LANG=en_US.iso88591 English, USA, Latin-1 encoding
|
||||
export LANG=en_GB.UTF-8 English, UK, UTF-8 encoding</code></pre>
|
||||
|
||||
<p>언어 및 국가 코드 전체 목록을 보려면 <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a> gettext 설명서를 참고하십시오</p>
|
||||
|
||||
<p>유닉스 시스템에서는 locale(1) 명령을 활용하여 로캘별 정보를 가져올 수 있습니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>LANGUAGE 환경 변수에는 언어를 우선 순위별로 콜론으로 구분하여 지정할 수 있습니다. dos2unix에서는 LANGUAGE를 LANG보다 우선 취급합니다. 예를 들면 네덜란드어를 먼저 그 다음에 독일어를 설정할 경우 <code>LANGUAGE=nl:de</code>(으)로 설정합니다. LANGUAGE 환경 변수에 언어별 우선 순위를 두어 사용할 수 있기 전에 LANG 환경 변수 (또는 LC_ALL)에 "C" 대신 다른 값을 넣어 지역화를 우선 설정해야합니다. <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a> gettext 설명서도 참고하십시오</p>
|
||||
|
||||
<p>사용할 수 없는 언어를 선택했다면 표준 (국제) 영어 메시지로 나타납니다.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS2UNIX_LOCALEDIR 환경 변수는, 컴파일 시간에는 LOCALEDIR 환경 변수를 우선 활용할 수 있습니다. LOCALEDIR 환경 변수는 언어 파일을 찾을 때 활용합니다. GNU 기본값은 <code>/usr/local/share/locale</code>입니다. <b>--version</b> 옵션을 사용하면 LOCALEDIR이 사용하는 값을 보여줍니다.</p>
|
||||
|
||||
<p>예제 (POSIX 셸):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod15">반환 값</h1>
|
||||
|
||||
<p>성공하면 0값을 반환합니다. 시스템 오류가 나타나면 가장 마지막에 나타난 시스템 오류를 반환합니다. 다른 오류는 1 값을 반환합니다.</p>
|
||||
|
||||
<p>미출력 모드의 반환 값은 항상 0이지만, 명령행 옵션이 잘못됐을 경우는 제외합니다.</p>
|
||||
|
||||
<h1 id="pod16">표준</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="pod17">저자</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (maintainer)</p>
|
||||
|
||||
<p>프로젝트 페이지: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge 페이지: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="pod18">추가 참조</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
678
Agent-Windows/OGP64/usr/share/doc/dos2unix/ko/dos2unix.txt
Normal file
678
Agent-Windows/OGP64/usr/share/doc/dos2unix/ko/dos2unix.txt
Normal file
|
|
@ -0,0 +1,678 @@
|
|||
이름
|
||||
dos2unix - DOS/맥 에서 유닉스로, 내지는 그 반대로의 텍스트 파일 형식 변환 프로그램
|
||||
|
||||
개요
|
||||
dos2unix [<옵션>] [<파일> ...] [-n <입력파일> <출력파일> ...]
|
||||
unix2dos [<옵션>] [<파일> ...] [-n <입력파일> <출력파일> ...]
|
||||
|
||||
설명
|
||||
dos2unix 패키지에는 DOS 또는 맥 형식을 유닉스 형식으로, 내지는 그 반대로 원시 텍스트 파일을 변환하는
|
||||
"dos2unix" 유틸리티와 "unix2dos" 유틸리티가 들어있습니다.
|
||||
|
||||
DOS/윈도우 텍스트 개행 문자는 캐리지 리턴(CR)과 뒤따라오는 라인 피드(LF) 문자를 결합한 형태를 취합니다. 유닉스 텍스트
|
||||
파일의 개행문자는 라인 피드(LF) 하나 뿐입니다. Mac OS X 이전의 맥 텍스트 파일은 캐리지 리턴(CR) 문자 하나
|
||||
뿐이었습니다. 그러나 지금은 Mac OS에서도 유닉스 방식 (LF) 개행 문자를 취합니다.
|
||||
|
||||
개행 문자 관련하여 dos2unix에서는 파일 인코딩도 변환할 수 있습니다. 일부 DOS 코드 페이지는 유닉스 Latin-1
|
||||
인코딩으로 변환할 수 있습니다. 그리고 윈도우 유니코드 (UTF-16) 파일은 유닉스 유니코드 (UTF-8) 파일로 변환할 수
|
||||
있습니다.
|
||||
|
||||
이진 파일은 변환을 강제하지 않는 한 자동으로 건너뜁니다.
|
||||
|
||||
디렉터리와 FIFO 같은 일반 파일 외 요소는 자동으로 건너뜁니다.
|
||||
|
||||
심볼릭 링크와 대상은 보통 (완전히) 연결한 상태가 아닙니다. 심볼릭 링크는 별도로 바꿀 수 있거나, 심볼릭 링크 대상으로 기록할
|
||||
수 있습니다. 심볼릭 링크 대상 기록은 윈도우에서 지원하지 않습니다.
|
||||
|
||||
dos2unix는 SunOS/솔라리스의 dos2unix가 나온 후 구성한 모델입니다. SunOS/솔라리스 버전과 한가지 중요한
|
||||
차이가 있습니다. SunOS/솔라리스 버전은 페어링 변환(새 파일 모드)만 지원하지만, 이 버전은 자체 변환(이전 파일 모드)도
|
||||
지원합니다. "-o", "-n" 옵션도 참고하십시오. 다른 차이점이 있다면 SunOS/솔라리스 버전은 *iso* 모드 변환이
|
||||
기본이지만 이 버전은 *ascii* 모드 변환이 기본입니다.
|
||||
|
||||
옵션
|
||||
-- 뒤따라오는 모든 옵션은 파일 이름으로 간주합니다. 대시 문자로 시작하는 이름을 가진 파일을 변환하려면 이 옵션을
|
||||
사용하십시오. 예를 들어 "-foo" 파일을 변환할 경우, 다음 명령을 사용할 수 있습니다:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
또는 새 파일 모드에서:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
이전 파일 모드의 파일 소유권을 바꿀 수 있게 합니다.
|
||||
|
||||
이 옵션을 사용하면 이전 파일의 사용자 또는 그룹 소유권을 유지할 수 없을 때 변환을 멈추지 않습니다. 새 파일의 모드로
|
||||
변환할 때 처럼 동일하게 변환한 파일에 새 소유권을 부여하면서 변환을 계속합니다. "-o", "-n" 옵션도 참고하십시오.
|
||||
이 옵션은 dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능이 있을 경우에만 사용할 수 있습니다.
|
||||
|
||||
-ascii
|
||||
기본 변환 모드입니다. 변환 모드 섹션을 참고하십시오.
|
||||
|
||||
-iso
|
||||
DOS와 ISO-8859-1 문자 세트 변환을 진행합니다. 변환 모드 섹션을 참고하십시오.
|
||||
|
||||
-1252
|
||||
윈도우 코드 페이지 1252(서유럽어)를 활용합니다.
|
||||
|
||||
-437
|
||||
DOS 코드 페이지 437(미합중국)을 활용합니다. ISO 변환시 기본 코드 페이지로 활용합니다.
|
||||
|
||||
-850
|
||||
DOS 코드 페이지 850(서유럽어)을 활용합니다.
|
||||
|
||||
-860
|
||||
DOS 코드 페이지 860(포르투갈어)을 활용합니다.
|
||||
|
||||
-863
|
||||
DOS 코드 페이지 863(캐나다 프랑스어)을 활용합니다.
|
||||
|
||||
-865
|
||||
DOS 코드 페이지 865(북유럽어)를 활용합니다.
|
||||
|
||||
-7 8비트 문자를 7비트 영역으로 변환합니다.
|
||||
|
||||
-b, --keep-bom
|
||||
바이트 순서 표시(BOM)를 유지합니다. 입력 파일에 BOM이 들어있다면, 출력 파일에 BOM을 기록합니다. DOS 개행
|
||||
문자를 변환할 때 기본 동작입니다. "-r"옵션 정보도 참고하십시오.
|
||||
|
||||
-c, --convmode <변환모드>
|
||||
변환 모드를 설정합니다. <변환모드>는 *ascii*, *7bit*, *iso*, *mac* 값 중 하나이며 ascii가
|
||||
기본값입니다.
|
||||
|
||||
-D, --display-enc <인코딩>
|
||||
표시 텍스트 인코딩을 설정합니다. <인코딩>은 *ansi*, *unicode*, *unicodebom*, *utf8*,
|
||||
*utf8bom* 값 중 하나이며, ansi가 기본값입니다.
|
||||
|
||||
이 옵션은 유니코드 파일 이름을 지원하는 윈도우용 dos2unix에서만 사용할 수 있습니다. 이 옵션은 실제 파일 이름을
|
||||
읽고 쓰는데 아무런 영향을 주지 않으며, 어떻게 나타내는 지에 대해서만 영향을 줍니다.
|
||||
|
||||
텍스트 인코딩 기반으로 윈도우 콘솔에서 텍스트를 나타내는 방법에는 여러가지가 있습니다. 각 방법에는 고유의 장점과 단점이
|
||||
있습니다.
|
||||
|
||||
ansi
|
||||
dos2unix의 기본 방식은 ANSI 인코딩 텍스트를 활용하는 방법입니다. 하위 호환성이 장점입니다. 래스터 및
|
||||
트루타입 글꼴에 동작합니다. 일부 국가에서는 dos2unix에서 윈도우 시스템 코드 페이지를 사용하기 때문에
|
||||
"chcp" 명령으로 윈도우 시스템 ANSI 코드 페이지로 DOS OEM 활성 코드 페이지를 바꾸어야 합니다.
|
||||
|
||||
ANSI 방식의 단점은 국제어 파일 이름이 시스템 기본 코드 페이지에 들어있지 않아 제대로 화면에 나타나지
|
||||
않습니다. 물음표 기호 또는 잘못된 기호가 대신 나타날 수 있습니다. 타 언어 파일 이름으로 동작하지 않는다면 이
|
||||
방식이 괜찮습니다.
|
||||
|
||||
unicode, unicodebom
|
||||
유니코드(UTF-16의 윈도우 이름) 인코딩의 장점이란 텍스트가 보통 제대로 나타난다는 점입니다. 활성 코드
|
||||
페이지를 바꿀 필요는 없습니다. 콘솔의 전세계 문자가 제대로 나타나려면 트루타입 글꼴을 선택해야합니다. 문자가
|
||||
트루타입 글꼴 세트에 들어있지 않으면 작은 사각형 모양을 볼 수 있으며, 때로는 물음표로 나타나기도 합니다.
|
||||
|
||||
ConEmu 콘솔을 사용한다면 ConEmu에서 적절한 글꼴을 자동으로 선택하므로 모든 텍스트가 제대로 나타납니다.
|
||||
|
||||
유니코드 사용의 단점은 아스키와 호환성이 없다는 점입니다. 다른 프로그램으로 출력을 전달할 때 쉽게 처리할 수
|
||||
없습니다.
|
||||
|
||||
"unicodebom" 방식을 사용하면 BOM(바이트 순서 표시)을 텍스트 앞에 둡니다. BOM은 파워셸에서 출력
|
||||
내용을 올바르게 전달 또는 파이핑할 때 필요합니다.
|
||||
|
||||
utf8, utf8bom
|
||||
utf8의 장점은 아스키와의 호환성입니다. 콘솔의 글꼴을 트루타입 글꼴로 선택해야 합니다. 트루타입 글꼴로 설정하면
|
||||
"unicode" 인코딩 때와 비슷하게 나타납니다.
|
||||
|
||||
단점은 래스터 글꼴을 기본으로 사용하면 아스키 인코딩을 하지 않는 문자를 잘못 나타낼 수 있습니다. 유니코드 파일
|
||||
이름 뿐만 아니라 번역 메시지 조차 제대로 읽을 수 없습니다. 윈도우에서는 동아시아 지역으로 설정했을 경우 메시지가
|
||||
나타날 때 콘솔 화면이 상당히 많이 깜빡거리는걸 볼 수 있습니다.
|
||||
|
||||
ConEmu 콘솔에서는 utf8 인코딩이 제대로 동작합니다.
|
||||
|
||||
"utf8bom" 방식을 사용하면 UTF-8 텍스트 앞에 BOM(바이트 순서 표시)를 둡니다. BOM은 파워셸에서
|
||||
출력 내용을 올바르게 전달 또는 파이핑할 때 필요합니다.
|
||||
|
||||
기본 인코딩은 DOS2UNIX_DISPLAY_ENC 환경 변수를 "unicode", "unicodebom", "utf8",
|
||||
"utf8bom" 중 값 하나로 설정하여 바꿀 수 있습니다.
|
||||
|
||||
-e, --add-eol
|
||||
개행 문자가 줄 끝에 없을 경우 추가합니다. 모든 변환 과정에서 동작합니다.
|
||||
|
||||
DOS 형식에서 유닉스 형식으로 변환한 파일의 행 끝에 개행 문자가 빠질 수도 있습니다. 행 끝에 개행 문자가 빠진 채로
|
||||
텍스트 파일을 기록하는 텍스트 편집기가 있습니다. 텍스트 파일의 모든 줄 끝에 반드시 개행 문자로 끝나야 하는게 POSIX
|
||||
표준이기에, 일부 유닉스 프로그램에서는 이 파일을 처리하는 문제가 있습니다. 예를 들면, 파일 내용을 합칠 때 예상한 대로
|
||||
결과가 나타나지 않습니다.
|
||||
|
||||
--error-binary
|
||||
이진 파일을 건너뛸 때 오류를 반환합니다.
|
||||
|
||||
-f, --force
|
||||
강제로 이진 파일을 변환합니다.
|
||||
|
||||
-gb, --gb18030
|
||||
윈도우에서는 로캘 설정 여부와 관계 없이 UTF-16 파일이 기본이기에 UTF-8로 변환합니다. 이 옵션을 사용하면
|
||||
UTF-16 파일을 GB18030으로 변환합니다. 이 옵션은 윈도우에서만 사용할 수 있습니다. GB18030 섹션을
|
||||
참고하십시오.
|
||||
|
||||
-h, --help
|
||||
도움말을 표시하고 나갑니다.
|
||||
|
||||
-i[<플래그>], --info[=<플래그>] <파일> ...
|
||||
파일 정보를 표시합니다. 변환 동작은 하지 않습니다.
|
||||
|
||||
다음 정보를 DOS 개행 문자 수, 유닉스 개행 문자 수, 맥 개행 문자 수, 바이트 순서 표시, 텍스트 또는 이진 파일
|
||||
여부, 파일 이름 순으로 정보를 출력합니다.
|
||||
|
||||
예제 출력:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
때로는 이진 파일을 텍스트 파일로 잘못 알아챌 수도 있습니다. "-s" 옵션도 참고하십시오.
|
||||
|
||||
"-e" 또는 "--add-eol" 옵션을 추가로 사용하면 행 마지막 개행 문자 형식도 출력하며, 없다면 "noeol"을
|
||||
출력합니다.
|
||||
|
||||
예제 출력:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
출력 방식을 바꿀 추가 플래그를 설정할 수 있습니다. 플래그 하나 이상을 추가할 수 있습니다.
|
||||
|
||||
0 파일 정보 행 끝의 개행 문자 대신 널 문자를 출력합니다. c 플래그를 사용할 때 공백 또는 따옴표로 파일 이름
|
||||
해석을 올바르게 할 수 있습니다. 이 플래그는 xargs(1) 옵션 -0 또는 "--null"을 함께 사용하십시오.
|
||||
|
||||
d DOS 개행 문자를 출력합니다.
|
||||
|
||||
u 유닉스 개행 문자를 출력합니다.
|
||||
|
||||
m 맥 개행 문자를 출력합니다.
|
||||
|
||||
b 바이트 순서 표시를 출력합니다.
|
||||
|
||||
t 파일의 텍스트 또는 이진 여부를 출력합니다.
|
||||
|
||||
e 행 마지막에 개행 문자 형식을 출력하거나, 없을 경우 "noeol"을 출력합니다.
|
||||
|
||||
c 변환할 파일만 출력합니다.
|
||||
|
||||
dos2unix에 "c" 플래그를 사용하면 DOS 개행 문자가 들어간 파일만 출력합니다. unix2dos는 유닉스
|
||||
개행 문자가 들어간 파일 이름만 출력합니다.
|
||||
|
||||
"-e" 또는 "--add-eol" 옵션을 추가로 사용하면 행 마지막에 빠진 개행 문자를 출력합니다.
|
||||
|
||||
h 헤더를 출력합니다.
|
||||
|
||||
p 경로를 뺀 파일 이름을 나타냅니다.
|
||||
|
||||
예제:
|
||||
|
||||
모든 *.txt 파일 정보 출력:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
DOS 개행 문자와 유닉스 개행 문자 갯수만 출력:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
바이트 순서 표시만 나타내기:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
DOS 개행 문자가 들어간 파일 목록 출력:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
유닉스 개행 문자가 들어간 파일 목록 출력:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
DOS 개행 문자가 들어갔거나 행 마지막에 개행 문자가 빠진 파일 목록 출력:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
DOS 개행 문자가 들어간 파일만 변환하며 다른 파일은 건드리지 않습니다:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
DOS 개행 문자가 들어간 텍스트 파일 찾기:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
출력 파일의 날짜 스탬프는 입력 파일과 동일하게 설정합니다.
|
||||
|
||||
-L, --license
|
||||
프로그램 라이선스를 표시합니다.
|
||||
|
||||
-l, --newline
|
||||
부가 개행 문자를 추가합니다.
|
||||
|
||||
dos2unix: DOS 개행 문자만을 유닉스 개행 문자 둘로 변환합니다. 맥 모드에서는 맥 개행 문자만을 유닉스 개행
|
||||
문자 둘로 변환합니다.
|
||||
|
||||
unix2dos: 유닉스 개행 문자만을 DOS 개행 문자 둘로 변환합니다. 맥 모드에서는 유닉스 개행 문자를 맥 개행 문자
|
||||
둘로 변환합니다.
|
||||
|
||||
-m, --add-bom
|
||||
바이트 순서 표시(BOM)를 출력 파일에 기록합니다. 기본적으로 UTF-8 BOM을 기록합니다.
|
||||
|
||||
입력 파일 인코딩이 UTF-16이고 "-u" 옵션을 사용했다면 UTF-16 BOM을 기록합니다.
|
||||
|
||||
출력 인코딩이 UTF-8, UTF-16, GB18030이 아니라면 이 옵션을 사용하지 마십시오. 유니코드 섹션도
|
||||
참고하십시오.
|
||||
|
||||
-n, --newfile <입력파일> <출력파일> ...
|
||||
새 파일 모드입니다. <입력파일>을 변환하여 <출력파일>에 기록합니다. 파일 이름은 짝으로 지정하며 와일드카드 이름은
|
||||
사용하지 *말아야* 하며, 그렇지 않으면 파일을 *잃습니다*.
|
||||
|
||||
새 파일(짝)모드로 파일 변환을 시작한 사용자는 변환한 파일의 소유자가 됩니다. 새 파일의 읽기/쓰기 권한은 변환을 실행한
|
||||
사용자의 umask(1)를 뺀 원본 파일의 권한으로 부여합니다.
|
||||
|
||||
--no-allow-chown
|
||||
이전 파일 모드의 파일 소유권 변경을 허용하지 않습니다(기본 동작).
|
||||
|
||||
원본 파일의 사용자 또는 그룹 소유권을 이전 파일 모드에서 유지할 수 없다면 변환을 멈춥니다. "-o", "-n" 옵션도
|
||||
참고하십시오. 이 옵션은 dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능이 있을 경우에만 사용할 수
|
||||
있습니다.
|
||||
|
||||
--no-add-eol
|
||||
개행 문자가 줄 끝에 없을 경우 넣지 않습니다(기본 동작).
|
||||
|
||||
--no-error-binary
|
||||
이진 파일을 건너뛸 때 오류를 반환하지 않습니다(기본 동작).
|
||||
|
||||
-O, --to-stdout
|
||||
유닉스 필터 동작과 비슷하게 표준 출력에 기록합니다. 이전 파일(기록) 모드로 돌아가려면 "-o" 옵션을 사용합니다.
|
||||
|
||||
"-e" 옵션을 붙여 결합한 파일은 제대로 내용을 합칠 수 있습니다. 마지막 줄과 첫줄은 병합하지 않으며, 결합한 파일
|
||||
내용 중간에 들어있는 유니코드 바이트 순서 표시는 들어가지 않습니다. 예를 들면:
|
||||
|
||||
dos2unix -e -O file1.txt file2.txt > output.txt
|
||||
|
||||
-o, --oldfile <파일> ...
|
||||
이전 파일 모드. <파일>을 변환하고 출력을 <파일>에 덮어씁니다. 이 모드로의 실행이 프로그램 기본 동작입니다.
|
||||
와일드카드 이름을 사용할 수도 있습니다.
|
||||
|
||||
이전 파일(자체 변환)모드에서 변환한 파일은 동일한 소유자, 그룹, 읽기 쓰기 권한을 원본 파일과 동일하게 유지합니다.
|
||||
게다가 쓰기 권한이 있는 다른 사용자(예를 들어, root)가 파일을 변환했다 하더라도 마찬가지입니다. 원본 값을 그대로
|
||||
유지할 수 없을 경우에는 변환을 멈춥니다. 소유권 변경이 가능하단건 곧 원본 소유자가 더이상 파일을 읽을 수 없음을
|
||||
의미합니다. 소유그룹 변경은 원하지 않는 사용자가 파일을 읽게 할 수 있어 보안 문제를 야기할 수 있습니다. 소유자,
|
||||
소유그룹, 읽기/쓰기 권한 유지는 유닉스에서만 지원합니다.
|
||||
|
||||
dos2unix에서 파일의 사용자 및 그룹 소유권을 유지하는 기능을 지원하는지 확인하려면 "dos2unix -V"를
|
||||
입력하십시오.
|
||||
|
||||
변환 동작은 항상 임시 파일로 처리합니다. 변환 과정 도중 오류가 발생하면, 임시 파일을 삭제하고 원본 파일을 그대로
|
||||
둡니다. 변환이 끝나면 원본 파일을 임시 파일로 바꿉니다. 실행한 사용자는 원본 파일의 쓰기 권한을 가지겠지만, 원본
|
||||
파일처럼 임시 파일에 사용자 또는 그룹 소유권을 동일하게 부여할 수는 없습니다. 즉, 원본 파일의 사용자 또는 그룹 권한을
|
||||
그대로 대상 파일에 설정할 수는 없단 뜻입니다. 이 경우 "--allow-chown" 옵션을 사용하여 변환을 계속할 수
|
||||
있습니다:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
다른 옵션은 새 파일 모드에서 사용합니다:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
"--allow-chown" 옵션의 장점은 와일드 카드를 사용할 수 있으며, 가능하다면 소유관 속성을 유지합니다.
|
||||
|
||||
-q, --quiet
|
||||
미 출력 모드. 모든 경고와 메시지를 끕니다. 반환 값은 0입니다. 잘못된 명령행 옵션을 사용했을 때는 이 경우에서
|
||||
제외합니다.
|
||||
|
||||
-r, --remove-bom
|
||||
바이트 순서 표시(BOM)를 제거합니다. BOM을 출력 파일에 기록하지 않습니다. 유닉스 개행 문자로 변환할 때 기본
|
||||
동작입니다. "-b" 옵션도 참고하십시오.
|
||||
|
||||
-s, --safe
|
||||
이진 파일은 건너뜁니다 (기본 동작).
|
||||
|
||||
이진 파일 건너뛰기는 갑작스런 실수를 피하는 동작입니다. 이진 파일 감시는 100% 실패 예방을 하지 않습니다. 입력
|
||||
파일에서 텍스트 파일에서 보통 찾을 수 없는 이진 심볼을 검색합니다. 이진 파일에도 일반 텍스트 문자만 들어있을 수
|
||||
있습니다. 이런 이진 파일 종류는 (그래서) 텍스트 파일로 실수로 알아챌 수 있습니다.
|
||||
|
||||
이진 파일을 건너뛸 때 오류 미반환이 기본 동작입니다. "--error-binary" 옵션을 사용하면 오류를 반환합니다.
|
||||
|
||||
-u, --keep-utf16
|
||||
입력 파일의 UTF-16 인코딩 원본을 유지합니다. 출력 파일은 동일한 UTF-16 인코딩을 리틀엔디언 또는 빅엔디언으로
|
||||
입력 파일과 같이 기록합니다. 이는 UTF-8로의 변환을 막습니다. UTF-16 BOM은 원본을 따라 대상에 기록합니다.
|
||||
이 옵션 동작은 "-ascii" 옵션으로 막을 수 있습니다.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
입력 파일 형식을 UTF-16LE로 가정합니다.
|
||||
|
||||
바이트 순서 표시가 입력 파일에 있다면 BOM은 이 옵션보다 우선순위를 갖습니다.
|
||||
|
||||
잘못된 가정(입력 파일이 UTF-16LE 형식이 아니라거나)하에 변환에 성공했다면, 잘못된 내용이 들어간 UTF-8 출력
|
||||
파일을 받을 수 있습니다. iconf(1) 명령을 활용하여 UTF-8 출력 파일을 UTF-16LE로 되돌려 변환하는
|
||||
방식으로 잘못된 변환 결과를 되돌릴 수 있습니다. 이런 방법으로 원본 파일을 되돌릴 수 있습니다.
|
||||
|
||||
UTF-16LE가 *변환 모드*로 동작한다고 가정해보겠습니다. 기본 *ascii* 모드로 전환하면 UTF-16LE에 대한
|
||||
가정은 꺼진 상태입니다.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
입력 파일 형식을 UTF-16BE로 가정합니다.
|
||||
|
||||
이 옵션은 "-ul"과 동일한 동작을 수행합니다.
|
||||
|
||||
-v, --verbose
|
||||
자세한 메시지를 표시합니다. 추가로, 바이트 순서 표시 세부정보가 나타나며 변환 개행 문자가 나타납니다.
|
||||
|
||||
-F, --follow-symlink
|
||||
심볼릭 링크를 따라가서 대상을 변환합니다.
|
||||
|
||||
-R, --replace-symlink
|
||||
심볼릭 링크를 변환 파일로 바꿉니다(원시 대상 파일은 바뀌지 않은 상태로 둡니다).
|
||||
|
||||
-S, --skip-symlink
|
||||
심볼릭 링크와 대상을 바뀌지 않게 그대로 둡니다 (기본 동작).
|
||||
|
||||
-V, --version
|
||||
버전 정보를 표시하고 나갑니다.
|
||||
|
||||
맥 모드
|
||||
DOS 개행 문자와 유닉스 개행 문자를 서로 변환해주는 동작이 기본 동작이빈다. 맥 개행 문자는 변환하지 않습니다.
|
||||
|
||||
맥 모드에서 개행 문자를 맥에서 유닉스로, 내지는 그 반대로 변환합니다. DOS 개행 문자를 바꾸지 않습니다.
|
||||
|
||||
맥 모드를 실행하려면 "-c mac" 명령행 옵션을 사용하거나 "mac2unix" 명령 또는 "unix2mac" 명령을
|
||||
사용하십시오.
|
||||
|
||||
변환 모드
|
||||
ascii
|
||||
기본 변환 모드입니다. 이 모드는 아스키와 UTF-8과 같은 아스키 호환 인코딩 파일을 변환합니다. ascii 모드를
|
||||
활성화하면 7bit 모드와 iso 모드를 사용하지 않습니다.
|
||||
|
||||
dos2unix에서 UTF-16을 지원하면 UTF-16 인코딩 파일을 POSIX 시스템의 현재 로캘 문자 인코딩과 윈도우의
|
||||
UTF-8 인코딩으로 변환합니다. ascii 모드를 사용하면 UTF-16 인코딩 ("u")을 유지하는 옵션과 UTF-16
|
||||
입력("-ul" 및 "-ub")을 가정하는 옵션 값을 사용하지 않습니다. dos2unix에 UTF-16 을 지원하는지
|
||||
알아보려면 "dos2unix -V"를 입력하십시오. 유니코드 섹션도 살펴보십시오.
|
||||
|
||||
7bit
|
||||
이 모드에서는 아스키 영역 밖(128~255 값)의 모든 8비트 문자를 7비트 영역으로 변환합니다.
|
||||
|
||||
iso DOS 문자 세트(코드 페이지)에서 유닉스 ISO 문자 세트 ISO-8859-1(Latin1)로 또는 그 반대로 문자를
|
||||
변환합니다. ISO-8859-1에 대응하지 않는 DOS 문자는 변환할 수 없어 구두점으로 변환합니다.
|
||||
ISO-8859-1에서 DOS 문자 세트로 변환할 때도 마찬가지입니다.
|
||||
|
||||
dos2unix에 "-iso"옵션만 사용했을 경우 활성 코드 페이지 확인을 시도합니다. 불가능하다면 dos2unix는
|
||||
미합중국에서 주로 사용하는 CP437 기본 코드 페이지를 사용합니다. 코드 페이지를 강제로 지정하려면 -437 (US),
|
||||
-850 (서유럽어), -860 (포르투갈어), -863 (캐나다 프랑스어), -865 (북유럽어) 옵션 중 하나를
|
||||
사용하십시오. 윈도우 코드 페이지 CP1252 (서유럽어)는 -1252 옵션으로 지원합니다. 다른 코드 페이지를 활용하려면
|
||||
dos2unix와 iconv(1)를 함께 사용하십시오. iconv는 다양한 문자 인코딩을 변환할 수 있습니다.
|
||||
|
||||
유니코드 텍스트 파일을 ISO 방식으로 변환하지 마십시오. UTF-8 인코딩 파일이 깨집니다.
|
||||
|
||||
일부 예제:
|
||||
|
||||
DOS 기본 코드 페이지에서 유닉스 Latin-1으로 변환:
|
||||
|
||||
dos2unix -iso -n in.txt out.txt
|
||||
|
||||
DOS CP850에서 유닉스 Latin-1으로 변환:
|
||||
|
||||
dos2unix -850 -n in.txt out.txt
|
||||
|
||||
윈도우 CP1252에서 유닉스 Latin-1으로 변환:
|
||||
|
||||
dos2unix -1252 -n in.txt out.txt
|
||||
|
||||
윈도우 CP1252에서 유닉스 UTF-8(유니코드)로 변환:
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
|
||||
|
||||
유닉스 Latin-1에서 DOS 기본 코드 페이지로 변환:
|
||||
|
||||
unix2dos -iso -n in.txt out.txt
|
||||
|
||||
유닉스 Latin-1에서 DOS CP850으로 변환:
|
||||
|
||||
unix2dos -850 -n in.txt out.txt
|
||||
|
||||
유닉스 Latin-1에서 윈도우 CP1252로 변환:
|
||||
|
||||
unix2dos -1252 -n in.txt out.txt
|
||||
|
||||
유닉스 UTF-8(유니코드)에서 윈도우 CP1252로 변환:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
|
||||
|
||||
<https://czyborra.com/charsets/codepages.html> 링크와
|
||||
<https://czyborra.com/charsets/iso8859.html> 링크도 참고하십시오.
|
||||
|
||||
유니코드
|
||||
인코딩
|
||||
제각기 다른 유니코드 인코딩이 있습니다. 유닉스와 리눅스 유니코드 파일은 보통 UTF-8 인코딩 방식으로 인코딩합니다.
|
||||
윈도우에서는 유니코드 텍스트 파일을 UTF-8, UTF-16, UTF-16 빅엔디언 방식으로 인코딩할 수 있지만 대부분
|
||||
UTF-16 형식으로 인코딩합니다.
|
||||
|
||||
변환
|
||||
유니코드 텍스트 파일에는 DOS, 유닉스, 맥 개행 문자를 아스키 텍스트 파일처럼 가질 수 있습니다.
|
||||
|
||||
dos2unix와 unix2dos의 모든 버전에서는 UTF-8이 아스키와의 하위 호환성을 고려했기 때문에 UTF-8 인코딩 파일을
|
||||
변환할 수 있습니다.
|
||||
|
||||
유니코드 UTF-16을 지원하는 dos2unix와 unix2dos는 UTF-16 리틀엔디언 및 빅엔디언 인코딩 텍스트 파일을 모두
|
||||
읽을 수 있습니다. dos2unix에 UTF-16 지원 기능이 들어갔는지 확인하려면 "dos2unix -V" 명령을 입력하십시오.
|
||||
|
||||
유닉스/리눅스에서 UTF-16 인코딩 파일은 로캘 문자 인코딩으로 변환합니다. 어떤 로캘 문자 인코딩을 사용했는지 확인하려면
|
||||
locale(1) 명령을 사용하십시오. 변환이 불가능할 경우 변환 오류가 나타나며, 해당 파일을 건너뜁니다.
|
||||
|
||||
윈도우에서 UTF-16 파일은 기본적으로 UTF-8로 변환합니다. UTF-8 형식 텍스트 파일은 윈도우, 유닉스, 리눅스에서 잘
|
||||
읽힙니다.
|
||||
|
||||
UTF-16과 UTF-8 인코딩은 완전한 호환 관계이며, 변환 과정에 잃을 내용은 없습니다. UTF-16에서 UTF-8로 변환하던
|
||||
중 오류가 나타났다면, 예를 들어 UTF-16 파일에 오류가 있다면, 해당 파일을 건너뜁니다.
|
||||
|
||||
"-u" 옵션을 사용하면 입력 파일의 UTF-16 인코딩을 출력 파일에도 그대로 적용합니다. "-u" 옵션은 UTF-8로의 변환을
|
||||
막습니다.
|
||||
|
||||
dos2unix와 unix2dos에는 UTF-8 파일을 UTF-16으로 변환하는 옵션이 없습니다.
|
||||
|
||||
ISO 및 7비트 모드 변환은 UTF-16 파일에 동작하지 않습니다.
|
||||
|
||||
바이트 순서 표시(BOM)
|
||||
윈도우에서는 유니코드 텍스트 파일에 대부분 윈도우 프로그램(메모장 포함)에서 BOM을 기본으로 추가하기 때문에 보통 바이트 순서
|
||||
표시(BOM)가 들어갑니다. <https://en.wikipedia.org/wiki/Byte_order_mark> 링크를
|
||||
참고하십시오.
|
||||
|
||||
유닉스에서는 유니코드 파일에 BOM이 들어가지 않습니다. 텍스트 파일을 로캘 문자 인코딩으로 인코딩했다고 가정합니다.
|
||||
|
||||
dos2unix는 UTF-16 형식인지, BOM이 들어갔는지만 알 수 있습니다. UTF-16 파일에 BOM이 없다면
|
||||
dos2unix는 이진 파일로 인식합니다.
|
||||
|
||||
UTF-16 파일을 BOM을 빼고 변환하려면 "-ul" 옵션 또는 "-ub" 옵션을 사용하십시오.
|
||||
|
||||
dos2unix에서는 기본적으로 출력 파일에 BOM을 기록하지 않습니다. 입력 파일에 BOM이 있다면 dos2unix에 "-b"
|
||||
옵션을 지정했을 때 출력 파일에 BOM을 기록합니다.
|
||||
|
||||
unix2dos에서는 기본적으로 입력 파일에 BOM이 있다면 출력 파일에 BOM을 기록합니다. BOM을 제거하려면 "-r" 옵션을
|
||||
사용하십시오.
|
||||
|
||||
dos2unix와 unix2dos에서 "-m" 옵션을 사용하면 항상 BOM을 기록합니다.
|
||||
|
||||
윈도우의 유니코드 파일 이름
|
||||
dos2unix에서는 윈도우 명령 프롬프트의 유니코드 파일 이름을 읽고 쓰는 추가 기능을 지원합니다. dos2unix에서 기본
|
||||
시스템 ANSI 코드 페이지의 일부가 아닌 문자가 들어간 이름일지라도 파일을 열 수 있다는 뜻입니다. 윈도우용 dos2unix에
|
||||
유니코드 파일 이름 지원 기능이 들어있는지 확인하려면 "dos2unix -V" 명령을 입력하십시오.
|
||||
|
||||
윈도우 콘솔에 유니코드 파일 이름을 표시할 때 몇가지 문제가 있습니다. "-D", "--display-enc" 옵션을
|
||||
참고하십시오. 콘솔에서 파일 이름이 잘못 나타날 수는 있지만 파일은 (어쨌든) 올바른 이름으로 기록합니다.
|
||||
|
||||
유니코드 예제
|
||||
윈도우 UTF-16(+BOM)을 유닉스 UTF-8로 변환:
|
||||
|
||||
dos2unix -n in.txt out.txt
|
||||
|
||||
윈도우 UTF-16LE(-BOM)를 유닉스 UTF-8로 변환:
|
||||
|
||||
dos2unix -ul -n in.txt out.txt
|
||||
|
||||
유닉스 UTF-8을 윈도우 UTF-8(+BOM)로 변환:
|
||||
|
||||
unix2dos -m -n in.txt out.txt
|
||||
|
||||
유닉스 UTF-8을 윈도우 UTF-16으로 변환:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
|
||||
|
||||
GB18030
|
||||
GB18030은 중화인민공화국 정부 표준입니다. GB18030 표준 하위 필수 세트는 중화인민공화국에서 판매하는 모든 프로그램
|
||||
제품에 공식적으로 필요합니다. <https://en.wikipedia.org/wiki/GB_18030> 링크를 참고하십시오.
|
||||
|
||||
GB18030은 유니코드와 완벽하게 호환하며, 유니코드 변환 형식으로 고려할 수 있습니다. UTF-8과 유사하게, GB18030은
|
||||
아스키와 호환성을 지닙니다. GB18030은 또한 GBK로 알려진 윈도우 코드 페이지 936과도 호환성이 있습니다.
|
||||
|
||||
유닉스/리눅스에서 UTF-16 파일은 로캘 인코딩을 GB18030으로 설정하면 GB18030으로 변환합니다. 참고로 시스템에서
|
||||
해당 로캘을 지원할 경우에만 동작합니다. 지원 로캘 목록을 살펴보려면 "locale -a" 명령을 사용하십시오.
|
||||
|
||||
윈도우에서는 UTF-16 파일을 GB18030으로 변환하려면 "-gb" 옵션을 사용해야합니다.
|
||||
|
||||
GB18030 인코딩 파일에는 유니코드 파일처럼 바이트 순서 표시가 들어갈 수 있습니다.
|
||||
|
||||
예제
|
||||
'표준 입력'을 읽어 '표준 출력'에 출력:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
a.txt를 변환하고 내용 바꾸기. b.txt를 변환하고 내용 바꾸기:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
a.txt를 아스키 변환 모드로 변환하고 내용 바꾸기:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
a.txt를 아스키 변환 모드로 변환하고 내용 바꾸기, b.txt를 7비트 변환 모드로 변환하고 내용 바꾸기:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
a.txt를 맥 형식에서 유닉스 형식으로 변환:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
a.txt를 유닉스 형시에서 맥 형식으로 변환:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
a.txt의 날짜 스탬프를 유지하며 변환하고 내용 바꾸기:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
a.txt를 변환하여 e.txt로 기록:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
a.txt를 변환하고 e.txt로 기록, e.txt의 날짜 스탬프를 a.txt와 동일하게 설정:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
a.txt를 변환하고 내용 바꾸기, b.txt를 변환하고 e.txt에 기록:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
a.txt를 변환하여 e.txt로 기록, a.txt를 변환하고 내용 바꾸기, b.txt를 변환하고 내용 바꾸기, d.txt를
|
||||
변환하고 f.txt로 기록:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
재귀 변환
|
||||
유닉스 셸에서 dos2unix로 하여금 디렉터리 트리의 모든 텍스트 파일을 재귀적으로 탐색하여 처리하려 할 때, find(1)와
|
||||
xargs(1) 명령을 사용할 수 있습니다. 예를 들어 아래 형태를 갖춘 디렉터리 트리의 모든 .txt 파일을 변환하려면:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
find(1) 명령의 옵션 "-print0" 그리고 이에 해당하는 xargs(1) 명령의 -0옵션은 이름에 공백이나 따옴표가 있을
|
||||
경우 필요합니다. 공백이나 따옴표가 없으면 이 옵션을 생략할 수 있습니다. 다른 옵션으로는 find(1)의 "-exec" 옵션이
|
||||
있습니다:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
윈도우 명령 프롬프트에서 다음 명령을 활용할 수 없습니다:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
파워셸 사용자는 윈도우 파워셸에서 다음 명령을 활용할 수 있습니다:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
지역화
|
||||
LANG
|
||||
기본 언어는 LANG 환경 변수로 선택합니다. LANG 환경 변수는 몇가지 부분으로 구성합니다. 첫번째 부분은 언어 코드를
|
||||
의미하는 몇가지 문자입니다. 두번제 부분은 대문자로 이루어진 국가 코드입니다. 두 코드 사이에는 밑줄 문자가 들어갑니다.
|
||||
마지막으로 추가하는 부분은 점이 앞서 오는 문자 인코딩입니다. POSIX 표준 형 셸에서 몇가지 예제를 보여드리도록
|
||||
하겠습니다:
|
||||
|
||||
export LANG=nl Dutch
|
||||
export LANG=nl_NL Dutch, The Netherlands
|
||||
export LANG=nl_BE Dutch, Belgium
|
||||
export LANG=es_ES Spanish, Spain
|
||||
export LANG=es_MX Spanish, Mexico
|
||||
export LANG=en_US.iso88591 English, USA, Latin-1 encoding
|
||||
export LANG=en_GB.UTF-8 English, UK, UTF-8 encoding
|
||||
|
||||
언어 및 국가 코드 전체 목록을 보려면
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html> gettext 설명서를 참고하십시오
|
||||
|
||||
유닉스 시스템에서는 locale(1) 명령을 활용하여 로캘별 정보를 가져올 수 있습니다.
|
||||
|
||||
LANGUAGE
|
||||
LANGUAGE 환경 변수에는 언어를 우선 순위별로 콜론으로 구분하여 지정할 수 있습니다. dos2unix에서는
|
||||
LANGUAGE를 LANG보다 우선 취급합니다. 예를 들면 네덜란드어를 먼저 그 다음에 독일어를 설정할 경우
|
||||
"LANGUAGE=nl:de"(으)로 설정합니다. LANGUAGE 환경 변수에 언어별 우선 순위를 두어 사용할 수 있기
|
||||
전에 LANG 환경 변수 (또는 LC_ALL)에 "C" 대신 다른 값을 넣어 지역화를 우선 설정해야합니다.
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html> gettext 설명서도 참고하십시오
|
||||
|
||||
사용할 수 없는 언어를 선택했다면 표준 (국제) 영어 메시지로 나타납니다.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
DOS2UNIX_LOCALEDIR 환경 변수는, 컴파일 시간에는 LOCALEDIR 환경 변수를 우선 활용할 수 있습니다.
|
||||
LOCALEDIR 환경 변수는 언어 파일을 찾을 때 활용합니다. GNU 기본값은
|
||||
"/usr/local/share/locale"입니다. --version 옵션을 사용하면 LOCALEDIR이 사용하는 값을
|
||||
보여줍니다.
|
||||
|
||||
예제 (POSIX 셸):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
반환 값
|
||||
성공하면 0값을 반환합니다. 시스템 오류가 나타나면 가장 마지막에 나타난 시스템 오류를 반환합니다. 다른 오류는 1 값을
|
||||
반환합니다.
|
||||
|
||||
미출력 모드의 반환 값은 항상 0이지만, 명령행 옵션이 잘못됐을 경우는 제외합니다.
|
||||
|
||||
표준
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
저자
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix
|
||||
mode) - <wuebben@kde.org>, Christian Wurll (add extra newline) -
|
||||
<wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl>
|
||||
(maintainer)
|
||||
|
||||
프로젝트 페이지: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge 페이지: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
추가 참조
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/nl/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/nl/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - DOS/Mac naar Unix en vice versa tekstbestand formaat omzetter</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NAAM">NAAM</a></li>
|
||||
<li><a href="#OVERZICHT">OVERZICHT</a></li>
|
||||
<li><a href="#BESCHRIJVING">BESCHRIJVING</a></li>
|
||||
<li><a href="#OPTIES">OPTIES</a></li>
|
||||
<li><a href="#MAC-MODUS">MAC-MODUS</a></li>
|
||||
<li><a href="#CONVERSIEMODI">CONVERSIEMODI</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Coderingen">Coderingen</a></li>
|
||||
<li><a href="#Conversie">Conversie</a></li>
|
||||
<li><a href="#Byte-Order-Mark">Byte-Order-Mark</a></li>
|
||||
<li><a href="#Unicode-bestandsnamen-op-Windows">Unicode-bestandsnamen op Windows</a></li>
|
||||
<li><a href="#Unicode-voorbeelden">Unicode-voorbeelden</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#VOORBEELDEN">VOORBEELDEN</a></li>
|
||||
<li><a href="#RECURSIEVE-CONVERSIE">RECURSIEVE CONVERSIE</a></li>
|
||||
<li><a href="#LOKALISATIE">LOKALISATIE</a></li>
|
||||
<li><a href="#AFSLUITWAARDE">AFSLUITWAARDE</a></li>
|
||||
<li><a href="#STANDAARDEN">STANDAARDEN</a></li>
|
||||
<li><a href="#AUTEURS">AUTEURS</a></li>
|
||||
<li><a href="#ZIE-OOK">ZIE OOK</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NAAM">NAAM</h1>
|
||||
|
||||
<p>dos2unix - omzetter van tekstbestandsindelingen, van DOS/Mac naar Unix en vice versa</p>
|
||||
|
||||
<h1 id="OVERZICHT">OVERZICHT</h1>
|
||||
|
||||
<pre><code>dos2unix [opties] [BESTAND ...] [-n INVOERBESTAND UITVOERBESTAND ...]
|
||||
unix2dos [opties] [BESTAND ...] [-n INVOERBESTAND UITVOERBESTAND ...]</code></pre>
|
||||
|
||||
<h1 id="BESCHRIJVING">BESCHRIJVING</h1>
|
||||
|
||||
<p>Het dos2unix-pakket bevat de toepassingen <code>dos2unix</code> en <code>unix2dos</code> om platte tekstbestanden in DOS- of Mac-indeling naar Unix-indeling om te zetten, en vice versa.</p>
|
||||
|
||||
<p>In DOS/Windows-tekstbestanden bestaat een regeleinde uit een combinatie van twee tekens: een 'Carriage Return' (CR) gevolgd door een 'Line Feed' (LF). In Unix-tekstbestanden bestaat een regeleinde uit één enkel 'Newline'-teken, dat gelijk is aan een DOS 'Line Feed'-teken (LF). In Mac-tekstbestanden, van vóór Mac OS X, bestaan regeleindes uit één enkel 'Carriage Return'-teken. Mac OS X is op Unix gebaseerd en heeft dezelfde regeleindes als Unix.</p>
|
||||
|
||||
<p>Naast regeleindes kan dos2unix ook de codering van bestanden converteren. Enkele DOS-codetabellen kunnen omgezet worden naar Unix Latin-1. En Windows Unicode-bestanden (UTF-16) kunnen omgezet worden naar Unix Unicode-bestanden (UTF-8).</p>
|
||||
|
||||
<p>Binaire bestanden worden automatisch overgeslagen, behalve als de omzetting geforceerd wordt.</p>
|
||||
|
||||
<p>Niet-reguliere bestanden, zoals mappen en FIFO's, worden automatisch overgeslagen.</p>
|
||||
|
||||
<p>Symbolische koppelingen en hun doelen blijven standaard onaangeroerd. Optioneel kunnen symbolische koppelingen worden vervangen, of de uitvoer kan naar het doel van de symbolische koppeling worden geschreven. Op Windows wordt het schrijven naar het doel van een symbolische koppeling niet ondersteund.</p>
|
||||
|
||||
<p>dos2unix is gemodelleerd naar dos2unix op SunOS/Solaris, maar er is een belangrijk verschil: deze versie van dos2unix voert standaard een vervangende conversie uit (oud-bestand-modus) terwijl de oorspronkelijke SunOS/Solaris-versie alleen de gepaarde conversie (nieuw-bestand-modus) kent. Zie ook de opties <code>-o</code> en <code>-n</code>. Een ander verschil is dat de SunOS/Solaris-versie standaard een conversie in <i>iso</i>-modus doet terwijl deze versie standaard <i>ascii</i>-modus gebruikt.</p>
|
||||
|
||||
<h1 id="OPTIES">OPTIES</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Alle volgende opties als bestandsnamen behandelen. Gebruik deze optie als u een bestand wilt converteren waarvan de naam met een streepje begint. Bijvoorbeeld, om een bestand genaamd "-foo" om te zetten, gebruikt u de volgende opdracht:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Of in nieuw-bestand-modus:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo uit.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wijziging van bestandseigenaar toestaan in oud-bestand-modus.</p>
|
||||
|
||||
<p>Wanneer deze optie gebruikt wordt, zal de omzetting niet afgebroken worden wanneer het gebruikers- en/of groepseigendomsrecht van het originele bestand niet behouden kan worden in oud-bestand-modus. Omzetting zal doorgaan en het omgezette bestand krijgt dezelfde eigendomsrechten alsof het was omgezet in nieuw-bestand-modus. Zie ook opties <code>-o</code> en <code>-n</code>. Deze optie is alleen beschikbaar als dos2unix ondersteuning heeft voor het behouden van gebruikers- en groepseigendomsrechten van bestanden.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Standaard conversiemodus. Zie ook de sectie <b>CONVERSIEMODI</b>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversie tussen de tekensets DOS en ISO-8859-1. Zie ook de sectie <b>CONVERSIEMODI</b>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Windows-codetabel 1252 (West-Europees) gebruiken.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS-codetabel 437 (VS) gebruiken. Dit is de standaard codetabel die gebruikt wordt bij ISO-conversie.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS-codetabel 850 (West-Europees) gebruiken.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS-codetabel 860 (Portugees) gebruiken.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS-codetabel 863 (Canadees Frans) gebruiken.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS-codetabel 865 (Scandinavisch) gebruiken.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Lettertekens met het achtste bit gezet omzetten naar spaties.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b</b>, <b>--keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een Byte-Order-Mark (BOM) behouden. Als het invoerbestand een BOM bevat, dan wordt ook een BOM naar het uitvoerbestand geschreven. Dit is het standaardgedrag bij conversie naar DOS. Zie ook optie <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-CONVERSIEMODUS"><b>-c</b>, <b>--convmode CONVERSIEMODUS</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De te gebruiken conversiemodus. CONVERSIEMODUS kan zijn: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, of <i>mac</i>, waarbij ascii de standaardinstelling is.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-CODERING"><b>-D</b>, <b>--display-enc CODERING</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De te gebruiken tekencodering voor weergegeven tekst. CODERING kan zijn: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, of <i>utf8bom</i>, waarbij ansi de standaardinstelling is.</p>
|
||||
|
||||
<p>Deze optie is alleen beschikbaar in dos2unix voor Windows met Unicode-bestandsnaam-ondersteuning. Deze optie heeft geen effect op de gelezen en geschreven bestandsnamen, maar alleen op hoe deze weergegeven worden.</p>
|
||||
|
||||
<p>Er zijn verscheidene methoden om tekst weer te geven in een Windows-console gebaseerd op de codering van de tekst. Ze hebben allemaal hun eigen voor- en nadelen.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix gebruikt standaard ANSI-gecodeerde tekst. Het voordeel hiervan is dat het achterwaarts compatibel is. Het werkt met raster- en TrueType-lettertypen. In sommige regio's moet je de actieve DOS OEM-codepagina veranderen in de Windows systeem ANSI-codepagina met het <code>chcp</code> commando, omdat dos2unix de Windows systeem-codepagina gebruikt.</p>
|
||||
|
||||
<p>Het nadeel van ANSI is dat internationale bestandsnamen met letters buiten de standaard systeem-codepagina niet goed worden weergegeven. U ziet in plaats daarvan een vraagteken of een verkeerd symbool. Wanneer u niet werkt met buitenlands bestandsnamen is de methode oké.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode</b>, <b>unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het voordeel van unicode (de Windows-naam voor UTF-16) codering is dat tekst meestal goed wordt weergegeven. Het is niet nodig om de actieve codepagina te wijzigen. Het kan nodig zijn om het lettertype van de console in te stellen op een TrueType-lettertype om internationale tekens goed weer te geven. Als een teken niet in het TrueType-lettertype is opgenomen, zie je meestal een klein vierkantje, soms met een vraagteken erin.</p>
|
||||
|
||||
<p>Wanneer je de ConEmu-console gebruikt wordt alle tekst goed weergegeven, omdat ConEmu automatisch een goed lettertype selecteert.</p>
|
||||
|
||||
<p>Het nadeel van unicode is dat het niet compatibel is met ASCII. De uitvoer is niet eenvoudig te verwerken als je deze doorstuurt naar een ander programma.</p>
|
||||
|
||||
<p>Wanneer methode <code>unicodebom</code> wordt gebruikt, wordt de Unicode-tekst voorafgegaan door een BOM (Byte Order Mark). Een BOM is vereist voor correcte omleiding of piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8</b>, <b>utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het voordeel van utf8 is dat het compatibel is met ASCII. Je moet het lettertype van de console instellen op een TrueType-lettertype. Met een TrueType-lettertype wordt de tekst hetzelfde weergegeven als met de <code>unicode</code>-codering.</p>
|
||||
|
||||
<p>Het nadeel is dat wanneer je het standaard raster-lettertype gebruikt alle niet-ASCII letters verkeerd worden weergegeven. Niet alleen unicode bestandsnamen, maar ook vertaalde berichten worden onleesbaar. Op Windows, ingesteld voor een Oost-Aziatische regio, is het mogelijk dat je veel flikkering in de console ziet wanneer de berichten weergegeven worden.</p>
|
||||
|
||||
<p>In een ConEmu-console werkt de utf8-codering goed.</p>
|
||||
|
||||
<p>Wanneer methode <code>utf8bom</code> wordt gebruikt, wordt de UTF-8-tekst voorafgegaan door een BOM (Byte Order Mark). Een BOM is vereist voor correcte omleiding of piping in PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>De standaard codering can gewijzigd worden met omgevingsvariabele DOS2UNIX_DISPLAY_ENC, door deze in te stellen op <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code>, of <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e</b>, <b>--add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een regeleinde toevoegen aan de laatste regel als er nog geen is. Dit werkt voor alle conversies.</p>
|
||||
|
||||
<p>Een bestand dat is geconverteerd van DOS- naar Unix-indeling kan een regeleinde op de laatste regel missen. Er zijn tekstbewerkers die tekstbestanden schrijven zonder een regeleinde op de laatste regel. Sommige Unix-programma's hebben problemen met het verwerken van deze bestanden, omdat de POSIX-standaard definieert dat elke regel in een tekstbestand moet eindigen met een afsluitend regeleindeteken. Het samenvoegen van bestanden kan bijvoorbeeld niet het verwachte resultaat opleveren.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een fout rapporteren wanneer een binair bestand wordt overgeslagen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f</b>, <b>--force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversie van binaire bestanden afdwingen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb</b>, <b>--gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Op Windows worden UTF-16-bestanden standaard naar UTF-8 geconverteerd, ongeacht de ingestelde taalregio. Gebruik deze optie om UTF-16-bestanden naar GB18030 te converteren. Deze optie is alleen beschikbaar op Windows. Zie ook de sectie <b>GB18030</b>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h</b>, <b>--help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een hulptekst tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-VLAGGEN---info-VLAGGEN-BESTAND"><b>-i[VLAGGEN]</b>, <b>--info[=VLAGGEN] BESTAND ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Bestandsinformatie tonen. Er wordt niets geconverteerd.</p>
|
||||
|
||||
<p>De volgende informatie wordt weergegeven, in deze volgorde: het aantal DOS-regeleindes, het aantal Unix-regeleindes, het aantal Mac-regeleindes, de Byte-Order-Mark, of het een tekst- of binair bestand is, en de bestandsnaam.</p>
|
||||
|
||||
<p>Voorbeelduitvoer:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Merk op dat een binair bestand soms voor een tekstbestand aangezien kan worden. Zie ook optie <code>-s</code>.</p>
|
||||
|
||||
<p>Als daarnaast optie <code>-e</code> of <code>--add-eol</code> wordt gebruikt, wordt ook het type regeleinde van de laatste regel afgedrukt, of <code>noeol</code> als er geen is.</p>
|
||||
|
||||
<p>Voorbeelduitvoer:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Bij de optie kunnen één of meer vlaggen meegegeven worden om de uitvoer te beperken.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De bestandsinformatieregels afdrukken gevolgd door een null-byte in plaats van een regeleindeteken. Dit maakt correcte interpretatie van bestandsnamen met spaties of aanhalingstekens mogelijk wanneer vlag c wordt gebruikt. Gebruik deze vlag in combinatie met xargs(1) optie <code>-0</code> of <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het aantal DOS-regeleindes tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het aantal Unix-regeleindes tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het aantal Mac-regeleindes tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De Byte-Order-Mark tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tonen of het bestand tekst is of binair.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het type van het regeleinde van de laatste regel afdrukken, of <code>noeol</code> als er geen regeleinde is.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Alleen de namen tonen van de bestanden die geconverteerd zouden worden.</p>
|
||||
|
||||
<p>Met de vlag <code>c</code> toont dos2unix alleen de bestanden die DOS-regeleindes bevatten, en unix2dos alleen de bestanden die Unix-regeleindes bevatten.</p>
|
||||
|
||||
<p>Als daarnaast optie <code>-e</code> of <code>--add-eol</code> wordt gebruikt, worden ook de bestanden afgedrukt waarbij de laatste regel geen regeleinde heeft.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een kopregel printen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Bestandsnamen tonen zonder pad.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Voorbeelden:</p>
|
||||
|
||||
<p>Informatie weergeven voor alle bestanden met de extensie 'txt':</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Alleen de aantallen DOS-regeleindes en Unix-regeleindes tonen:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Alleen de Byte-Order-Mark tonen:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>De bestanden opsommen die DOS-regeleindes bevatten:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>De bestanden opsommen die Unix-regeleindes bevatten:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>De bestanden opsommen met DOS-regeleindes of met een ontbrekend regeleinde op de laatste regel:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Alleen bestanden die DOS-regeleindes bevatten converteren en andere bestanden ongemoeid laten:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>De bestanden vinden die DOS-regeleindes bevatten:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k</b>, <b>--keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Het tijdsstempel van het invoerbestand behouden voor het uitvoerbestand.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L</b>, <b>--license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De softwarelicentie tonen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l</b>, <b>--newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een extra regeleinde toevoegen.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Alleen DOS-regeleindes worden omgezet naar twee Unix-regeleindes. In Mac-modus worden alleen Mac-regeleindes omgezet naar twee Unix-regeleindes.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Alleen Unix-regeleindes worden omgezet naar twee DOS-regeleindes. In Mac-modus worden Unix-regeleindes omgezet naar twee Mac-regeleindes.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m</b>, <b>--add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een Byte-Order-Mark (BOM) naar het uitvoerbestand schrijven. Standaard wordt een UTF-8-BOM geschreven.</p>
|
||||
|
||||
<p>Als het invoerbestand in UTF-16 is, en de optie <code>-u</code> is gegeven, dan wordt een UTF-16-BOM geschreven.</p>
|
||||
|
||||
<p>Gebruik deze optie nooit als de codering van het uitvoerbestand niet UTF-8, UTF-16, of GB18030 is. Zie ook de sectie <b>UNICODE</b>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-INVOERBESTAND-UITVOERBESTAND"><b>-n</b>, <b>--newfile INVOERBESTAND UITVOERBESTAND ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nieuw-bestand-modus. Het bestand INVOERBESTAND converteren en naar bestand UITVOERBESTAND schrijven. Bestandsnamen moeten opgegeven worden in paren. Jokertekens moeten <i>niet</i>gebruikt worden, anders <i>verlies</i> je de bestanden.</p>
|
||||
|
||||
<p>De gebruiker die de conversie start in nieuw-bestand (gepaarde) modus wordt de eigenaar van het geconverteerde bestand. De lees/schrijf-toegangsrechten van het nieuwe bestand worden de toegangsrechten van het originele bestand minus de umask(1) van de gebruiker die de conversie draait.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wijziging van bestandseigenaar niet toestaan in oud-bestand-modus (standaard).</p>
|
||||
|
||||
<p>Conversie afbreken wanneer het gebruikers- en/of groepseigendomsrecht van het originele bestand niet behouden kan worden in de oud-bestand-modus. Zie ook opties <code>-o</code> en <code>-n</code>. Deze optie is alleen beschikbaar als dos2unix ondersteuning heeft voor het behouden van het gebruikers- en groepseigendomsrechten van bestanden.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Geen regeleinde toevoegen aan de laatste regel als er geen is (standaard).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Geen fout rapporteren wanneer een binair bestand wordt overgeslagen (standaard).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O</b>, <b>--to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Naar standaarduitvoer schrijven, zoals een Unix-filter. Gebruik optie <code>-o</code> om terug te gaan naar de oud-bestand-modus (vervangend).</p>
|
||||
|
||||
<p>Gecombineerd met optie <code>-e</code> kunnen bestanden correct worden samengevoegd. Geen samengevoegde laatste en eerste regels, en geen Unicode Byte-Order-Marks in het midden van het samengevoegde bestand. Voorbeeld:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O bestand1.txt bestand2.txt > uit.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-BESTAND"><b>-o</b>, <b>--oldfile BESTAND ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Oud-bestand-modus. Het bestand BESTAND converteren en overschrijven. Dit is de standaard modus. Jokertekens kunnen gebruikt worden.</p>
|
||||
|
||||
<p>In oud-bestand (vervangende) modus krijgt het geconverteerde bestand dezelfde eigenaar, groep en lees/schrijf-rechten als het originele bestand. Ook wanneer het bestand wordt omgezet door een andere gebruiker die schrijfrechten heeft op het bestand (b.v. gebruiker root). De omzetting wordt afgebroken wanneer het niet mogelijk is de originele waardes te behouden. Verandering van eigenaar kan betekenen dat de originele eigenaar het bestand niet meer kan lezen. Verandering van groep zou een veiligheidsrisico kunnen zijn, het bestand zou leesbaar kunnen worden voor personen voor wie het niet bestemd is. Behoud van eigenaar, groep en lees/schrijf-rechten wordt alleen ondersteund op Unix.</p>
|
||||
|
||||
<p>Om te controleren of dos2unix ondersteuning heeft voor het behouden van de gebruiker en de groep van bestanden, typt u <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Conversie wordt altijd uitgevoerd via een tijdelijk bestand. Wanneer er halverwege de conversie een fout optreedt, wordt het tijdelijke bestand verwijderd en blijft het originele bestand intact. Wanneer de conversie succesvol is, wordt het originele bestand vervangen door het tijdelijke bestand. U hebt mogelijk schrijfrechten op het originele bestand, maar geen rechten om dezelfde gebruikers- en/of groepseigendomseigenschappen op het tijdelijke bestand te plaatsen als het originele bestand. Dit betekent dat u de gebruikers- en/of groepseigendom van het originele bestand niet kunt behouden. In dit geval kunt u optie <code>--allow-chown</code> gebruiken om door te gaan met de conversie:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Een andere mogelijkheid is het gebruiken van nieuw-bestand-modus:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Het voordeel van optie <code>--allow-chown</code> is dat u jokertekens kunt gebruiken, en dat dan de eigenaarseigenschappen waar mogelijk behouden zullen blijven.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q</b>, <b>--quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Stille werking. Alle waarschuwingen onderdrukken. De afsluitwaarde is nul, behalve wanneer verkeerde opties worden gegeven.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r</b>, <b>--remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Een Byte-Order-Mark (BOM) verwijderen. Er wordt geen BOM naar het uitvoerbestand geschreven. Dit is het standaardgedrag bij conversie naar Unix. Zie ook optie <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s</b>, <b>--safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Binaire bestanden overslaan (standaard).</p>
|
||||
|
||||
<p>Binaire bestanden worden overgeslagen om vergissingen te voorkomen. Het detecteren van binaire bestanden is echter niet 100% betrouwbaar. Invoerbestanden worden gescand op binaire tekens die gewoonlijk niet in tekstbestanden voorkomen. Maar het is mogelijk dat een binair bestand enkel normale teksttekens bevat. Zo'n binair bestand zal dan foutief als een tekstbestand gezien worden.</p>
|
||||
|
||||
<p>Standaard wordt geen fout gerapporteerd als een binair bestand wordt overgeslagen. Hiervoor wordt alleen een fout gerapporteerd wanneer optie <code>--error-binary</code> gegeven is.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u</b>, <b>--keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul</b>, <b>--assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Veronderstellen dat de indeling van het invoerbestand UTF-16LE is.</p>
|
||||
|
||||
<p>Wanneer het invoerbestand een Byte-Order-Mark (BOM) bevat, dan gaat deze BOM vóór deze optie.</p>
|
||||
|
||||
<p>Wanneer een verkeerde aanname is gemaakt (het invoerbestand was geen UTF-16LE) en de conversie verliep met succes, dan krijgt u een UTF-8-bestand met verkeerde tekst. De verkeerde conversie kan ongedaan worden gemaakt door met iconv(1) het UTF-8-uitvoerbestand terug om te zetten naar UTF-16LE. Dit zal het originele bestand terug brengen.</p>
|
||||
|
||||
<p>De aanname van UTF-16LE werkt als een <i>conversiemodus</i>. Door de standaardmodus <i>ascii</i> in te schakelen wordt de UTF-16LE-veronderstelling uitgeschakeld.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub</b>, <b>--assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Veronderstellen dat de indeling van het invoerbestand UTF-16BE is.</p>
|
||||
|
||||
<p>Deze optie werkt hetzelfde als optie <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v</b>, <b>--verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Extra meldingen weergeven. Er wordt extra informatie getoond over Byte-Order-Marks en het aantal geconverteerde regeleindes.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F</b>, <b>--follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Symbolische koppelingen volgen en de doelen converteren.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R</b>, <b>--replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Symbolische koppelingen vervangen door geconverteerde bestanden (de originele doelbestanden blijven ongewijzigd).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S</b>, <b>--skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Symbolische koppelingen en doelen ongewijzigd laten (standaard).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V</b>, <b>--version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Versie-informatie tonen.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MAC-MODUS">MAC-MODUS</h1>
|
||||
|
||||
<p>Standaard worden regeleindes geconverteerd van DOS naar Unix en vice versa. Mac-regeleindes worden niet omgezet.</p>
|
||||
|
||||
<p>In Mac-modus worden Mac-regeleindes naar Unix omgezet en vice versa. DOS-regeleindes blijven ongewijzigd.</p>
|
||||
|
||||
<p>Om in Mac-modus te draaien kunt u de opdrachtregeloptie <code>-c mac</code> gebruiken, of de opdrachten <code>mac2unix</code> of <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="CONVERSIEMODI">CONVERSIEMODI</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Dit is de standaard conversiemodus. Deze modus is voor het converteren van ASCII en ASCII-compatibele gecodeerde bestanden, zoals UTF-8. Het inschakelen van de <b>ascii</b>-modus schakelt de <b>7bit</b>- en <b>iso</b>-modus uit.</p>
|
||||
|
||||
<p>Als dos2unix UTF-16-ondersteuning heeft, worden UTF-16-gecodeerde bestanden geconverteerd naar de tekencodering van de ingestelde taalregio op POSIX-systemen en naar UTF-8 op Windows. Als u de <b>ascii</b>-modus inschakelt, worden de optie om UTF-16-codering te behouden (<code>-u</code>) en de opties om UTF-16-invoer aan te nemen (<code>-ul</code> en <code>-ub</code>) uitgeschakeld. Om te zien of dos2unix UTF-16-ondersteuning heeft, typt u <code>dos2unix -V</code>. Zie ook de sectie UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Alle 8-bits niet-ASCII lettertekens (met waardes van 128 t/m 255) worden omgezet naar een 7-bits spatie.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tekens worden omgezet tussen een DOS-tekenset (codetabel) en de ISO-tekenset ISO-8859-1 (Latin-1) op Unix. DOS-tekens zonder een ISO-8859-1-equivalent, waarvoor dus geen omzetting mogelijk is, worden omgezet in een punt. Hetzelfde geldt voor ISO-8859-1-tekens zonder DOS-tegenhanger.</p>
|
||||
|
||||
<p>Wanneer alleen optie <code>-iso</code> gebruikt wordt, zal dos2unix proberen de actieve codetabel te gebruiken. Als dat niet mogelijk is wordt codetabel CP437 gebruikt, die vooral in de VS gebruikt wordt. Om een bepaalde codetabel te forceren, kunt u de opties <code>-850</code> (West-Europees), <code>-860</code> (Portugees), <code>-863</code> (Canadees Frans) of <code>-865</code> (Scandinavisch) gebruiken. Windows-codetabel CP1252 (West-Europees) wordt ook ondersteund met optie <code>-1252</code>. Gebruik voor andere codetabellen dos2unix in combinatie met iconv(1). Iconv kan omzetten tussen een lange lijst tekensetcoderingen.</p>
|
||||
|
||||
<p>Gebruik ISO-conversie nooit op Unicode-tekstbestanden. Het zal UTF-8-gecodeerde bestanden beschadigen.</p>
|
||||
|
||||
<p>Enkele voorbeelden:</p>
|
||||
|
||||
<p>Omzetten van de standaard DOS-codetabel naar Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van DOS CP850 naar Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Windows CP1252 naar Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Windows CP1252 naar Unix UTF-8 (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix Latin-1 naar de standaard DOS-codetabel:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix Latin-1 naar DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix Latin-1 naar Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix UTF-8 (Unicode) naar Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > uit.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Coderingen">Coderingen</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Conversie">Conversie</h2>
|
||||
|
||||
<p>Unicode-tekstbestanden kunnen DOS-, Unix- of Mac-regeleindes hebben, net als ASCII-tekstbestanden.</p>
|
||||
|
||||
<p>Alle versies van dos2unix en unix2dos kunnen UTF-8-gecodeerde bestanden omzetten, want UTF-8 is ontworpen op compatibiliteit met ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Op Unix/Linux worden UTF-16-bestanden geconverteerd naar de codering van de ingestelde taalregio. Gebruik de opdracht <b>locale</b>(1) om te zien wat de ingestelde codering is. Wanneer conversie niet mogelijk is, treedt er een fout op en wordt het bestand overgeslagen.</p>
|
||||
|
||||
<p>Op Windows worden UTF-16-bestanden standaard naar UTF-8 geconverteerd. UTF-8-tekstbestanden worden alom goed ondersteund, zowel op Windows als Unix/Linux.</p>
|
||||
|
||||
<p>De UTF-16- en UTF-8-coderingen zijn volledig compatibel, er gaat bij het converteren niets verloren. Als er tijdens de conversie van UTF-16 naar UTF-8 een fout optreedt, bijvoorbeeld omdat het UTF-16-invoerbestand een fout bevat, dan wordt het bestand overgeslagen.</p>
|
||||
|
||||
<p>Wanneer <code>-u</code> gebruikt wordt, wordt het uitvoerbestand in dezelfde UTF-16-codering geschreven als het invoerbestand. Optie <code>-u</code> voorkomt conversie naar UTF-8.</p>
|
||||
|
||||
<p>dos2unix en unix2dos hebben geen optie om van UTF-8 naar UTF-16 te converteren.</p>
|
||||
|
||||
<p>ISO- en 7-bits-conversie werken niet op UTF-16-bestanden.</p>
|
||||
|
||||
<h2 id="Byte-Order-Mark">Byte-Order-Mark</h2>
|
||||
|
||||
<p>Op Windows bevatten Unicode-tekstbestanden gewoonlijk een Byte-Order-Mark (BOM), omdat veel Windows-programma's (inclusief Kladblok) standaard een BOM toevoegen. Zie ook <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>Op Unix hebben Unicode-tekstbestanden meestal geen BOM. Er wordt aangenomen dat de codering van tekstbestanden gelijk is aan de tekencodering van de ingestelde taalregio.</p>
|
||||
|
||||
<p>dos2unix kan alleen detecteren of een bestand in UTF-16-codering is als het bestand een BOM bevat. Wanneer een UTF-16-bestand geen BOM heeft, ziet dos2unix het bestand als een binair bestand.</p>
|
||||
|
||||
<p>Gebruik optie <code>-ul</code> of <code>-ub</code> om een UTF-16-bestand zonder BOM om te zetten.</p>
|
||||
|
||||
<p>dos2unix schrijft standaard geen BOM in het uitvoerbestand. Met optie <code>-b</code> schrijft dos2unix een BOM wanneer het invoerbestand een BOM bevat.</p>
|
||||
|
||||
<p>unix2dos schrijft standaard een BOM in het uitvoerbestand wanneer het invoerbestand een BOM bevat. Gebruik optie <code>-r</code> om de BOM te verwijderen.</p>
|
||||
|
||||
<p>dos2unix en unix2dos schrijven altijd een BOM wanneer optie <code>-m</code> gebruikt wordt.</p>
|
||||
|
||||
<h2 id="Unicode-bestandsnamen-op-Windows">Unicode-bestandsnamen op Windows</h2>
|
||||
|
||||
<p>dos2unix heeft optionele ondersteuning voor het lezen en schrijven van Unicode-bestandsnamen in de Windows Opdrachtprompt. Dit betekent dat dos2unix bestanden kan openen waarvan de naam tekens bevat die niet voorkomen in de standaard ANSI-codetabel. Om te zien of dos2unix voor Windows gecompileerd werd met ondersteuning voor Unicode-bestandsnamen, typt u <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Er zijn enige problemen met het weergeven van Unicode-bestandsnamen in een Windows-console; zie bij optie <code>-D</code>, <code>--display-enc</code>. De bestandsnamen kunnen verkeerd weergegeven worden, maar de bestanden zullen geschreven worden met de correcte naam.</p>
|
||||
|
||||
<h2 id="Unicode-voorbeelden">Unicode-voorbeelden</h2>
|
||||
|
||||
<p>Omzetten van Windows UTF-16 (met BOM) naar Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Windows UTF-16LE (zonder BOM) naar Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix UTF-8 naar Windows UTF-8 met BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt uit.txt</code></pre>
|
||||
|
||||
<p>Omzetten van Unix UTF-8 naar Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > uit.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 is een standaard van de Chinese overheid. Een subset van de GB18030-standaard is officieel verplicht voor alle softwareproducten die in China verkocht worden. Zie ook <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 is volledig compatibel met Unicode, en kan als een Unicodetransformatie beschouwd worden. Net als UTF-8 is GB18030 compatibel met ASCII. GB18030 is ook compatibel met Windows-codetabel 936 (ook wel GBK genoemd).</p>
|
||||
|
||||
<p>Op Unix/Linux worden UTF-16-bestanden naar GB18030 geconverteerd wanneer de taalregio-codering GB18030 is. Merk op dat dit alleen werkt als deze taalregio-instelling door het systeem ondersteund wordt. Gebruik het commando <code>locale -a</code> voor een overzicht van de beschikbare taalregio's.</p>
|
||||
|
||||
<p>Op Windows dient u de optie <code>-gb</code> te gebruiken om UTF-16-bestanden naar GB18030 te converteren.</p>
|
||||
|
||||
<p>GB18030-bestanden kunnen een Byte-Order-Mark bevatten, net als Unicode-bestanden.</p>
|
||||
|
||||
<h1 id="VOORBEELDEN">VOORBEELDEN</h1>
|
||||
|
||||
<p>Invoer lezen van standaardinvoer en uitvoer schrijven naar standaarduitvoer:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Omzetten en vervangen van a.txt; omzetten en vervangen van b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Omzetten en vervangen van a.txt in ascii-conversiemodus:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Omzetten en vervangen van a.txt in ascii-conversiemodus; omzetten en vervangen van b.txt in 7-bits conversiemodus:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Omzetten van a.txt van Mac- naar Unix-indeling:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Omzetten van a.txt van Unix- naar Mac-indeling:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Omzetten en vervangen van a.txt met behoud van origineel tijdsstempel:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Omzetten van a.txt en resultaat naar e.txt schrijven:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Omzetten van a.txt en naar e.txt schrijven, met tijdsstempel van e.txt gelijk aan die van a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Omzetten en vervangen van a.txt; omzetten van b.txt en naar e.txt schrijven:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Omzetten van c.txt en naar e.txt schrijven; omzetten en vervangen van a.txt; omzetten en vervangen van b.txt; omzetten van d.txt en naar f.txt schrijven:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="RECURSIEVE-CONVERSIE">RECURSIEVE CONVERSIE</h1>
|
||||
|
||||
<p>In een Unix-shell kunnen de find(1) en xargs(1) commando's gebruikt worden om dos2unix recursief uit te voeren over alle tekstbestanden in een mappenboomstructuur. Bijvoorbeeld om alle .txt-bestanden in de mappenboomstructuur onder het huidige maptype te converteren:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>De find(1) optie <code>-print0</code> en de corresponderende xargs(1) optie <code>-0</code> zijn nodig als er bestanden zijn met spaties of aanhalingstekens in de naam. Anders kunnen deze opties worden weggelaten. Een andere optie is om find(1) te gebruiken met de <code>-exec</code> optie:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>In een Windows Opdrachtprompt kan de volgende opdracht gebruikt worden:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>PowerShell-gebruikers kunnen de volgende opdracht in Windows PowerShell gebruiken:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOKALISATIE">LOKALISATIE</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>De primaire taal wordt geselecteerd via de omgevingsvariabele LANG. De variabele LANG bestaat uit verschillende onderdelen. Het eerste deel is in kleine letters de taalcode. Het tweede deel is optioneel en is de landcode in hoofdletters, voorafgegaan door een liggend streepje. Er is ook een optioneel derde deel: de tekencodering, voorafgegaan door een punt. Enkele voorbeelden voor een POSIX-shell:</p>
|
||||
|
||||
<pre><code>export LANG=nl Nederlands
|
||||
export LANG=nl_NL Nederlands, Nederland
|
||||
export LANG=nl_BE Nederlands, België
|
||||
export LANG=es_ES Spaans, Spanje
|
||||
export LANG=es_MX Spaans, Mexico
|
||||
export LANG=en_US.iso88591 Engels, VS, Latin-1-codering
|
||||
export LANG=en_GB.UTF-8 Engels, GB, UTF-8-codering</code></pre>
|
||||
|
||||
<p>Voor een complete lijst van taal- en landcodes zie de gettext-handleiding: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>Op Unix-systemen kunt u de opdracht <b>locale</b>(1) gebruiken om specifieke taalregio-informatie te verkrijgen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Met de omgevingsvariabele LANGUAGE kunt u een prioriteitenlijst specificeren van talen, gescheiden door dubbele punten. dos2unix geeft voorrang aan LANGUAGE boven LANG. Bijvoorbeeld, eerst Nederlands en dan Duits: <code>LANGUAGE=nl:de</code>. U moet eerst lokalisatie in werking stellen, door het instellen van LANG (of LC_ALL) op een waarde ongelijk aan "C", voordat u een talen-prioriteitenlijst kunt gebruiken via de variabele LANGUAGE. Zie ook de gettext-handleiding: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Als u een taal kiest die niet beschikbaar is, worden de standaard Engelse berichten gebruikt.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Met de omgevingsvariabele DOS2UNIX_LOCALEDIR kan de LOCALEDIR die ingesteld werd tijdens compilatie worden overstemd. LOCALEDIR wordt gebruikt om de taalbestanden te vinden. De GNU standaardwaarde is <code>/usr/local/share/locale</code>. De optie <b>--version</b> laat de gebruikte LOCALEDIR zien.</p>
|
||||
|
||||
<p>Voorbeeld (POSIX-shell):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="AFSLUITWAARDE">AFSLUITWAARDE</h1>
|
||||
|
||||
<p>Bij succes wordt nul teruggegeven. Wanneer een systeemfout optreedt wordt het laatste systeemfoutnummer teruggegeven. Bij andere fouten wordt 1 teruggegeven.</p>
|
||||
|
||||
<p>De afsluitwaarde is altijd nul in de stillewerkingsmodus, behalve wanneer verkeerde opties worden gegeven.</p>
|
||||
|
||||
<h1 id="STANDAARDEN">STANDAARDEN</h1>
|
||||
|
||||
<p><a href="https://nl.wikipedia.org/wiki/Tekstbestand">https://nl.wikipedia.org/wiki/Tekstbestand</a></p>
|
||||
|
||||
<p><a href="https://nl.wikipedia.org/wiki/Carriage_Return">https://nl.wikipedia.org/wiki/Carriage_Return</a></p>
|
||||
|
||||
<p><a href="https://nl.wikipedia.org/wiki/Linefeed">https://nl.wikipedia.org/wiki/Linefeed</a></p>
|
||||
|
||||
<p><https://nl.wikipedia.org/wiki/Unicode></p>
|
||||
|
||||
<h1 id="AUTEURS">AUTEURS</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix-modus) - <wuebben@kde.org>, Christian Wurll (toevoegen van extra regeleindes) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (beheerder)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge-pagina: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="ZIE-OOK">ZIE OOK</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
861
Agent-Windows/OGP64/usr/share/doc/dos2unix/nl/dos2unix.txt
Normal file
861
Agent-Windows/OGP64/usr/share/doc/dos2unix/nl/dos2unix.txt
Normal file
|
|
@ -0,0 +1,861 @@
|
|||
NAAM
|
||||
dos2unix - omzetter van tekstbestandsindelingen, van DOS/Mac naar Unix
|
||||
en vice versa
|
||||
|
||||
OVERZICHT
|
||||
dos2unix [opties] [BESTAND ...] [-n INVOERBESTAND UITVOERBESTAND ...]
|
||||
unix2dos [opties] [BESTAND ...] [-n INVOERBESTAND UITVOERBESTAND ...]
|
||||
|
||||
BESCHRIJVING
|
||||
Het dos2unix-pakket bevat de toepassingen "dos2unix" en "unix2dos" om
|
||||
platte tekstbestanden in DOS- of Mac-indeling naar Unix-indeling om te
|
||||
zetten, en vice versa.
|
||||
|
||||
In DOS/Windows-tekstbestanden bestaat een regeleinde uit een combinatie
|
||||
van twee tekens: een 'Carriage Return' (CR) gevolgd door een 'Line Feed'
|
||||
(LF). In Unix-tekstbestanden bestaat een regeleinde uit één enkel
|
||||
'Newline'-teken, dat gelijk is aan een DOS 'Line Feed'-teken (LF). In
|
||||
Mac-tekstbestanden, van vóór Mac OS X, bestaan regeleindes uit één enkel
|
||||
'Carriage Return'-teken. Mac OS X is op Unix gebaseerd en heeft dezelfde
|
||||
regeleindes als Unix.
|
||||
|
||||
Naast regeleindes kan dos2unix ook de codering van bestanden
|
||||
converteren. Enkele DOS-codetabellen kunnen omgezet worden naar Unix
|
||||
Latin-1. En Windows Unicode-bestanden (UTF-16) kunnen omgezet worden
|
||||
naar Unix Unicode-bestanden (UTF-8).
|
||||
|
||||
Binaire bestanden worden automatisch overgeslagen, behalve als de
|
||||
omzetting geforceerd wordt.
|
||||
|
||||
Niet-reguliere bestanden, zoals mappen en FIFO's, worden automatisch
|
||||
overgeslagen.
|
||||
|
||||
Symbolische koppelingen en hun doelen blijven standaard onaangeroerd.
|
||||
Optioneel kunnen symbolische koppelingen worden vervangen, of de uitvoer
|
||||
kan naar het doel van de symbolische koppeling worden geschreven. Op
|
||||
Windows wordt het schrijven naar het doel van een symbolische koppeling
|
||||
niet ondersteund.
|
||||
|
||||
dos2unix is gemodelleerd naar dos2unix op SunOS/Solaris, maar er is een
|
||||
belangrijk verschil: deze versie van dos2unix voert standaard een
|
||||
vervangende conversie uit (oud-bestand-modus) terwijl de oorspronkelijke
|
||||
SunOS/Solaris-versie alleen de gepaarde conversie (nieuw-bestand-modus)
|
||||
kent. Zie ook de opties "-o" en "-n". Een ander verschil is dat de
|
||||
SunOS/Solaris-versie standaard een conversie in *iso*-modus doet terwijl
|
||||
deze versie standaard *ascii*-modus gebruikt.
|
||||
|
||||
OPTIES
|
||||
-- Alle volgende opties als bestandsnamen behandelen. Gebruik deze
|
||||
optie als u een bestand wilt converteren waarvan de naam met een
|
||||
streepje begint. Bijvoorbeeld, om een bestand genaamd "-foo" om te
|
||||
zetten, gebruikt u de volgende opdracht:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Of in nieuw-bestand-modus:
|
||||
|
||||
dos2unix -n -- -foo uit.txt
|
||||
|
||||
--allow-chown
|
||||
Wijziging van bestandseigenaar toestaan in oud-bestand-modus.
|
||||
|
||||
Wanneer deze optie gebruikt wordt, zal de omzetting niet afgebroken
|
||||
worden wanneer het gebruikers- en/of groepseigendomsrecht van het
|
||||
originele bestand niet behouden kan worden in oud-bestand-modus.
|
||||
Omzetting zal doorgaan en het omgezette bestand krijgt dezelfde
|
||||
eigendomsrechten alsof het was omgezet in nieuw-bestand-modus. Zie
|
||||
ook opties "-o" en "-n". Deze optie is alleen beschikbaar als
|
||||
dos2unix ondersteuning heeft voor het behouden van gebruikers- en
|
||||
groepseigendomsrechten van bestanden.
|
||||
|
||||
-ascii
|
||||
Standaard conversiemodus. Zie ook de sectie CONVERSIEMODI.
|
||||
|
||||
-iso
|
||||
Conversie tussen de tekensets DOS en ISO-8859-1. Zie ook de sectie
|
||||
CONVERSIEMODI.
|
||||
|
||||
-1252
|
||||
Windows-codetabel 1252 (West-Europees) gebruiken.
|
||||
|
||||
-437
|
||||
DOS-codetabel 437 (VS) gebruiken. Dit is de standaard codetabel die
|
||||
gebruikt wordt bij ISO-conversie.
|
||||
|
||||
-850
|
||||
DOS-codetabel 850 (West-Europees) gebruiken.
|
||||
|
||||
-860
|
||||
DOS-codetabel 860 (Portugees) gebruiken.
|
||||
|
||||
-863
|
||||
DOS-codetabel 863 (Canadees Frans) gebruiken.
|
||||
|
||||
-865
|
||||
DOS-codetabel 865 (Scandinavisch) gebruiken.
|
||||
|
||||
-7 Lettertekens met het achtste bit gezet omzetten naar spaties.
|
||||
|
||||
-b, --keep-bom
|
||||
Een Byte-Order-Mark (BOM) behouden. Als het invoerbestand een BOM
|
||||
bevat, dan wordt ook een BOM naar het uitvoerbestand geschreven. Dit
|
||||
is het standaardgedrag bij conversie naar DOS. Zie ook optie "-r".
|
||||
|
||||
-c, --convmode CONVERSIEMODUS
|
||||
De te gebruiken conversiemodus. CONVERSIEMODUS kan zijn: *ascii*,
|
||||
*7bit*, *iso*, of *mac*, waarbij ascii de standaardinstelling is.
|
||||
|
||||
-D, --display-enc CODERING
|
||||
De te gebruiken tekencodering voor weergegeven tekst. CODERING kan
|
||||
zijn: *ansi*, *unicode*, *unicodebom*, *utf8*, of *utf8bom*, waarbij
|
||||
ansi de standaardinstelling is.
|
||||
|
||||
Deze optie is alleen beschikbaar in dos2unix voor Windows met
|
||||
Unicode-bestandsnaam-ondersteuning. Deze optie heeft geen effect op
|
||||
de gelezen en geschreven bestandsnamen, maar alleen op hoe deze
|
||||
weergegeven worden.
|
||||
|
||||
Er zijn verscheidene methoden om tekst weer te geven in een
|
||||
Windows-console gebaseerd op de codering van de tekst. Ze hebben
|
||||
allemaal hun eigen voor- en nadelen.
|
||||
|
||||
ansi
|
||||
dos2unix gebruikt standaard ANSI-gecodeerde tekst. Het voordeel
|
||||
hiervan is dat het achterwaarts compatibel is. Het werkt met
|
||||
raster- en TrueType-lettertypen. In sommige regio's moet je de
|
||||
actieve DOS OEM-codepagina veranderen in de Windows systeem
|
||||
ANSI-codepagina met het "chcp" commando, omdat dos2unix de
|
||||
Windows systeem-codepagina gebruikt.
|
||||
|
||||
Het nadeel van ANSI is dat internationale bestandsnamen met
|
||||
letters buiten de standaard systeem-codepagina niet goed worden
|
||||
weergegeven. U ziet in plaats daarvan een vraagteken of een
|
||||
verkeerd symbool. Wanneer u niet werkt met buitenlands
|
||||
bestandsnamen is de methode oké.
|
||||
|
||||
unicode, unicodebom
|
||||
Het voordeel van unicode (de Windows-naam voor UTF-16) codering
|
||||
is dat tekst meestal goed wordt weergegeven. Het is niet nodig
|
||||
om de actieve codepagina te wijzigen. Het kan nodig zijn om het
|
||||
lettertype van de console in te stellen op een
|
||||
TrueType-lettertype om internationale tekens goed weer te geven.
|
||||
Als een teken niet in het TrueType-lettertype is opgenomen, zie
|
||||
je meestal een klein vierkantje, soms met een vraagteken erin.
|
||||
|
||||
Wanneer je de ConEmu-console gebruikt wordt alle tekst goed
|
||||
weergegeven, omdat ConEmu automatisch een goed lettertype
|
||||
selecteert.
|
||||
|
||||
Het nadeel van unicode is dat het niet compatibel is met ASCII.
|
||||
De uitvoer is niet eenvoudig te verwerken als je deze doorstuurt
|
||||
naar een ander programma.
|
||||
|
||||
Wanneer methode "unicodebom" wordt gebruikt, wordt de
|
||||
Unicode-tekst voorafgegaan door een BOM (Byte Order Mark). Een
|
||||
BOM is vereist voor correcte omleiding of piping in PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
Het voordeel van utf8 is dat het compatibel is met ASCII. Je
|
||||
moet het lettertype van de console instellen op een
|
||||
TrueType-lettertype. Met een TrueType-lettertype wordt de tekst
|
||||
hetzelfde weergegeven als met de "unicode"-codering.
|
||||
|
||||
Het nadeel is dat wanneer je het standaard raster-lettertype
|
||||
gebruikt alle niet-ASCII letters verkeerd worden weergegeven.
|
||||
Niet alleen unicode bestandsnamen, maar ook vertaalde berichten
|
||||
worden onleesbaar. Op Windows, ingesteld voor een
|
||||
Oost-Aziatische regio, is het mogelijk dat je veel flikkering in
|
||||
de console ziet wanneer de berichten weergegeven worden.
|
||||
|
||||
In een ConEmu-console werkt de utf8-codering goed.
|
||||
|
||||
Wanneer methode "utf8bom" wordt gebruikt, wordt de UTF-8-tekst
|
||||
voorafgegaan door een BOM (Byte Order Mark). Een BOM is vereist
|
||||
voor correcte omleiding of piping in PowerShell.
|
||||
|
||||
De standaard codering can gewijzigd worden met omgevingsvariabele
|
||||
DOS2UNIX_DISPLAY_ENC, door deze in te stellen op "unicode",
|
||||
"unicodebom", "utf8", of "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Een regeleinde toevoegen aan de laatste regel als er nog geen is.
|
||||
Dit werkt voor alle conversies.
|
||||
|
||||
Een bestand dat is geconverteerd van DOS- naar Unix-indeling kan een
|
||||
regeleinde op de laatste regel missen. Er zijn tekstbewerkers die
|
||||
tekstbestanden schrijven zonder een regeleinde op de laatste regel.
|
||||
Sommige Unix-programma's hebben problemen met het verwerken van deze
|
||||
bestanden, omdat de POSIX-standaard definieert dat elke regel in een
|
||||
tekstbestand moet eindigen met een afsluitend regeleindeteken. Het
|
||||
samenvoegen van bestanden kan bijvoorbeeld niet het verwachte
|
||||
resultaat opleveren.
|
||||
|
||||
--error-binary
|
||||
Een fout rapporteren wanneer een binair bestand wordt overgeslagen.
|
||||
|
||||
-f, --force
|
||||
Conversie van binaire bestanden afdwingen.
|
||||
|
||||
-gb, --gb18030
|
||||
Op Windows worden UTF-16-bestanden standaard naar UTF-8
|
||||
geconverteerd, ongeacht de ingestelde taalregio. Gebruik deze optie
|
||||
om UTF-16-bestanden naar GB18030 te converteren. Deze optie is
|
||||
alleen beschikbaar op Windows. Zie ook de sectie GB18030.
|
||||
|
||||
-h, --help
|
||||
Een hulptekst tonen.
|
||||
|
||||
-i[VLAGGEN], --info[=VLAGGEN] BESTAND ...
|
||||
Bestandsinformatie tonen. Er wordt niets geconverteerd.
|
||||
|
||||
De volgende informatie wordt weergegeven, in deze volgorde: het
|
||||
aantal DOS-regeleindes, het aantal Unix-regeleindes, het aantal
|
||||
Mac-regeleindes, de Byte-Order-Mark, of het een tekst- of binair
|
||||
bestand is, en de bestandsnaam.
|
||||
|
||||
Voorbeelduitvoer:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Merk op dat een binair bestand soms voor een tekstbestand aangezien
|
||||
kan worden. Zie ook optie "-s".
|
||||
|
||||
Als daarnaast optie "-e" of "--add-eol" wordt gebruikt, wordt ook
|
||||
het type regeleinde van de laatste regel afgedrukt, of "noeol" als
|
||||
er geen is.
|
||||
|
||||
Voorbeelduitvoer:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Bij de optie kunnen één of meer vlaggen meegegeven worden om de
|
||||
uitvoer te beperken.
|
||||
|
||||
0 De bestandsinformatieregels afdrukken gevolgd door een null-byte
|
||||
in plaats van een regeleindeteken. Dit maakt correcte
|
||||
interpretatie van bestandsnamen met spaties of aanhalingstekens
|
||||
mogelijk wanneer vlag c wordt gebruikt. Gebruik deze vlag in
|
||||
combinatie met xargs(1) optie -0 of "--null".
|
||||
|
||||
d Het aantal DOS-regeleindes tonen.
|
||||
|
||||
u Het aantal Unix-regeleindes tonen.
|
||||
|
||||
m Het aantal Mac-regeleindes tonen.
|
||||
|
||||
b De Byte-Order-Mark tonen.
|
||||
|
||||
t Tonen of het bestand tekst is of binair.
|
||||
|
||||
e Het type van het regeleinde van de laatste regel afdrukken, of
|
||||
"noeol" als er geen regeleinde is.
|
||||
|
||||
c Alleen de namen tonen van de bestanden die geconverteerd zouden
|
||||
worden.
|
||||
|
||||
Met de vlag "c" toont dos2unix alleen de bestanden die
|
||||
DOS-regeleindes bevatten, en unix2dos alleen de bestanden die
|
||||
Unix-regeleindes bevatten.
|
||||
|
||||
Als daarnaast optie "-e" of "--add-eol" wordt gebruikt, worden
|
||||
ook de bestanden afgedrukt waarbij de laatste regel geen
|
||||
regeleinde heeft.
|
||||
|
||||
h Een kopregel printen.
|
||||
|
||||
p Bestandsnamen tonen zonder pad.
|
||||
|
||||
Voorbeelden:
|
||||
|
||||
Informatie weergeven voor alle bestanden met de extensie 'txt':
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Alleen de aantallen DOS-regeleindes en Unix-regeleindes tonen:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Alleen de Byte-Order-Mark tonen:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
De bestanden opsommen die DOS-regeleindes bevatten:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
De bestanden opsommen die Unix-regeleindes bevatten:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
De bestanden opsommen met DOS-regeleindes of met een ontbrekend
|
||||
regeleinde op de laatste regel:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Alleen bestanden die DOS-regeleindes bevatten converteren en andere
|
||||
bestanden ongemoeid laten:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
De bestanden vinden die DOS-regeleindes bevatten:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Het tijdsstempel van het invoerbestand behouden voor het
|
||||
uitvoerbestand.
|
||||
|
||||
-L, --license
|
||||
De softwarelicentie tonen.
|
||||
|
||||
-l, --newline
|
||||
Een extra regeleinde toevoegen.
|
||||
|
||||
dos2unix: Alleen DOS-regeleindes worden omgezet naar twee
|
||||
Unix-regeleindes. In Mac-modus worden alleen Mac-regeleindes omgezet
|
||||
naar twee Unix-regeleindes.
|
||||
|
||||
unix2dos: Alleen Unix-regeleindes worden omgezet naar twee
|
||||
DOS-regeleindes. In Mac-modus worden Unix-regeleindes omgezet naar
|
||||
twee Mac-regeleindes.
|
||||
|
||||
-m, --add-bom
|
||||
Een Byte-Order-Mark (BOM) naar het uitvoerbestand schrijven.
|
||||
Standaard wordt een UTF-8-BOM geschreven.
|
||||
|
||||
Als het invoerbestand in UTF-16 is, en de optie "-u" is gegeven, dan
|
||||
wordt een UTF-16-BOM geschreven.
|
||||
|
||||
Gebruik deze optie nooit als de codering van het uitvoerbestand niet
|
||||
UTF-8, UTF-16, of GB18030 is. Zie ook de sectie UNICODE.
|
||||
|
||||
-n, --newfile INVOERBESTAND UITVOERBESTAND ...
|
||||
Nieuw-bestand-modus. Het bestand INVOERBESTAND converteren en naar
|
||||
bestand UITVOERBESTAND schrijven. Bestandsnamen moeten opgegeven
|
||||
worden in paren. Jokertekens moeten *niet*gebruikt worden, anders
|
||||
*verlies* je de bestanden.
|
||||
|
||||
De gebruiker die de conversie start in nieuw-bestand (gepaarde)
|
||||
modus wordt de eigenaar van het geconverteerde bestand. De
|
||||
lees/schrijf-toegangsrechten van het nieuwe bestand worden de
|
||||
toegangsrechten van het originele bestand minus de umask(1) van de
|
||||
gebruiker die de conversie draait.
|
||||
|
||||
--no-allow-chown
|
||||
Wijziging van bestandseigenaar niet toestaan in oud-bestand-modus
|
||||
(standaard).
|
||||
|
||||
Conversie afbreken wanneer het gebruikers- en/of
|
||||
groepseigendomsrecht van het originele bestand niet behouden kan
|
||||
worden in de oud-bestand-modus. Zie ook opties "-o" en "-n". Deze
|
||||
optie is alleen beschikbaar als dos2unix ondersteuning heeft voor
|
||||
het behouden van het gebruikers- en groepseigendomsrechten van
|
||||
bestanden.
|
||||
|
||||
--no-add-eol
|
||||
Geen regeleinde toevoegen aan de laatste regel als er geen is
|
||||
(standaard).
|
||||
|
||||
--no-error-binary
|
||||
Geen fout rapporteren wanneer een binair bestand wordt overgeslagen
|
||||
(standaard).
|
||||
|
||||
-O, --to-stdout
|
||||
Naar standaarduitvoer schrijven, zoals een Unix-filter. Gebruik
|
||||
optie "-o" om terug te gaan naar de oud-bestand-modus (vervangend).
|
||||
|
||||
Gecombineerd met optie "-e" kunnen bestanden correct worden
|
||||
samengevoegd. Geen samengevoegde laatste en eerste regels, en geen
|
||||
Unicode Byte-Order-Marks in het midden van het samengevoegde
|
||||
bestand. Voorbeeld:
|
||||
|
||||
dos2unix -e -O bestand1.txt bestand2.txt > uit.txt
|
||||
|
||||
-o, --oldfile BESTAND ...
|
||||
Oud-bestand-modus. Het bestand BESTAND converteren en overschrijven.
|
||||
Dit is de standaard modus. Jokertekens kunnen gebruikt worden.
|
||||
|
||||
In oud-bestand (vervangende) modus krijgt het geconverteerde bestand
|
||||
dezelfde eigenaar, groep en lees/schrijf-rechten als het originele
|
||||
bestand. Ook wanneer het bestand wordt omgezet door een andere
|
||||
gebruiker die schrijfrechten heeft op het bestand (b.v. gebruiker
|
||||
root). De omzetting wordt afgebroken wanneer het niet mogelijk is de
|
||||
originele waardes te behouden. Verandering van eigenaar kan
|
||||
betekenen dat de originele eigenaar het bestand niet meer kan lezen.
|
||||
Verandering van groep zou een veiligheidsrisico kunnen zijn, het
|
||||
bestand zou leesbaar kunnen worden voor personen voor wie het niet
|
||||
bestemd is. Behoud van eigenaar, groep en lees/schrijf-rechten wordt
|
||||
alleen ondersteund op Unix.
|
||||
|
||||
Om te controleren of dos2unix ondersteuning heeft voor het behouden
|
||||
van de gebruiker en de groep van bestanden, typt u "dos2unix -V".
|
||||
|
||||
Conversie wordt altijd uitgevoerd via een tijdelijk bestand. Wanneer
|
||||
er halverwege de conversie een fout optreedt, wordt het tijdelijke
|
||||
bestand verwijderd en blijft het originele bestand intact. Wanneer
|
||||
de conversie succesvol is, wordt het originele bestand vervangen
|
||||
door het tijdelijke bestand. U hebt mogelijk schrijfrechten op het
|
||||
originele bestand, maar geen rechten om dezelfde gebruikers- en/of
|
||||
groepseigendomseigenschappen op het tijdelijke bestand te plaatsen
|
||||
als het originele bestand. Dit betekent dat u de gebruikers- en/of
|
||||
groepseigendom van het originele bestand niet kunt behouden. In dit
|
||||
geval kunt u optie "--allow-chown" gebruiken om door te gaan met de
|
||||
conversie:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Een andere mogelijkheid is het gebruiken van nieuw-bestand-modus:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Het voordeel van optie "--allow-chown" is dat u jokertekens kunt
|
||||
gebruiken, en dat dan de eigenaarseigenschappen waar mogelijk
|
||||
behouden zullen blijven.
|
||||
|
||||
-q, --quiet
|
||||
Stille werking. Alle waarschuwingen onderdrukken. De afsluitwaarde
|
||||
is nul, behalve wanneer verkeerde opties worden gegeven.
|
||||
|
||||
-r, --remove-bom
|
||||
Een Byte-Order-Mark (BOM) verwijderen. Er wordt geen BOM naar het
|
||||
uitvoerbestand geschreven. Dit is het standaardgedrag bij conversie
|
||||
naar Unix. Zie ook optie "-b".
|
||||
|
||||
-s, --safe
|
||||
Binaire bestanden overslaan (standaard).
|
||||
|
||||
Binaire bestanden worden overgeslagen om vergissingen te voorkomen.
|
||||
Het detecteren van binaire bestanden is echter niet 100%
|
||||
betrouwbaar. Invoerbestanden worden gescand op binaire tekens die
|
||||
gewoonlijk niet in tekstbestanden voorkomen. Maar het is mogelijk
|
||||
dat een binair bestand enkel normale teksttekens bevat. Zo'n binair
|
||||
bestand zal dan foutief als een tekstbestand gezien worden.
|
||||
|
||||
Standaard wordt geen fout gerapporteerd als een binair bestand wordt
|
||||
overgeslagen. Hiervoor wordt alleen een fout gerapporteerd wanneer
|
||||
optie "--error-binary" gegeven is.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Veronderstellen dat de indeling van het invoerbestand UTF-16LE is.
|
||||
|
||||
Wanneer het invoerbestand een Byte-Order-Mark (BOM) bevat, dan gaat
|
||||
deze BOM vóór deze optie.
|
||||
|
||||
Wanneer een verkeerde aanname is gemaakt (het invoerbestand was geen
|
||||
UTF-16LE) en de conversie verliep met succes, dan krijgt u een
|
||||
UTF-8-bestand met verkeerde tekst. De verkeerde conversie kan
|
||||
ongedaan worden gemaakt door met iconv(1) het UTF-8-uitvoerbestand
|
||||
terug om te zetten naar UTF-16LE. Dit zal het originele bestand
|
||||
terug brengen.
|
||||
|
||||
De aanname van UTF-16LE werkt als een *conversiemodus*. Door de
|
||||
standaardmodus *ascii* in te schakelen wordt de
|
||||
UTF-16LE-veronderstelling uitgeschakeld.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Veronderstellen dat de indeling van het invoerbestand UTF-16BE is.
|
||||
|
||||
Deze optie werkt hetzelfde als optie "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Extra meldingen weergeven. Er wordt extra informatie getoond over
|
||||
Byte-Order-Marks en het aantal geconverteerde regeleindes.
|
||||
|
||||
-F, --follow-symlink
|
||||
Symbolische koppelingen volgen en de doelen converteren.
|
||||
|
||||
-R, --replace-symlink
|
||||
Symbolische koppelingen vervangen door geconverteerde bestanden (de
|
||||
originele doelbestanden blijven ongewijzigd).
|
||||
|
||||
-S, --skip-symlink
|
||||
Symbolische koppelingen en doelen ongewijzigd laten (standaard).
|
||||
|
||||
-V, --version
|
||||
Versie-informatie tonen.
|
||||
|
||||
MAC-MODUS
|
||||
Standaard worden regeleindes geconverteerd van DOS naar Unix en vice
|
||||
versa. Mac-regeleindes worden niet omgezet.
|
||||
|
||||
In Mac-modus worden Mac-regeleindes naar Unix omgezet en vice versa.
|
||||
DOS-regeleindes blijven ongewijzigd.
|
||||
|
||||
Om in Mac-modus te draaien kunt u de opdrachtregeloptie "-c mac"
|
||||
gebruiken, of de opdrachten "mac2unix" of "unix2mac".
|
||||
|
||||
CONVERSIEMODI
|
||||
ascii
|
||||
Dit is de standaard conversiemodus. Deze modus is voor het
|
||||
converteren van ASCII en ASCII-compatibele gecodeerde bestanden,
|
||||
zoals UTF-8. Het inschakelen van de ascii-modus schakelt de 7bit- en
|
||||
iso-modus uit.
|
||||
|
||||
Als dos2unix UTF-16-ondersteuning heeft, worden UTF-16-gecodeerde
|
||||
bestanden geconverteerd naar de tekencodering van de ingestelde
|
||||
taalregio op POSIX-systemen en naar UTF-8 op Windows. Als u de
|
||||
ascii-modus inschakelt, worden de optie om UTF-16-codering te
|
||||
behouden ("-u") en de opties om UTF-16-invoer aan te nemen ("-ul" en
|
||||
"-ub") uitgeschakeld. Om te zien of dos2unix UTF-16-ondersteuning
|
||||
heeft, typt u "dos2unix -V". Zie ook de sectie UNICODE.
|
||||
|
||||
7bit
|
||||
Alle 8-bits niet-ASCII lettertekens (met waardes van 128 t/m 255)
|
||||
worden omgezet naar een 7-bits spatie.
|
||||
|
||||
iso Tekens worden omgezet tussen een DOS-tekenset (codetabel) en de
|
||||
ISO-tekenset ISO-8859-1 (Latin-1) op Unix. DOS-tekens zonder een
|
||||
ISO-8859-1-equivalent, waarvoor dus geen omzetting mogelijk is,
|
||||
worden omgezet in een punt. Hetzelfde geldt voor ISO-8859-1-tekens
|
||||
zonder DOS-tegenhanger.
|
||||
|
||||
Wanneer alleen optie "-iso" gebruikt wordt, zal dos2unix proberen de
|
||||
actieve codetabel te gebruiken. Als dat niet mogelijk is wordt
|
||||
codetabel CP437 gebruikt, die vooral in de VS gebruikt wordt. Om een
|
||||
bepaalde codetabel te forceren, kunt u de opties -850
|
||||
(West-Europees), -860 (Portugees), -863 (Canadees Frans) of -865
|
||||
(Scandinavisch) gebruiken. Windows-codetabel CP1252 (West-Europees)
|
||||
wordt ook ondersteund met optie -1252. Gebruik voor andere
|
||||
codetabellen dos2unix in combinatie met iconv(1). Iconv kan omzetten
|
||||
tussen een lange lijst tekensetcoderingen.
|
||||
|
||||
Gebruik ISO-conversie nooit op Unicode-tekstbestanden. Het zal
|
||||
UTF-8-gecodeerde bestanden beschadigen.
|
||||
|
||||
Enkele voorbeelden:
|
||||
|
||||
Omzetten van de standaard DOS-codetabel naar Unix Latin-1:
|
||||
|
||||
dos2unix -iso -n in.txt uit.txt
|
||||
|
||||
Omzetten van DOS CP850 naar Unix Latin-1:
|
||||
|
||||
dos2unix -850 -n in.txt uit.txt
|
||||
|
||||
Omzetten van Windows CP1252 naar Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n in.txt uit.txt
|
||||
|
||||
Omzetten van Windows CP1252 naar Unix UTF-8 (Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > uit.txt
|
||||
|
||||
Omzetten van Unix Latin-1 naar de standaard DOS-codetabel:
|
||||
|
||||
unix2dos -iso -n in.txt uit.txt
|
||||
|
||||
Omzetten van Unix Latin-1 naar DOS CP850:
|
||||
|
||||
unix2dos -850 -n in.txt uit.txt
|
||||
|
||||
Omzetten van Unix Latin-1 naar Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n in.txt uit.txt
|
||||
|
||||
Omzetten van Unix UTF-8 (Unicode) naar Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > uit.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Coderingen
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversie
|
||||
Unicode-tekstbestanden kunnen DOS-, Unix- of Mac-regeleindes hebben, net
|
||||
als ASCII-tekstbestanden.
|
||||
|
||||
Alle versies van dos2unix en unix2dos kunnen UTF-8-gecodeerde bestanden
|
||||
omzetten, want UTF-8 is ontworpen op compatibiliteit met ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
Op Unix/Linux worden UTF-16-bestanden geconverteerd naar de codering van
|
||||
de ingestelde taalregio. Gebruik de opdracht locale(1) om te zien wat de
|
||||
ingestelde codering is. Wanneer conversie niet mogelijk is, treedt er
|
||||
een fout op en wordt het bestand overgeslagen.
|
||||
|
||||
Op Windows worden UTF-16-bestanden standaard naar UTF-8 geconverteerd.
|
||||
UTF-8-tekstbestanden worden alom goed ondersteund, zowel op Windows als
|
||||
Unix/Linux.
|
||||
|
||||
De UTF-16- en UTF-8-coderingen zijn volledig compatibel, er gaat bij het
|
||||
converteren niets verloren. Als er tijdens de conversie van UTF-16 naar
|
||||
UTF-8 een fout optreedt, bijvoorbeeld omdat het UTF-16-invoerbestand een
|
||||
fout bevat, dan wordt het bestand overgeslagen.
|
||||
|
||||
Wanneer "-u" gebruikt wordt, wordt het uitvoerbestand in dezelfde
|
||||
UTF-16-codering geschreven als het invoerbestand. Optie "-u" voorkomt
|
||||
conversie naar UTF-8.
|
||||
|
||||
dos2unix en unix2dos hebben geen optie om van UTF-8 naar UTF-16 te
|
||||
converteren.
|
||||
|
||||
ISO- en 7-bits-conversie werken niet op UTF-16-bestanden.
|
||||
|
||||
Byte-Order-Mark
|
||||
Op Windows bevatten Unicode-tekstbestanden gewoonlijk een
|
||||
Byte-Order-Mark (BOM), omdat veel Windows-programma's (inclusief
|
||||
Kladblok) standaard een BOM toevoegen. Zie ook
|
||||
<https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
Op Unix hebben Unicode-tekstbestanden meestal geen BOM. Er wordt
|
||||
aangenomen dat de codering van tekstbestanden gelijk is aan de
|
||||
tekencodering van de ingestelde taalregio.
|
||||
|
||||
dos2unix kan alleen detecteren of een bestand in UTF-16-codering is als
|
||||
het bestand een BOM bevat. Wanneer een UTF-16-bestand geen BOM heeft,
|
||||
ziet dos2unix het bestand als een binair bestand.
|
||||
|
||||
Gebruik optie "-ul" of "-ub" om een UTF-16-bestand zonder BOM om te
|
||||
zetten.
|
||||
|
||||
dos2unix schrijft standaard geen BOM in het uitvoerbestand. Met optie
|
||||
"-b" schrijft dos2unix een BOM wanneer het invoerbestand een BOM bevat.
|
||||
|
||||
unix2dos schrijft standaard een BOM in het uitvoerbestand wanneer het
|
||||
invoerbestand een BOM bevat. Gebruik optie "-r" om de BOM te
|
||||
verwijderen.
|
||||
|
||||
dos2unix en unix2dos schrijven altijd een BOM wanneer optie "-m"
|
||||
gebruikt wordt.
|
||||
|
||||
Unicode-bestandsnamen op Windows
|
||||
dos2unix heeft optionele ondersteuning voor het lezen en schrijven van
|
||||
Unicode-bestandsnamen in de Windows Opdrachtprompt. Dit betekent dat
|
||||
dos2unix bestanden kan openen waarvan de naam tekens bevat die niet
|
||||
voorkomen in de standaard ANSI-codetabel. Om te zien of dos2unix voor
|
||||
Windows gecompileerd werd met ondersteuning voor Unicode-bestandsnamen,
|
||||
typt u "dos2unix -V".
|
||||
|
||||
Er zijn enige problemen met het weergeven van Unicode-bestandsnamen in
|
||||
een Windows-console; zie bij optie "-D", "--display-enc". De
|
||||
bestandsnamen kunnen verkeerd weergegeven worden, maar de bestanden
|
||||
zullen geschreven worden met de correcte naam.
|
||||
|
||||
Unicode-voorbeelden
|
||||
Omzetten van Windows UTF-16 (met BOM) naar Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt uit.txt
|
||||
|
||||
Omzetten van Windows UTF-16LE (zonder BOM) naar Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n in.txt uit.txt
|
||||
|
||||
Omzetten van Unix UTF-8 naar Windows UTF-8 met BOM:
|
||||
|
||||
unix2dos -m -n in.txt uit.txt
|
||||
|
||||
Omzetten van Unix UTF-8 naar Windows UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > uit.txt
|
||||
|
||||
GB18030
|
||||
GB18030 is een standaard van de Chinese overheid. Een subset van de
|
||||
GB18030-standaard is officieel verplicht voor alle softwareproducten die
|
||||
in China verkocht worden. Zie ook
|
||||
<https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 is volledig compatibel met Unicode, en kan als een
|
||||
Unicodetransformatie beschouwd worden. Net als UTF-8 is GB18030
|
||||
compatibel met ASCII. GB18030 is ook compatibel met Windows-codetabel
|
||||
936 (ook wel GBK genoemd).
|
||||
|
||||
Op Unix/Linux worden UTF-16-bestanden naar GB18030 geconverteerd wanneer
|
||||
de taalregio-codering GB18030 is. Merk op dat dit alleen werkt als deze
|
||||
taalregio-instelling door het systeem ondersteund wordt. Gebruik het
|
||||
commando "locale -a" voor een overzicht van de beschikbare taalregio's.
|
||||
|
||||
Op Windows dient u de optie "-gb" te gebruiken om UTF-16-bestanden naar
|
||||
GB18030 te converteren.
|
||||
|
||||
GB18030-bestanden kunnen een Byte-Order-Mark bevatten, net als
|
||||
Unicode-bestanden.
|
||||
|
||||
VOORBEELDEN
|
||||
Invoer lezen van standaardinvoer en uitvoer schrijven naar
|
||||
standaarduitvoer:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Omzetten en vervangen van a.txt; omzetten en vervangen van b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Omzetten en vervangen van a.txt in ascii-conversiemodus:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Omzetten en vervangen van a.txt in ascii-conversiemodus; omzetten en
|
||||
vervangen van b.txt in 7-bits conversiemodus:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Omzetten van a.txt van Mac- naar Unix-indeling:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Omzetten van a.txt van Unix- naar Mac-indeling:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Omzetten en vervangen van a.txt met behoud van origineel tijdsstempel:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Omzetten van a.txt en resultaat naar e.txt schrijven:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Omzetten van a.txt en naar e.txt schrijven, met tijdsstempel van e.txt
|
||||
gelijk aan die van a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Omzetten en vervangen van a.txt; omzetten van b.txt en naar e.txt
|
||||
schrijven:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Omzetten van c.txt en naar e.txt schrijven; omzetten en vervangen van
|
||||
a.txt; omzetten en vervangen van b.txt; omzetten van d.txt en naar f.txt
|
||||
schrijven:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
RECURSIEVE CONVERSIE
|
||||
In een Unix-shell kunnen de find(1) en xargs(1) commando's gebruikt
|
||||
worden om dos2unix recursief uit te voeren over alle tekstbestanden in
|
||||
een mappenboomstructuur. Bijvoorbeeld om alle .txt-bestanden in de
|
||||
mappenboomstructuur onder het huidige maptype te converteren:
|
||||
|
||||
find . -name '*.txt' -print0 | xargs -0 dos2unix
|
||||
|
||||
De find(1) optie "-print0" en de corresponderende xargs(1) optie -0 zijn
|
||||
nodig als er bestanden zijn met spaties of aanhalingstekens in de naam.
|
||||
Anders kunnen deze opties worden weggelaten. Een andere optie is om
|
||||
find(1) te gebruiken met de "-exec" optie:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
In een Windows Opdrachtprompt kan de volgende opdracht gebruikt worden:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
PowerShell-gebruikers kunnen de volgende opdracht in Windows PowerShell
|
||||
gebruiken:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOKALISATIE
|
||||
LANG
|
||||
De primaire taal wordt geselecteerd via de omgevingsvariabele LANG.
|
||||
De variabele LANG bestaat uit verschillende onderdelen. Het eerste
|
||||
deel is in kleine letters de taalcode. Het tweede deel is optioneel
|
||||
en is de landcode in hoofdletters, voorafgegaan door een liggend
|
||||
streepje. Er is ook een optioneel derde deel: de tekencodering,
|
||||
voorafgegaan door een punt. Enkele voorbeelden voor een POSIX-shell:
|
||||
|
||||
export LANG=nl Nederlands
|
||||
export LANG=nl_NL Nederlands, Nederland
|
||||
export LANG=nl_BE Nederlands, België
|
||||
export LANG=es_ES Spaans, Spanje
|
||||
export LANG=es_MX Spaans, Mexico
|
||||
export LANG=en_US.iso88591 Engels, VS, Latin-1-codering
|
||||
export LANG=en_GB.UTF-8 Engels, GB, UTF-8-codering
|
||||
|
||||
Voor een complete lijst van taal- en landcodes zie de
|
||||
gettext-handleiding:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
Op Unix-systemen kunt u de opdracht locale(1) gebruiken om
|
||||
specifieke taalregio-informatie te verkrijgen.
|
||||
|
||||
LANGUAGE
|
||||
Met de omgevingsvariabele LANGUAGE kunt u een prioriteitenlijst
|
||||
specificeren van talen, gescheiden door dubbele punten. dos2unix
|
||||
geeft voorrang aan LANGUAGE boven LANG. Bijvoorbeeld, eerst
|
||||
Nederlands en dan Duits: "LANGUAGE=nl:de". U moet eerst lokalisatie
|
||||
in werking stellen, door het instellen van LANG (of LC_ALL) op een
|
||||
waarde ongelijk aan "C", voordat u een talen-prioriteitenlijst kunt
|
||||
gebruiken via de variabele LANGUAGE. Zie ook de gettext-handleiding:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Als u een taal kiest die niet beschikbaar is, worden de standaard
|
||||
Engelse berichten gebruikt.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Met de omgevingsvariabele DOS2UNIX_LOCALEDIR kan de LOCALEDIR die
|
||||
ingesteld werd tijdens compilatie worden overstemd. LOCALEDIR wordt
|
||||
gebruikt om de taalbestanden te vinden. De GNU standaardwaarde is
|
||||
"/usr/local/share/locale". De optie --version laat de gebruikte
|
||||
LOCALEDIR zien.
|
||||
|
||||
Voorbeeld (POSIX-shell):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
AFSLUITWAARDE
|
||||
Bij succes wordt nul teruggegeven. Wanneer een systeemfout optreedt
|
||||
wordt het laatste systeemfoutnummer teruggegeven. Bij andere fouten
|
||||
wordt 1 teruggegeven.
|
||||
|
||||
De afsluitwaarde is altijd nul in de stillewerkingsmodus, behalve
|
||||
wanneer verkeerde opties worden gegeven.
|
||||
|
||||
STANDAARDEN
|
||||
<https://nl.wikipedia.org/wiki/Tekstbestand>
|
||||
|
||||
<https://nl.wikipedia.org/wiki/Carriage_Return>
|
||||
|
||||
<https://nl.wikipedia.org/wiki/Linefeed>
|
||||
|
||||
<https://nl.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTEURS
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben
|
||||
(mac2unix-modus) - <wuebben@kde.org>, Christian Wurll (toevoegen van
|
||||
extra regeleindes) - <wurll@ira.uka.de>, Erwin Waterlander -
|
||||
<waterlan@xs4all.nl> (beheerder)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge-pagina: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
ZIE OOK
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
837
Agent-Windows/OGP64/usr/share/doc/dos2unix/pl/dos2unix.htm
Normal file
837
Agent-Windows/OGP64/usr/share/doc/dos2unix/pl/dos2unix.htm
Normal file
|
|
@ -0,0 +1,837 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - konwerter formatu plików tekstowych między systemami DOS/Mac a Uniksem</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NAZWA">NAZWA</a></li>
|
||||
<li><a href="#SK-ADNIA">SKŁADNIA</a></li>
|
||||
<li><a href="#OPIS">OPIS</a></li>
|
||||
<li><a href="#OPCJE">OPCJE</a></li>
|
||||
<li><a href="#TRYB-MAC">TRYB MAC</a></li>
|
||||
<li><a href="#TRYBY-KONWERSJI">TRYBY KONWERSJI</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Kodowania">Kodowania</a></li>
|
||||
<li><a href="#Konwersje">Konwersje</a></li>
|
||||
<li><a href="#Znacznik-BOM">Znacznik BOM</a></li>
|
||||
<li><a href="#Unikodowe-nazwy-plik-w-w-Windows">Unikodowe nazwy plików w Windows</a></li>
|
||||
<li><a href="#Przyk-ady-Unicode">Przykłady Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#PRZYK-ADY">PRZYKŁADY</a></li>
|
||||
<li><a href="#KONWERSJA-REKURENCYJNA">KONWERSJA REKURENCYJNA</a></li>
|
||||
<li><a href="#LOKALIZACJA">LOKALIZACJA</a></li>
|
||||
<li><a href="#WARTO-ZWRACANA">WARTOŚĆ ZWRACANA</a></li>
|
||||
<li><a href="#STANDARDY">STANDARDY</a></li>
|
||||
<li><a href="#AUTORZY">AUTORZY</a></li>
|
||||
<li><a href="#ZOBACZ-TAK-E">ZOBACZ TAKŻE</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NAZWA">NAZWA</h1>
|
||||
|
||||
<p>dos2unix - konwerter formatu plików tekstowych między systemami DOS/Mac a Uniksem</p>
|
||||
|
||||
<h1 id="SK-ADNIA">SKŁADNIA</h1>
|
||||
|
||||
<pre><code>dos2unix [opcje] [PLIK ...] [-n PLIK_WEJ PLIK_WYJ ...]
|
||||
unix2dos [opcje] [PLIK ...] [-n PLIK_WEJ PLIK_WYJ ...]</code></pre>
|
||||
|
||||
<h1 id="OPIS">OPIS</h1>
|
||||
|
||||
<p>Pakiet dos2unix zawiera narzędzia <code>dos2unix</code> oraz <code>unix2dos</code> do konwersji zwykłych plików tekstowych między formatami używanymi w systemach DOS lub Mac a formatem uniksowym.</p>
|
||||
|
||||
<p>W plikach tekstowych systemu DOS/Windows oznaczenie końca linii to połączenie dwóch znaków: powrotu karetki (CR) i przesunięcia linii (LF). W uniksowych plikach tekstowych koniec linii to pojedynczy znak LF. W plikach tekstowych systemu Mac sprzed Mac OS X koniec linii był pojedynczym znakiem CR. Obecnie Mac OS wykorzystuje uniksowe końce linii (LF).</p>
|
||||
|
||||
<p>Oprócz oznaczeń końców linii dos2unix potrafi konwertować także kodowanie plików. Kilko stron kodowych DOS-a może być przekonwertowanych do uniksowego Latin-1, a windowsowy Unicode (UTF-16) do powszechniejszego pod Uniksem kodowania Unicode UTF-8.</p>
|
||||
|
||||
<p>Pliki binarne są pomijane automatycznie, chyba że konwersja zostanie wymuszona.</p>
|
||||
|
||||
<p>Pliki inne niż zwykłe, np. katalogi lub FIFO, są pomijane automatycznie.</p>
|
||||
|
||||
<p>Dowiązania symboliczne i ich cele są domyślnie pozostawiane bez zmian. Dowiązania symboliczne mogą być opcjonalnie zastępowane, albo wyjście może być zapisywane do celu dowiązania. Zapis do celu dowiązania symbolicznego nie jest obsługiwane pod Windows.</p>
|
||||
|
||||
<p>dos2unix powstał na podstawie narzędzia dos2unix z systemu SunOS/Solaris. Jest jedna istotna różnica w stosunku do oryginalnej wersji z SunOS-a/Solarisa: ta wersja domyślnie wykonuje konwersję w miejscu (tryb starego pliku), podczas gdy oryginalna obsługiwała tylko konwersję parami (tryb nowego pliku) - p. także opcje <code>-o</code> i <code>-n</code>. Ponadto wersja z SunOS-a/Solarisa domyślnie wykonuje konwersję w trybie <i>iso</i>, podczas gdy ta wersja domyślnie wykonuje konwersję w trybie <i>ascii</i>.</p>
|
||||
|
||||
<h1 id="OPCJE">OPCJE</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Potraktowanie wszystkich kolejnych opcji jako nazw plików. Tej opcji należy użyć, aby przekonwertować pliki, których nazwy zaczynają się od minusa. Przykładowo, aby przekonwertować plik o nazwie "-foo", można użyć polecenia:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Lub w trybie nowego pliku:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo wynik.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zezwolenie na zmianę właściciela w trybie starego pliku.</p>
|
||||
|
||||
<p>W przypadku użycia tej opcji, konwersja nie zostanie przerwana, jeśli nie ma możliwości zachowania właściciela i/lub grupy oryginalnego pliku w trybie starego pliku. Konwersja będzie kontynuowana, a przekonwertowany plik będzie miał tego samego właściciela, jakiego by miał w trybie nowego pliku. P. także opcje <code>-o</code> i <code>-n</code>. Opcja jest dostępna tylko wtedy, gdy dos2unix ma obsługę zachowywania użytkownika i grupy plików.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Domyślny tryb konwersji. Więcej w sekcji TRYBY KONWERSJI.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Konwersja między zestawami znaków DOS i ISO-8859-1. Więcej w sekcji TRYBY KONWERSJI.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej Windows 1252 (zachodnioeuropejskiej).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej DOS 437 (US). Jest to domyślna strona kodowa używana przy konwersji ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej DOS 850 (zachodnioeuropejskiej).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej DOS 860 (portugalskiej).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej DOS 863 (kanadyjskiej francuskiej).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Użycie strony kodowej DOS 865 (nordyckiej).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Konwersja znaków 8-bitowych do przestrzeni 7-bitowej.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zachowanie znaku BOM (Byte Order Makr). Jeżeli plik wejściowy zawiera BOM, powoduje zapisanie go w pliku wyjściowym. Jest to domyślne zachowanie przy konwersji na DOS-owe końce linii. P. także opcja <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-TRYB_KONW"><b>-c, --convmode TRYB_KONW</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ustawienie trybu konwersji. TRYB_KONW to jeden z: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i>, przy czym domyślny jest ascii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-KODOWANIE"><b>-D, --display-enc KODOWANIE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ustawienie kodowania wyświetlanego tekstu. KODOWANIE to jedno z: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i>, przy czym domyślne to ansi.</p>
|
||||
|
||||
<p>Ta opcja jest dostępna wyłączenie w programie dos2unix dla Windows z obsługą nazw plików Unicode. Nie ma wpływu na same nawy odczytywanych i zapisywanych plików, a jedynie na sposób ich wyświetlania.</p>
|
||||
|
||||
<p>Istnieje kilka sposobów wyświetlania tekstu w konsoli Windows w zależności od kodowania tekstu. Wszystkie mają swoje zalety i wady.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Domyślna metoda programu dos2unix to stosowanie tekstu kodowanego w ANSI. Zaletą jest wsteczna zgodność. Działa z fontami rastrowymi, jak i TrueType. W niektórych rejonach może być potrzeba zmiany aktywnej strony kodowej DOS OEM na systemową stronę kodową Windows ANSI przy użyciu polecenia <code>chcp</code>, ponieważ dos2unix wykorzystuje systemową stronę kodową Windows.</p>
|
||||
|
||||
<p>Wadą kodowania ansi jest fakt, że międzynarodowe nazwy plików ze znakami spoza domyślnej systemowej strony kodowej nie są wyświetlane właściwie. Można zamiast tego zobaczyć znak zapytania albo niewłaściwy symbol. Jeżeli nie pracujemy z obcymi nazwami plików, ta metoda jest poprawna.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zaletą kodowania unicode (windowsową nazwą dla UTF-16) jest (zwykle) właściwe wyświetlanie tekstu. Nie ma potrzeby zmiany aktywnej strony kodowej. Może być potrzeba zmiany fontu konsoli na font TrueType, aby znaki międzynarodowe były wyświetlane poprawnie. Jeśli znak nie jest obecny w foncie TrueType, zwykle widać mały kwadrat, czasami ze znakiem zapytania w środku.</p>
|
||||
|
||||
<p>W przypadku używania konsoli ConEmu cały tekst jest wyświetlany poprawnie, ponieważ ConEmu automatycznie wybiera dobry font.</p>
|
||||
|
||||
<p>Wadą kodowania unicode jest niezgodność z ASCII. Wyjście nie jest łatwe do obsłużenia w przypadku przekierowania do innego programu lub pliku.</p>
|
||||
|
||||
<p>W przypadku użycia metody <code>unicodebom</code>, tekst w unikodzie jest poprzedzony znakiem BOM (Byte Order Mark). BOM jest wymagany do poprawnego przekierowania lub przekazywania przez potok w powłoce PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zaletą kodowania utf8 jest zgodność z ASCII. Trzeba ustawić font konsoli na font TrueType. Przy użyciu fontu TrueType tekst jest wyświetlany podobnie do kodowania <code>unicode</code>.</p>
|
||||
|
||||
<p>Wadą jest fakt, że w przypadku używania domyślnego fontu rastrowego, wszystkie znaki spoza ASCII są wyświetlane niepoprawnie. Nie tylko unikodowe nazwy plików, ale także przetłumaczone komunikaty stają się nieczytelne. W Windows skonfigurowanym dla rejonu Azji Wschodniej widać dużo migotania konsoli w trakcie wyświetlania komunikatów.</p>
|
||||
|
||||
<p>W konsoli ConEmu metoda kodowania utf8 działa dobrze.</p>
|
||||
|
||||
<p>W przypadku użycia metody <code>utf8bom</code>, tekst w UTF-8 jest poprzedzony znakiem BOM (Byte Order Mark). BOM jest wymagany do poprawnego przekierowania lub przekazywania przez potok w powłoce PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Domyślne kodowanie można zmienić przy użyciu zmiennej środowiskowej DOS2UNIX_DISPLAY_ENC, ustawiając ją na <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> lub <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Dodawanie znaku końca linii do ostatniej linii, jeśli ta go nie zawiera. Działa przy każdej konwersji.</p>
|
||||
|
||||
<p>Pliki przekształcone z formatu DOS do Uniksa mogą nie mieć w ostatnim wierszu znaku końca linii. Istnieją edytory tekstu zapisujące pliki tekstowe bez znaku końca wiersza w ostatniej linii. Niektóre programy uniksowe mają problemy przy przetwarzaniu takich plików, ponieważ standard POSIX określa, że każdy wiersz pliku tekstowego musi kończyć się znakiem końca linii. Na przykład łączenie plików może nie dać oczekiwanego wyniku.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zwrócenie błędu, jeśli pominięto plik binarny.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wymuszenie konwersji plików binarnych.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Pod Windows pliki w UTF-16 są domyślnie konwertowane do UTF-8, niezależnie od ustawienia lokalizacji. Ta opcja pozwala przekonwertować pliki w UTF-16 do GB18030. Opcja jest dostępna tylko pod Windows, więcej w sekcji dotyczącej GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlenie opisu i zakończenie.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-FLAGI---info-FLAGI-PLIK"><b>-i[FLAGI], --info[=FLAGI] PLIK ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlenie informacji o pliku. Konwersja nie jest wykonywana.</p>
|
||||
|
||||
<p>Wypisywane są następujące informacje, w tej kolejności: liczba DOS-owych końców linii, liczba uniksowych końców linii, liczba macowych końców linii, znacznik BOM, tekstowy lub binarny, nazwa pliku.</p>
|
||||
|
||||
<p>Przykładowe wyjście:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Uwaga: czasami plik binarny może być błędnie rozpoznany jako tekstowy. P. także opcja <code>-s</code>.</p>
|
||||
|
||||
<p>Jeśli dodatkowo użyta jest opcja <code>-e</code> lub <code>--add-eol</code>, wypisywany jest także rodzaj końca linii z ostatniej linii, lub <code>noeol</code>, jeśli nie ma żadnego.</p>
|
||||
|
||||
<p>Przykładowe wyjście:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
Opcjonalnie można ustawić dodatkowe flagi, aby zmienić wyjście. Można dodać jedną lub więcej flag.</code></pre>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie wierszy informacji o pliku zakończonych znakiem NUL zamiast znaku nowej linii. Pozwala to na poprawną interpretację nazw plików zawierających spacje lub cudzysłowy w przypadku użycia flagi c. Flagi należy używać w połączeniu z opcją <code>-0</code> lub <code>--null</code> programu xargs(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie liczby DOS-owych końców linii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie liczby uniksowych końców linii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie liczby macowych końców linii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie znacznika BOM.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie, czy plik jest tekstowy, czy binarny.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie rodzaju końca wiersza w ostatnim wierszu, lub <code>noeol</code>, jeśli nie ma żadnego.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie tylko plików, które zostałyby przekonwertowane.</p>
|
||||
|
||||
<p>Z flagą <code>c</code> dos2unix wypisze tylko pliki zawierające DOS-owe końce linii, a unix2dos wypisze tylko nazwy plików zawierających uniksowe końce linii.</p>
|
||||
|
||||
<p>Jeśli dodatkowo użyta jest opcja <code>-e</code> lub <code>--add-eol</code>, wypisywane są także pliki bez zakończenia ostatniej linii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wypisanie nagłówka.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlanie nazw plików bez ścieżki.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Przykłady:</p>
|
||||
|
||||
<p>Pokazanie informacji o wszystkich plikach *.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Pokazanie tylko liczby DOS-owych i uniksowych końców linii:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Pokazanie tylko znacznika BOM:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Wypisanie listy plików zawierających DOS-owe końce linii:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Wypisanie listy plików zawierających uniksowe końce linii:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Wypisanie listy plików zawierających DOS-owe końce linii lub bez znaku końca w ostatniej linii:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Konwersja tylko plików mających DOS-owe końce linii, pozostawienie pozostałych bez zmian:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Wyszukanie plików tekstowych zawierających DOS-owe końce linii:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zachowanie znacznika czasu pliku wyjściowego takiego samego, jak pliku wejściowego.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlenie licencji programu.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Dodanie dodatkowego znaku końca linii.</p>
|
||||
|
||||
<p><b>dos2unix</b>: tylko DOS-owe znaki końca linii są zamieniane na dwa uniksowe. W trybie Mac tylko macowe znaki końca linii są zamieniane na dwa uniksowe.</p>
|
||||
|
||||
<p><b>unix2dos</b>: tylko uniksowe znaki końca linii są zamieniane na dwa DOS-owe. W trybie Mac uniksowe znaki końca linii są zamieniane na dwa macowe.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zapisanie znacznika BOM (Byte Order Mark) w pliku wyjściowym. Domyślnie zapisywany jest BOM UTF-8.</p>
|
||||
|
||||
<p>Jeśli plik wejściowy jest w kodowaniu UTF-16 i użyto opcji <code>-u</code>, zostanie zapisany BOM UTF-16.</p>
|
||||
|
||||
<p>Nigdy nie należy używać tej opcji, jeśli kodowanie wyjściowe jest inne niż UTF-8, UTF-16 lub GB18030. Więcej w sekcji UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-PLIK_WEJ-PLIK_WYJ"><b>-n, --newfile PLIK_WEJ PLIK_WYJ ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tryb nowego pliku. Konwersja PLIKU_WEJ z zapisem wyjścia do PLIKU_WYJ. Nazwy plików muszą być podane parami, a masek <i>nie</i> należy używać, gdyż <i>spowoduje</i> to utratę plików.</p>
|
||||
|
||||
<p>Osoba uruchamiająca konwersję w trybie nowego pliku (par) będzie właścicielem przekonwertowanego pliku. Prawa odczytu/zapisu nowego pliku będą pochodziły z praw pliku oryginalnego po odjęciu umask(1) osoby uruchamiającej konwersję.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Bez zezwolenia na zmianę właściciela pliku w trybie starego pliku (domyślne).</p>
|
||||
|
||||
<p>Przerwanie konwersji, jeżeli użytkownik lub grupa oryginalnego pliku nie może być zachowana w trybie starego pliku. P. także opcje <code>-o</code> oraz <code>-n</code>. Ta opcja jest dostępna tylko jeśli dos2unix ma obsługę zachowywania użytkownika i grupy plików.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Bez dodawania znaku końca linii do ostatniego wiersza, jeśli ten go nie zawiera (domyślne).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Bez zwracania błędu, jeśli pominięto plik binarny (domyślne).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zapis na standardowe wyjście, jak filtr uniksowy. Opcja <code>-o</code> przywróci tryb starego pliku (zamianę z miejscu).</p>
|
||||
|
||||
<p>W połączeniu z opcją <code>-e</code> pliki mogą być właściwie łączone - bez połączonych ostatnich i pierwszych linii oraz znaków unikodowych BOM w środku połączonego pliku. Przykład:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O plik1.txt plik2.txt > wynik.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-PLIK"><b>-o, --oldfile PLIK ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tryb starego pliku. Konwersja PLIKU i nadpisanie go wyjściem. Program działa domyślnie w tym trybie. Można używać masek.</p>
|
||||
|
||||
<p>W trybie starego pliku (w miejscu) przekonwertowany plik otrzymuje tego samego właściciela, grupę oraz prawa odczytu/zapisu, jak plik oryginalny - także wtedy, gdy plik jest konwertowany przez innego użytkownika, mającego prawo zapisu do pliku (np. przez użytkownika root). Konwersja zostanie przerwana, jeśli nie będzie możliwe zachowanie oryginalnych wartości. Zmiana właściciela mogłaby oznaczać, że pierwotny właściciel nie może już odczytać pliku. Zmiana grupy mogłaby być zagrożeniem bezpieczeństwa, plik mógłby być czytelny dla niezamierzonych osób. Zachowanie właściciela, grupy i praw odczytu/zapisu jest obsługiwane tylko na Uniksie.</p>
|
||||
|
||||
<p>Aby sprawdzić, czy doswunix ma obsługę zachowywania użytkownika i grupy plików, można napisać <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Konwersja jest wykonywana zawsze przy użyciu pliku tymczasowego. Jeśli w trakcie konwersji wystąpi błąd, plik tymczasowy jest usuwany, a plik oryginalny pozostaje nietknięty. Jeśli konwersja się powiedzie, plik oryginalny jest zastępowany plikiem tymczasowym. Można mieć prawa zapisu do pliku oryginalnego, ale brak uprawnień, aby nadać tego samego właściciela i/lub grupę, co plik oryginalny, plikowi tymczasowemu. Oznacza to, że nie można zachować użytkownika i/lub grupy oryginalnego pliku. W takim przypadku można użyć opcji <code>--allow-chown</code>, aby kontynuować konwersję:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Inny sposób to użycie trybu nowego pliku:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Zaletą opcji <code>--allow-chown</code> jest możliwość użycia masek oraz zachowanie właściciela w miarę możliwości.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tryb cichy. Pominięcie wszystkich ostrzeżeń i komunikatów. Zwracanym kodem jest zero, chyba że podano błędne opcje linii poleceń.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usunięcie znaków BOM (Byte Order Mark). Bez zapisywania BOM do pliku wyjściowego. Jest to domyślne zachowanie przy konwersji na uniksowe końce linii. P. także opcja <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Pominięcie plików binarnych (domyślne).</p>
|
||||
|
||||
<p>Pomijanie plików binarnych ma na celu zapobieżenie przypadkowym błędom. Uwaga: wykrywanie plików binarnych nie jest w 100% odporne na błędy. Pliki wejściowe są przeszukiwane pod kątem symboli binarnych, które zwykle nie występują w plikach tekstowych. Może się zdarzyć, że plik binarny zawiera tylko zwykłe znaki tekstowe. Taki plik binarny będzie błędnie widziany jako plik tekstowy.</p>
|
||||
|
||||
<p>Domyślnie nie jest zwacany błąd, kiedy zostaje pominięty plik binarny. Jeśli użyta zostanie opcja <code>--error-binary</code>, błąd jest zwracany.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zachowanie oryginalnego kodowania pliku wejściowego UTF-16. Plik wyjściowy zostanie zapisany w tym samym kodowaniu UTF-16 (little- lub big-endian), co plik wejściowy. Zapobiega to przekształceniu do UTF-8. Do pliku zostanie zapisany odpowiedni znacznik BOM UTF-16. Tę opcję można wyłączyć opcją <code>-ascii</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Przyjęcie, że format pliku wejściowego to UTF-16LE.</p>
|
||||
|
||||
<p>Jeśli w pliku wejściowym jest znacznik BOM (Byte Order Mark), ma on priorytet nad tą opcją.</p>
|
||||
|
||||
<p>Jeśli przyjęto błędne założenie (plik wejściowy nie jest w formacie UTF-16LE), a konwersja się uda, wynikiem będzie plik wyjściowy UTF-8 ze złym tekstem. Konwersję tę można odwrócić przy użyciu polecenia iconv(1) do konwersji wyjścia UTF-8 z powrotem do UTF-16LE. Przywróci to plik oryginalny.</p>
|
||||
|
||||
<p>Przyjęcie UTF-16LE działa jako <i>tryb konwersji</i>. Przy przełączeniu na domyślny tryb <i>ascii</i> przyjęcie UTF-16LE jest wyłączane.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Przyjęcie, że format pliku wejściowego to UTF-16BE.</p>
|
||||
|
||||
<p>Ta opcja działa analogicznie do <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlanie szczegółowych komunikatów. Wyświetlane śa dodatkowe informacje o znacznikach BOM (Byte Order Mark) oraz liczbie przekonwertowanych końców linii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Podążanie za dowiązaniami symbolicznymi i konwertowanie ich celów</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Zastępowanie dowiązań symbolicznych przekonwertowanymi plikami (oryginalne pliki docelowe pozostają bez zmian).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Pozostawienie dowiązań symbolicznych i celów bez zmian (domyślne).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wyświetlenie informacji o wersji i zakończenie.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="TRYB-MAC">TRYB MAC</h1>
|
||||
|
||||
<p>Domyślnie znaki końca linii są konwertowane z DOS-a do Uniksa i odwrotnie. Znaki końca linii systemu Mac nie są konwertowane.</p>
|
||||
|
||||
<p>W trybie Mac znaki końca linii są konwertowane z formatu Maca do Uniksa i odwrotnie. Znaki końca linii systemu DOS nie są zmieniane.</p>
|
||||
|
||||
<p>Aby uruchomić program w trybie Mac, należy użyć opcji linii poleceń <code>-c mac</code> albo użyć poleceń <code>mac2unix</code> lub <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="TRYBY-KONWERSJI">TRYBY KONWERSJI</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>To jest domyślny tryb konwersji. Służy do konwersji plików kodowanych ASCII lub zgodnie z ASCII, np. UTF-8. Włączenie trybu <b>ascii</b> wyłącza tryby <b>7bit</b> i <b>iso</b>.</p>
|
||||
|
||||
<p>Jeśli dos2unix ma obsługę UTF-16, pliki kodowane UTF-16 są konwertowane do bieżącego kodowania w systamach zgodnych z POSIX lub do UTF-8 na Windows. Włączenie trybu <b>ascii</b> wyłącza opcję zachowywania kodowania UTF-16 (<code>-u</code>) oraz opcje zakładające wejście UTF-16 (<code>-ul</code> oraz <code>-ub</code>). Aby sprawdzić, czy dos2unix ma obsługę UTF-16, można wywołać <code>dos2unix -V</code>. Więcej w sekcji UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>W tym trybie wszystkie znaki 8-bitowe spoza ASCII (o wartościach od 128 do 255) są konwertowane do przestrzeni 7-bitowej.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>W tym trybie znaki są konwertowane między zestawem znaków DOS (stroną kodową) a zestawem znaków ISO-8859-1 (Latin-1) używanym na Uniksie. Znaki DOS-owe niemające odpowiednika w ISO-8859-1, których nie da się przekonwertować, są zamieniane na kropkę. To samo dotyczy znaków ISO-8859-1 bez odpowiednika w DOS-ie.</p>
|
||||
|
||||
<p>Jeśli używana jest tylko opcja <code>-iso</code>, dos2unix próbuje wykryć aktywną stronę kodową. Jeśli nie jest to możliwe, dos2unix używa domyślnej strony kodowej CP437, stosowanej głównie w USA. Aby wymusić określoną stronę kodową, należy użyć opcji <code>-437</code> (US), <code>-850</code> (zachodnioeuropejska), <code>-860</code> (portugalska), <code>-863</code> (kanadyjska francuska) lub <code>-865</code> (nordycka). Ponadto obsługiwana jest strona kodowa Windows CP1252 (zachodnioeuropejska) przy użyciu opcji <code>-1252</code>. W przypadku innych stron kodowych można użyć narzędzia dos2unix wraz z iconv(1). Iconv potrafi konwertować między wieloma kodowaniami znaków.</p>
|
||||
|
||||
<p>Nigdy nie należy używać konwersji ISO na plikach tekstowych w Unicode. Uszkodziłaby pliki kodowane UTF-8.</p>
|
||||
|
||||
<p>Kilka przykładów:</p>
|
||||
|
||||
<p>Konwersja z domyślnej strony kodowej DOS do uniksowego Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja ze strony kodowej DOS CP850 do uniksowego Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja ze strony kodowej Windows CP1252 do uniksowego Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja ze strony kodowej Windows CP1252 do uniksowego UTF-8 (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 wejście.txt | dos2unix > wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersa z uniksowego Latin-1 do domyślnej strony kodowej DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja z uniksowego Latin-1 do strony kodowej DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja z uniksowego Latin-1 do strony kodowej Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja z uniksowego UTF-8 (Unicode) do strony kodowej Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < wejście.txt | iconv -f UTF-8 -t CP1252 > wynik.txt</code></pre>
|
||||
|
||||
<p>Więcej pod adresem <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> oraz <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Kodowania">Kodowania</h2>
|
||||
|
||||
<p>Istnieją różne kodowania Unicode. Pod Uniksem i Linuksem pliki Unicode są zwykle kodowane z użyciem UTF-8. Pod Windows pliki tekstowe Unicode mogą być kodowane w UTF-8, UTF-16, UTF-16 big-endian, ale przeważnie są kodowane w UTF-16.</p>
|
||||
|
||||
<h2 id="Konwersje">Konwersje</h2>
|
||||
|
||||
<p>Pliki tekstowe Unicode mogą mieć znaki końca linii systemu DOS, Unix lub Mac, podobnie jak pliki tekstowe ASCII.</p>
|
||||
|
||||
<p>Wszystkie wersje dos2unix i unix2dos potrafią konwertować pliki kodowane UTF-8, ponieważ UTF-8 jest wstecznie zgodne z ASCII.</p>
|
||||
|
||||
<p>dos2unix i unix2dos z obsługą Unicode UTF-16 potrafią odczytywać pliki tekstowe kodowane UTF-16 little- oraz big-endian. Aby sprawdzić, czy dos2unix został zbudowany z obsługą UTF-16, należy napisać <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Pod Uniksem/Linuksem pliki w kodowaniu UTF-16 są konwertowane do kodowania znaków ustawionej lokalizacji. Kodowanie znaków dla lokalizacji można sprawdzić poleceniem locale(1). Jeśli konwersja nie jest możliwa, wystąpi błąd, a plik zostanie pominięty.</p>
|
||||
|
||||
<p>Pod Windows pliki UTF-16 są domyślnie konwertowane do UTF-8. Pliki tekstkowe w kodowaniu UTF-8 są dobrze obsługiwane zarówno pod Windows, jak i Uniksem/Linuksem.</p>
|
||||
|
||||
<p>Kodowania UTF-16 i UTF-8 są w pełni zgodne, konwersja nie spowoduje utraty żadnej części tekstu. W przypadku wystąpienia błędu konwersji, na przykład w przypadku błędu w pliku wejściowym UTF-16, plik zostanie pominięty.</p>
|
||||
|
||||
<p>W przypadku użycia opcji <code>-u</code>, plik wejściowy zostanie zapisany w tym samym kodowaniu UTF-16, co plik wejściowy. Opcja <code>-u</code> zapobiega konwersji do UTF-8.</p>
|
||||
|
||||
<p>dos2unix oraz unix2dos nie mają opcji pozwalającej na konwersję plików UTF-8 do UTF-16.</p>
|
||||
|
||||
<p>Tryby konwersji ISO i 7-bit nie działają na plikach UTF-16.</p>
|
||||
|
||||
<h2 id="Znacznik-BOM">Znacznik BOM</h2>
|
||||
|
||||
<p>W systemie Windows pliki tekstowe zwykle zawierają znacznik BOM (Byte Order Mark), ponieważ wiele programów dla Windows (w tym Notepad) dodaje domyślnie znaczniki BOM. Więcej informacji można znaleźć pod adresem <a href="https://pl.wikipedia.org/wiki/BOM_(informatyka)">https://pl.wikipedia.org/wiki/BOM_(informatyka)</a>.</p>
|
||||
|
||||
<p>Pod Uniksem pliki Unicode zwykle nie mają znacznika BOM. Pliki tekstowe są traktowane jako kodowane zgodnie z kodowaniem znaków ustawionej lokalizacji.</p>
|
||||
|
||||
<p>dos2unix potrafi wykryć tylko, czy plik jest w formacie UTF-16, jeśli zawiera znacznik BOM. Jeśli plik UTF-16 nie ma tego znacznika, dos2unix potraktuje plik jako binarny.</p>
|
||||
|
||||
<p>Do konwersji pliku UTF-16 bez znacznika BOM można użyć opcji <code>-ul</code> lub <code>-ub</code>.</p>
|
||||
|
||||
<p>dos2unix nie zapisuje domyślnie znaku BOM w pliku wyjściowym. Z opcją <code>-b</code> dos2unix zapisuje BOM, jeśli plik wejściowy zawiera BOM.</p>
|
||||
|
||||
<p>unix2dos domyślnie zapisuje znaczniki BOM w pliku wyjściowym, jeśli plik wejściowy ma BOM. Aby usunąć BOM, można użyć opcji <code>-r</code>.</p>
|
||||
|
||||
<p>dos2unix oraz unix2dos zawsze zapisują znaczniki BOM, jeśli użyta zostanie opcja <code>-m</code>.</p>
|
||||
|
||||
<h2 id="Unikodowe-nazwy-plik-w-w-Windows">Unikodowe nazwy plików w Windows</h2>
|
||||
|
||||
<p>dos2unix ma opcjonalną obsługę odczytu i zapisu nazw plików Unicode w linii poleceń Windows. Oznacza to, że dos2unix potrafi otwierać pliki zawierające w nazwie znaki spoza domyślnej systemowej strony kodowej ANSI. Aby sprawdzić, czy dos2unix dla Windows został zbudowany z obsługą nazw plików Unicode, można wpisać <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Przy wyświetlaniu nazw plików Unicode w konsoli Windows występuje kilka problemów. Więcej informacji w opisie opcji <code>-D</code>, <code>--display-enc</code>. Nazwy plików mogą być wyświetlane błędnie na konsoli, ale pliki będą zapisywane z poprawną nazwą.</p>
|
||||
|
||||
<h2 id="Przyk-ady-Unicode">Przykłady Unicode</h2>
|
||||
|
||||
<p>Konwersja pliku UTF-16 (z BOM) z formatu Windows do uniksowego UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja pliku UTF-16LE (bez BOM) z formatu Windows do uniksowego UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja z uniksowego UTF-8 do UTF-8 z BOM dla Windows:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n wejście.txt wynik.txt</code></pre>
|
||||
|
||||
<p>Konwersja z uniksowego UTF-8 do UTF-16 dla Windows:</p>
|
||||
|
||||
<pre><code>unix2dos < wejście.txt | iconv -f UTF-8 -t UTF-16 > wynik.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 to standard urzędowy w Chinach. Obowiązkowy podzbiór standardu GB18030 jest oficjalnym wymaganiem każdego oprogramowania sprzedawanego w Chinach. Więcej pod adresem <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 jest w pełni zgodny z Unicode i może być uważany za format transformacji unikodu. Podobnie jak UTF-8, GB18030 jest zgodny z ASCII. Jest także zgodny ze stroną kodową Windows 936, znaną też jako GBK.</p>
|
||||
|
||||
<p>Pod Uniksem/Linuksem pliki UTF-16 są konwertowane do GB18030, jeśli kodowanie dla lokalizacji jest ustawione na GB18030. Uwaga: będzie to działać tylko, jeśli lokalizacja jest obsługiwana przez system. Listę obsługiwanych lokalizacji można sprawdzić poleceniem <code>locale -a</code>.</p>
|
||||
|
||||
<p>Pod Windows w celu konwersji plików UTF-16 do GB18030 należy użyć opcji <code>-gb</code>.</p>
|
||||
|
||||
<p>Pliki w kodowaniu GB18030 mogą mieć znacznik BOM, podobnie jak pliki w Unicode.</p>
|
||||
|
||||
<h1 id="PRZYK-ADY">PRZYKŁADY</h1>
|
||||
|
||||
<p>Odczyt ze standardowego wejścia i zapis na standardowe wyjście:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Konwersja i zastąpienie a.txt; konwersja i zastąpienie b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Konwersja i zastąpienie a.txt w trybie ascii:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Konwersja i zastąpienie a.txt w trybie ascii; konwersja i zastąpienie b.txt w trybie 7-bitowym:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Konwersja a.txt z formatu Mac do formatu uniksowego:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Konwersja a.txt z formatu uniksowego do formatu Mac:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Konwersja i zastąpienie a.txt z zachowaniem oryginalnego znacznika czasu:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Konwersja a.txt i zapis do e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Konwersja a.txt i zapis do e.txt z zachowaniem znacznika czasu e.txt takiego, jak a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Konwersja i zastąpienie a.txt; konwersja b.txt i zapis do e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Konwersja c.txt i zapis do e.txt; konwersja i zastąpienie a.txt; konwersja i zastąpienie b.txt; konwersja d.txt i zapis do f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="KONWERSJA-REKURENCYJNA">KONWERSJA REKURENCYJNA</h1>
|
||||
|
||||
<p>W powłoce uniksowej można użyć poleceń find(1) i xargs(1) do rekurencyjnego uruchomienia dos2unix na wszystkich plikach tekstowych w strukturze drzewa katalogów. Na przykład, aby przekonwertować wszystkie pliki .txt w drzewie katalogów poniżej katalogu bieżącego, należy napisać:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Opcja <code>-print0</code> polecenia find(1) i odpowiadająca jej opcja <code>-0</code> polecenia xargs(1) są potrzebne, jeśli istnieją pliki ze spacjami lub cudzysłowami w nazwie. W przeciwnym wypadku opcje te można pominąć. Inny sposób to użycie find(1) z opcją <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>Z poziomu linii poleceń Windows można użyć następującego polecenia:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>Użytkownicy powłoki PowerShell mogą użyć następującego polecenia w Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOKALIZACJA">LOKALIZACJA</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Główny język wybiera się zmienną środowiskową LANG. Zmienna LANG składa się z kilku części. Pierwsza część to małe litery oznaczające kod języka. Druga część jest opcjonalna i zawiera kod kraju pisany wielkimi literami, poprzedzony podkreśleniem. Jest także opcjonalna trzecia część: kodowanie znaków, poprzedzone kropką. Kilka przykładów dla powłok zgodnych ze standardem POSIX:</p>
|
||||
|
||||
<pre><code>export LANG=nl holenderski
|
||||
export LANG=nl_NL holenderski, Holandia
|
||||
export LANG=nl_BE holenderski, Belgia
|
||||
export LANG=es_ES hiszpański, Hiszpania
|
||||
export LANG=es_MX hiszpański, Meksyk
|
||||
export LANG=en_US.iso88591 angielski, USA, kodowanie Latin-1
|
||||
export LANG=en_GB.UTF-8 angielski, Wlk. Brytania, kodowanie UTF-8</code></pre>
|
||||
|
||||
<p>Pełną listę kodów języków i krajów można znaleźć w podręczniku do gettexta: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>W systemach uniksowych do uzyskania informacji dotyczących lokalizacji można użyć polecenia locale(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Przy użyciu zmiennej środowiskowej LANGUAGE można określić listę języków wg priorytetu, oddzielonych dwukropkami. dos2unix przyjmuje pierwszeństwo zmiennej LANGUAGE nad LANG. Na przykład, najpierw holenderski, następnie niemiecki: <code>LANGUAGE=nl:de</code>. Aby skorzystać z listy wg priorytetów ze zmiennej LANGUAGE, trzeba najpierw włączyć lokalizację przez ustawienie zmiennej LANG (lub LC_ALL) na wartość inną niż "C". Więcej informacji znajduje się w podręczniku do gettexta: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>W przypadku wybrania niedostępnego języka, otrzymamy standardowe, angielskie komunikaty.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Przy użyciu zmiennej środowiskowej DOS2UNIX_LOCALEDIR, można nadpisać ustawienie LOCALEDIR z czasu kompilacji. LOCALEDIR to katalog używany do znalezienia plików lokalizacji. Domyślną wartością dla GNU jest <code>/usr/local/share/locale</code>. Opcja <b>--version</b> wyświetla używaną wartość LOCALEDIR.</p>
|
||||
|
||||
<p>Przykład (dla powłoki POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="WARTO-ZWRACANA">WARTOŚĆ ZWRACANA</h1>
|
||||
|
||||
<p>W przypadku powodzenia zwracane jest zero. Jeśli wystąpi błąd systemowy, zwracany jest ostatni błąd systemowy. W przypadku innych błędów zwracane jest 1.</p>
|
||||
|
||||
<p>Wartość zwracana w trybie cichym to zawsze zero, z wyjątkiem sytuacji podania błędnych opcji linii poleceń.</p>
|
||||
|
||||
<h1 id="STANDARDY">STANDARDY</h1>
|
||||
|
||||
<p><a href="https://pl.wikipedia.org/wiki/Plik_tekstowy">https://pl.wikipedia.org/wiki/Plik_tekstowy</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://pl.wikipedia.org/wiki/Koniec_linii">https://pl.wikipedia.org/wiki/Koniec_linii</a></p>
|
||||
|
||||
<p><a href="https://pl.wikipedia.org/wiki/Unicode">https://pl.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTORZY">AUTORZY</h1>
|
||||
|
||||
<p>Benjamin Lin <blin@socs.uts.edu.au>; Bernd Johannes Wuebben (tryb mac2unix) <wuebben@kde.org>; Christian Wurll (dodawanie dodatkowej nowej linii) <wurll@ira.uka.de>; Erwin Waterlander <waterlan@xs4all.nl> (prowadzący)</p>
|
||||
|
||||
<p>Strona projektu: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Strona SourceForge: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="ZOBACZ-TAK-E">ZOBACZ TAKŻE</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
840
Agent-Windows/OGP64/usr/share/doc/dos2unix/pl/dos2unix.txt
Normal file
840
Agent-Windows/OGP64/usr/share/doc/dos2unix/pl/dos2unix.txt
Normal file
|
|
@ -0,0 +1,840 @@
|
|||
NAZWA
|
||||
dos2unix - konwerter formatu plików tekstowych między systemami DOS/Mac
|
||||
a Uniksem
|
||||
|
||||
SKŁADNIA
|
||||
dos2unix [opcje] [PLIK ...] [-n PLIK_WEJ PLIK_WYJ ...]
|
||||
unix2dos [opcje] [PLIK ...] [-n PLIK_WEJ PLIK_WYJ ...]
|
||||
|
||||
OPIS
|
||||
Pakiet dos2unix zawiera narzędzia "dos2unix" oraz "unix2dos" do
|
||||
konwersji zwykłych plików tekstowych między formatami używanymi w
|
||||
systemach DOS lub Mac a formatem uniksowym.
|
||||
|
||||
W plikach tekstowych systemu DOS/Windows oznaczenie końca linii to
|
||||
połączenie dwóch znaków: powrotu karetki (CR) i przesunięcia linii (LF).
|
||||
W uniksowych plikach tekstowych koniec linii to pojedynczy znak LF. W
|
||||
plikach tekstowych systemu Mac sprzed Mac OS X koniec linii był
|
||||
pojedynczym znakiem CR. Obecnie Mac OS wykorzystuje uniksowe końce linii
|
||||
(LF).
|
||||
|
||||
Oprócz oznaczeń końców linii dos2unix potrafi konwertować także
|
||||
kodowanie plików. Kilko stron kodowych DOS-a może być przekonwertowanych
|
||||
do uniksowego Latin-1, a windowsowy Unicode (UTF-16) do
|
||||
powszechniejszego pod Uniksem kodowania Unicode UTF-8.
|
||||
|
||||
Pliki binarne są pomijane automatycznie, chyba że konwersja zostanie
|
||||
wymuszona.
|
||||
|
||||
Pliki inne niż zwykłe, np. katalogi lub FIFO, są pomijane automatycznie.
|
||||
|
||||
Dowiązania symboliczne i ich cele są domyślnie pozostawiane bez zmian.
|
||||
Dowiązania symboliczne mogą być opcjonalnie zastępowane, albo wyjście
|
||||
może być zapisywane do celu dowiązania. Zapis do celu dowiązania
|
||||
symbolicznego nie jest obsługiwane pod Windows.
|
||||
|
||||
dos2unix powstał na podstawie narzędzia dos2unix z systemu
|
||||
SunOS/Solaris. Jest jedna istotna różnica w stosunku do oryginalnej
|
||||
wersji z SunOS-a/Solarisa: ta wersja domyślnie wykonuje konwersję w
|
||||
miejscu (tryb starego pliku), podczas gdy oryginalna obsługiwała tylko
|
||||
konwersję parami (tryb nowego pliku) - p. także opcje "-o" i "-n".
|
||||
Ponadto wersja z SunOS-a/Solarisa domyślnie wykonuje konwersję w trybie
|
||||
*iso*, podczas gdy ta wersja domyślnie wykonuje konwersję w trybie
|
||||
*ascii*.
|
||||
|
||||
OPCJE
|
||||
-- Potraktowanie wszystkich kolejnych opcji jako nazw plików. Tej opcji
|
||||
należy użyć, aby przekonwertować pliki, których nazwy zaczynają się
|
||||
od minusa. Przykładowo, aby przekonwertować plik o nazwie "-foo",
|
||||
można użyć polecenia:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Lub w trybie nowego pliku:
|
||||
|
||||
dos2unix -n -- -foo wynik.txt
|
||||
|
||||
--allow-chown
|
||||
Zezwolenie na zmianę właściciela w trybie starego pliku.
|
||||
|
||||
W przypadku użycia tej opcji, konwersja nie zostanie przerwana,
|
||||
jeśli nie ma możliwości zachowania właściciela i/lub grupy
|
||||
oryginalnego pliku w trybie starego pliku. Konwersja będzie
|
||||
kontynuowana, a przekonwertowany plik będzie miał tego samego
|
||||
właściciela, jakiego by miał w trybie nowego pliku. P. także opcje
|
||||
"-o" i "-n". Opcja jest dostępna tylko wtedy, gdy dos2unix ma
|
||||
obsługę zachowywania użytkownika i grupy plików.
|
||||
|
||||
-ascii
|
||||
Domyślny tryb konwersji. Więcej w sekcji TRYBY KONWERSJI.
|
||||
|
||||
-iso
|
||||
Konwersja między zestawami znaków DOS i ISO-8859-1. Więcej w sekcji
|
||||
TRYBY KONWERSJI.
|
||||
|
||||
-1252
|
||||
Użycie strony kodowej Windows 1252 (zachodnioeuropejskiej).
|
||||
|
||||
-437
|
||||
Użycie strony kodowej DOS 437 (US). Jest to domyślna strona kodowa
|
||||
używana przy konwersji ISO.
|
||||
|
||||
-850
|
||||
Użycie strony kodowej DOS 850 (zachodnioeuropejskiej).
|
||||
|
||||
-860
|
||||
Użycie strony kodowej DOS 860 (portugalskiej).
|
||||
|
||||
-863
|
||||
Użycie strony kodowej DOS 863 (kanadyjskiej francuskiej).
|
||||
|
||||
-865
|
||||
Użycie strony kodowej DOS 865 (nordyckiej).
|
||||
|
||||
-7 Konwersja znaków 8-bitowych do przestrzeni 7-bitowej.
|
||||
|
||||
-b, --keep-bom
|
||||
Zachowanie znaku BOM (Byte Order Makr). Jeżeli plik wejściowy
|
||||
zawiera BOM, powoduje zapisanie go w pliku wyjściowym. Jest to
|
||||
domyślne zachowanie przy konwersji na DOS-owe końce linii. P. także
|
||||
opcja "-r".
|
||||
|
||||
-c, --convmode TRYB_KONW
|
||||
Ustawienie trybu konwersji. TRYB_KONW to jeden z: *ascii*, *7bit*,
|
||||
*iso*, *mac*, przy czym domyślny jest ascii.
|
||||
|
||||
-D, --display-enc KODOWANIE
|
||||
Ustawienie kodowania wyświetlanego tekstu. KODOWANIE to jedno z:
|
||||
*ansi*, *unicode*, *unicodebom*, *utf8*, *utf8bom*, przy czym
|
||||
domyślne to ansi.
|
||||
|
||||
Ta opcja jest dostępna wyłączenie w programie dos2unix dla Windows z
|
||||
obsługą nazw plików Unicode. Nie ma wpływu na same nawy
|
||||
odczytywanych i zapisywanych plików, a jedynie na sposób ich
|
||||
wyświetlania.
|
||||
|
||||
Istnieje kilka sposobów wyświetlania tekstu w konsoli Windows w
|
||||
zależności od kodowania tekstu. Wszystkie mają swoje zalety i wady.
|
||||
|
||||
ansi
|
||||
Domyślna metoda programu dos2unix to stosowanie tekstu
|
||||
kodowanego w ANSI. Zaletą jest wsteczna zgodność. Działa z
|
||||
fontami rastrowymi, jak i TrueType. W niektórych rejonach może
|
||||
być potrzeba zmiany aktywnej strony kodowej DOS OEM na systemową
|
||||
stronę kodową Windows ANSI przy użyciu polecenia "chcp",
|
||||
ponieważ dos2unix wykorzystuje systemową stronę kodową Windows.
|
||||
|
||||
Wadą kodowania ansi jest fakt, że międzynarodowe nazwy plików ze
|
||||
znakami spoza domyślnej systemowej strony kodowej nie są
|
||||
wyświetlane właściwie. Można zamiast tego zobaczyć znak
|
||||
zapytania albo niewłaściwy symbol. Jeżeli nie pracujemy z obcymi
|
||||
nazwami plików, ta metoda jest poprawna.
|
||||
|
||||
unicode, unicodebom
|
||||
Zaletą kodowania unicode (windowsową nazwą dla UTF-16) jest
|
||||
(zwykle) właściwe wyświetlanie tekstu. Nie ma potrzeby zmiany
|
||||
aktywnej strony kodowej. Może być potrzeba zmiany fontu konsoli
|
||||
na font TrueType, aby znaki międzynarodowe były wyświetlane
|
||||
poprawnie. Jeśli znak nie jest obecny w foncie TrueType, zwykle
|
||||
widać mały kwadrat, czasami ze znakiem zapytania w środku.
|
||||
|
||||
W przypadku używania konsoli ConEmu cały tekst jest wyświetlany
|
||||
poprawnie, ponieważ ConEmu automatycznie wybiera dobry font.
|
||||
|
||||
Wadą kodowania unicode jest niezgodność z ASCII. Wyjście nie
|
||||
jest łatwe do obsłużenia w przypadku przekierowania do innego
|
||||
programu lub pliku.
|
||||
|
||||
W przypadku użycia metody "unicodebom", tekst w unikodzie jest
|
||||
poprzedzony znakiem BOM (Byte Order Mark). BOM jest wymagany do
|
||||
poprawnego przekierowania lub przekazywania przez potok w
|
||||
powłoce PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
Zaletą kodowania utf8 jest zgodność z ASCII. Trzeba ustawić font
|
||||
konsoli na font TrueType. Przy użyciu fontu TrueType tekst jest
|
||||
wyświetlany podobnie do kodowania "unicode".
|
||||
|
||||
Wadą jest fakt, że w przypadku używania domyślnego fontu
|
||||
rastrowego, wszystkie znaki spoza ASCII są wyświetlane
|
||||
niepoprawnie. Nie tylko unikodowe nazwy plików, ale także
|
||||
przetłumaczone komunikaty stają się nieczytelne. W Windows
|
||||
skonfigurowanym dla rejonu Azji Wschodniej widać dużo migotania
|
||||
konsoli w trakcie wyświetlania komunikatów.
|
||||
|
||||
W konsoli ConEmu metoda kodowania utf8 działa dobrze.
|
||||
|
||||
W przypadku użycia metody "utf8bom", tekst w UTF-8 jest
|
||||
poprzedzony znakiem BOM (Byte Order Mark). BOM jest wymagany do
|
||||
poprawnego przekierowania lub przekazywania przez potok w
|
||||
powłoce PowerShell.
|
||||
|
||||
Domyślne kodowanie można zmienić przy użyciu zmiennej środowiskowej
|
||||
DOS2UNIX_DISPLAY_ENC, ustawiając ją na "unicode", "unicodebom",
|
||||
"utf8" lub "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Dodawanie znaku końca linii do ostatniej linii, jeśli ta go nie
|
||||
zawiera. Działa przy każdej konwersji.
|
||||
|
||||
Pliki przekształcone z formatu DOS do Uniksa mogą nie mieć w
|
||||
ostatnim wierszu znaku końca linii. Istnieją edytory tekstu
|
||||
zapisujące pliki tekstowe bez znaku końca wiersza w ostatniej linii.
|
||||
Niektóre programy uniksowe mają problemy przy przetwarzaniu takich
|
||||
plików, ponieważ standard POSIX określa, że każdy wiersz pliku
|
||||
tekstowego musi kończyć się znakiem końca linii. Na przykład
|
||||
łączenie plików może nie dać oczekiwanego wyniku.
|
||||
|
||||
--error-binary
|
||||
Zwrócenie błędu, jeśli pominięto plik binarny.
|
||||
|
||||
-f, --force
|
||||
Wymuszenie konwersji plików binarnych.
|
||||
|
||||
-gb, --gb18030
|
||||
Pod Windows pliki w UTF-16 są domyślnie konwertowane do UTF-8,
|
||||
niezależnie od ustawienia lokalizacji. Ta opcja pozwala
|
||||
przekonwertować pliki w UTF-16 do GB18030. Opcja jest dostępna tylko
|
||||
pod Windows, więcej w sekcji dotyczącej GB18030.
|
||||
|
||||
-h, --help
|
||||
Wyświetlenie opisu i zakończenie.
|
||||
|
||||
-i[FLAGI], --info[=FLAGI] PLIK ...
|
||||
Wyświetlenie informacji o pliku. Konwersja nie jest wykonywana.
|
||||
|
||||
Wypisywane są następujące informacje, w tej kolejności: liczba
|
||||
DOS-owych końców linii, liczba uniksowych końców linii, liczba
|
||||
macowych końców linii, znacznik BOM, tekstowy lub binarny, nazwa
|
||||
pliku.
|
||||
|
||||
Przykładowe wyjście:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Uwaga: czasami plik binarny może być błędnie rozpoznany jako
|
||||
tekstowy. P. także opcja "-s".
|
||||
|
||||
Jeśli dodatkowo użyta jest opcja "-e" lub "--add-eol", wypisywany
|
||||
jest także rodzaj końca linii z ostatniej linii, lub "noeol", jeśli
|
||||
nie ma żadnego.
|
||||
|
||||
Przykładowe wyjście:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
Opcjonalnie można ustawić dodatkowe flagi, aby zmienić wyjście. Można dodać jedną lub więcej flag.
|
||||
|
||||
0 Wypisanie wierszy informacji o pliku zakończonych znakiem NUL
|
||||
zamiast znaku nowej linii. Pozwala to na poprawną interpretację
|
||||
nazw plików zawierających spacje lub cudzysłowy w przypadku
|
||||
użycia flagi c. Flagi należy używać w połączeniu z opcją -0 lub
|
||||
"--null" programu xargs(1).
|
||||
|
||||
d Wypisanie liczby DOS-owych końców linii.
|
||||
|
||||
u Wypisanie liczby uniksowych końców linii.
|
||||
|
||||
m Wypisanie liczby macowych końców linii.
|
||||
|
||||
b Wypisanie znacznika BOM.
|
||||
|
||||
t Wypisanie, czy plik jest tekstowy, czy binarny.
|
||||
|
||||
e Wypisanie rodzaju końca wiersza w ostatnim wierszu, lub "noeol",
|
||||
jeśli nie ma żadnego.
|
||||
|
||||
c Wypisanie tylko plików, które zostałyby przekonwertowane.
|
||||
|
||||
Z flagą "c" dos2unix wypisze tylko pliki zawierające DOS-owe
|
||||
końce linii, a unix2dos wypisze tylko nazwy plików zawierających
|
||||
uniksowe końce linii.
|
||||
|
||||
Jeśli dodatkowo użyta jest opcja "-e" lub "--add-eol",
|
||||
wypisywane są także pliki bez zakończenia ostatniej linii.
|
||||
|
||||
h Wypisanie nagłówka.
|
||||
|
||||
p Wyświetlanie nazw plików bez ścieżki.
|
||||
|
||||
Przykłady:
|
||||
|
||||
Pokazanie informacji o wszystkich plikach *.txt:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Pokazanie tylko liczby DOS-owych i uniksowych końców linii:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Pokazanie tylko znacznika BOM:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Wypisanie listy plików zawierających DOS-owe końce linii:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Wypisanie listy plików zawierających uniksowe końce linii:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Wypisanie listy plików zawierających DOS-owe końce linii lub bez
|
||||
znaku końca w ostatniej linii:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Konwersja tylko plików mających DOS-owe końce linii, pozostawienie
|
||||
pozostałych bez zmian:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Wyszukanie plików tekstowych zawierających DOS-owe końce linii:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Zachowanie znacznika czasu pliku wyjściowego takiego samego, jak
|
||||
pliku wejściowego.
|
||||
|
||||
-L, --license
|
||||
Wyświetlenie licencji programu.
|
||||
|
||||
-l, --newline
|
||||
Dodanie dodatkowego znaku końca linii.
|
||||
|
||||
dos2unix: tylko DOS-owe znaki końca linii są zamieniane na dwa
|
||||
uniksowe. W trybie Mac tylko macowe znaki końca linii są zamieniane
|
||||
na dwa uniksowe.
|
||||
|
||||
unix2dos: tylko uniksowe znaki końca linii są zamieniane na dwa
|
||||
DOS-owe. W trybie Mac uniksowe znaki końca linii są zamieniane na
|
||||
dwa macowe.
|
||||
|
||||
-m, --add-bom
|
||||
Zapisanie znacznika BOM (Byte Order Mark) w pliku wyjściowym.
|
||||
Domyślnie zapisywany jest BOM UTF-8.
|
||||
|
||||
Jeśli plik wejściowy jest w kodowaniu UTF-16 i użyto opcji "-u",
|
||||
zostanie zapisany BOM UTF-16.
|
||||
|
||||
Nigdy nie należy używać tej opcji, jeśli kodowanie wyjściowe jest
|
||||
inne niż UTF-8, UTF-16 lub GB18030. Więcej w sekcji UNICODE.
|
||||
|
||||
-n, --newfile PLIK_WEJ PLIK_WYJ ...
|
||||
Tryb nowego pliku. Konwersja PLIKU_WEJ z zapisem wyjścia do
|
||||
PLIKU_WYJ. Nazwy plików muszą być podane parami, a masek *nie*
|
||||
należy używać, gdyż *spowoduje* to utratę plików.
|
||||
|
||||
Osoba uruchamiająca konwersję w trybie nowego pliku (par) będzie
|
||||
właścicielem przekonwertowanego pliku. Prawa odczytu/zapisu nowego
|
||||
pliku będą pochodziły z praw pliku oryginalnego po odjęciu umask(1)
|
||||
osoby uruchamiającej konwersję.
|
||||
|
||||
--no-allow-chown
|
||||
Bez zezwolenia na zmianę właściciela pliku w trybie starego pliku
|
||||
(domyślne).
|
||||
|
||||
Przerwanie konwersji, jeżeli użytkownik lub grupa oryginalnego pliku
|
||||
nie może być zachowana w trybie starego pliku. P. także opcje "-o"
|
||||
oraz "-n". Ta opcja jest dostępna tylko jeśli dos2unix ma obsługę
|
||||
zachowywania użytkownika i grupy plików.
|
||||
|
||||
--no-add-eol
|
||||
Bez dodawania znaku końca linii do ostatniego wiersza, jeśli ten go
|
||||
nie zawiera (domyślne).
|
||||
|
||||
--no-error-binary
|
||||
Bez zwracania błędu, jeśli pominięto plik binarny (domyślne).
|
||||
|
||||
-O, --to-stdout
|
||||
Zapis na standardowe wyjście, jak filtr uniksowy. Opcja "-o"
|
||||
przywróci tryb starego pliku (zamianę z miejscu).
|
||||
|
||||
W połączeniu z opcją "-e" pliki mogą być właściwie łączone - bez
|
||||
połączonych ostatnich i pierwszych linii oraz znaków unikodowych BOM
|
||||
w środku połączonego pliku. Przykład:
|
||||
|
||||
dos2unix -e -O plik1.txt plik2.txt > wynik.txt
|
||||
|
||||
-o, --oldfile PLIK ...
|
||||
Tryb starego pliku. Konwersja PLIKU i nadpisanie go wyjściem.
|
||||
Program działa domyślnie w tym trybie. Można używać masek.
|
||||
|
||||
W trybie starego pliku (w miejscu) przekonwertowany plik otrzymuje
|
||||
tego samego właściciela, grupę oraz prawa odczytu/zapisu, jak plik
|
||||
oryginalny - także wtedy, gdy plik jest konwertowany przez innego
|
||||
użytkownika, mającego prawo zapisu do pliku (np. przez użytkownika
|
||||
root). Konwersja zostanie przerwana, jeśli nie będzie możliwe
|
||||
zachowanie oryginalnych wartości. Zmiana właściciela mogłaby
|
||||
oznaczać, że pierwotny właściciel nie może już odczytać pliku.
|
||||
Zmiana grupy mogłaby być zagrożeniem bezpieczeństwa, plik mógłby być
|
||||
czytelny dla niezamierzonych osób. Zachowanie właściciela, grupy i
|
||||
praw odczytu/zapisu jest obsługiwane tylko na Uniksie.
|
||||
|
||||
Aby sprawdzić, czy doswunix ma obsługę zachowywania użytkownika i
|
||||
grupy plików, można napisać "dos2unix -V".
|
||||
|
||||
Konwersja jest wykonywana zawsze przy użyciu pliku tymczasowego.
|
||||
Jeśli w trakcie konwersji wystąpi błąd, plik tymczasowy jest
|
||||
usuwany, a plik oryginalny pozostaje nietknięty. Jeśli konwersja się
|
||||
powiedzie, plik oryginalny jest zastępowany plikiem tymczasowym.
|
||||
Można mieć prawa zapisu do pliku oryginalnego, ale brak uprawnień,
|
||||
aby nadać tego samego właściciela i/lub grupę, co plik oryginalny,
|
||||
plikowi tymczasowemu. Oznacza to, że nie można zachować użytkownika
|
||||
i/lub grupy oryginalnego pliku. W takim przypadku można użyć opcji
|
||||
"--allow-chown", aby kontynuować konwersję:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Inny sposób to użycie trybu nowego pliku:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Zaletą opcji "--allow-chown" jest możliwość użycia masek oraz
|
||||
zachowanie właściciela w miarę możliwości.
|
||||
|
||||
-q, --quiet
|
||||
Tryb cichy. Pominięcie wszystkich ostrzeżeń i komunikatów. Zwracanym
|
||||
kodem jest zero, chyba że podano błędne opcje linii poleceń.
|
||||
|
||||
-r, --remove-bom
|
||||
Usunięcie znaków BOM (Byte Order Mark). Bez zapisywania BOM do pliku
|
||||
wyjściowego. Jest to domyślne zachowanie przy konwersji na uniksowe
|
||||
końce linii. P. także opcja "-b".
|
||||
|
||||
-s, --safe
|
||||
Pominięcie plików binarnych (domyślne).
|
||||
|
||||
Pomijanie plików binarnych ma na celu zapobieżenie przypadkowym
|
||||
błędom. Uwaga: wykrywanie plików binarnych nie jest w 100% odporne
|
||||
na błędy. Pliki wejściowe są przeszukiwane pod kątem symboli
|
||||
binarnych, które zwykle nie występują w plikach tekstowych. Może się
|
||||
zdarzyć, że plik binarny zawiera tylko zwykłe znaki tekstowe. Taki
|
||||
plik binarny będzie błędnie widziany jako plik tekstowy.
|
||||
|
||||
Domyślnie nie jest zwacany błąd, kiedy zostaje pominięty plik
|
||||
binarny. Jeśli użyta zostanie opcja "--error-binary", błąd jest
|
||||
zwracany.
|
||||
|
||||
-u, --keep-utf16
|
||||
Zachowanie oryginalnego kodowania pliku wejściowego UTF-16. Plik
|
||||
wyjściowy zostanie zapisany w tym samym kodowaniu UTF-16 (little-
|
||||
lub big-endian), co plik wejściowy. Zapobiega to przekształceniu do
|
||||
UTF-8. Do pliku zostanie zapisany odpowiedni znacznik BOM UTF-16. Tę
|
||||
opcję można wyłączyć opcją "-ascii".
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Przyjęcie, że format pliku wejściowego to UTF-16LE.
|
||||
|
||||
Jeśli w pliku wejściowym jest znacznik BOM (Byte Order Mark), ma on
|
||||
priorytet nad tą opcją.
|
||||
|
||||
Jeśli przyjęto błędne założenie (plik wejściowy nie jest w formacie
|
||||
UTF-16LE), a konwersja się uda, wynikiem będzie plik wyjściowy UTF-8
|
||||
ze złym tekstem. Konwersję tę można odwrócić przy użyciu polecenia
|
||||
iconv(1) do konwersji wyjścia UTF-8 z powrotem do UTF-16LE.
|
||||
Przywróci to plik oryginalny.
|
||||
|
||||
Przyjęcie UTF-16LE działa jako *tryb konwersji*. Przy przełączeniu
|
||||
na domyślny tryb *ascii* przyjęcie UTF-16LE jest wyłączane.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Przyjęcie, że format pliku wejściowego to UTF-16BE.
|
||||
|
||||
Ta opcja działa analogicznie do "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Wyświetlanie szczegółowych komunikatów. Wyświetlane śa dodatkowe
|
||||
informacje o znacznikach BOM (Byte Order Mark) oraz liczbie
|
||||
przekonwertowanych końców linii.
|
||||
|
||||
-F, --follow-symlink
|
||||
Podążanie za dowiązaniami symbolicznymi i konwertowanie ich celów
|
||||
|
||||
-R, --replace-symlink
|
||||
Zastępowanie dowiązań symbolicznych przekonwertowanymi plikami
|
||||
(oryginalne pliki docelowe pozostają bez zmian).
|
||||
|
||||
-S, --skip-symlink
|
||||
Pozostawienie dowiązań symbolicznych i celów bez zmian (domyślne).
|
||||
|
||||
-V, --version
|
||||
Wyświetlenie informacji o wersji i zakończenie.
|
||||
|
||||
TRYB MAC
|
||||
Domyślnie znaki końca linii są konwertowane z DOS-a do Uniksa i
|
||||
odwrotnie. Znaki końca linii systemu Mac nie są konwertowane.
|
||||
|
||||
W trybie Mac znaki końca linii są konwertowane z formatu Maca do Uniksa
|
||||
i odwrotnie. Znaki końca linii systemu DOS nie są zmieniane.
|
||||
|
||||
Aby uruchomić program w trybie Mac, należy użyć opcji linii poleceń "-c
|
||||
mac" albo użyć poleceń "mac2unix" lub "unix2mac".
|
||||
|
||||
TRYBY KONWERSJI
|
||||
ascii
|
||||
To jest domyślny tryb konwersji. Służy do konwersji plików
|
||||
kodowanych ASCII lub zgodnie z ASCII, np. UTF-8. Włączenie trybu
|
||||
ascii wyłącza tryby 7bit i iso.
|
||||
|
||||
Jeśli dos2unix ma obsługę UTF-16, pliki kodowane UTF-16 są
|
||||
konwertowane do bieżącego kodowania w systamach zgodnych z POSIX lub
|
||||
do UTF-8 na Windows. Włączenie trybu ascii wyłącza opcję
|
||||
zachowywania kodowania UTF-16 ("-u") oraz opcje zakładające wejście
|
||||
UTF-16 ("-ul" oraz "-ub"). Aby sprawdzić, czy dos2unix ma obsługę
|
||||
UTF-16, można wywołać "dos2unix -V". Więcej w sekcji UNICODE.
|
||||
|
||||
7bit
|
||||
W tym trybie wszystkie znaki 8-bitowe spoza ASCII (o wartościach od
|
||||
128 do 255) są konwertowane do przestrzeni 7-bitowej.
|
||||
|
||||
iso W tym trybie znaki są konwertowane między zestawem znaków DOS
|
||||
(stroną kodową) a zestawem znaków ISO-8859-1 (Latin-1) używanym na
|
||||
Uniksie. Znaki DOS-owe niemające odpowiednika w ISO-8859-1, których
|
||||
nie da się przekonwertować, są zamieniane na kropkę. To samo dotyczy
|
||||
znaków ISO-8859-1 bez odpowiednika w DOS-ie.
|
||||
|
||||
Jeśli używana jest tylko opcja "-iso", dos2unix próbuje wykryć
|
||||
aktywną stronę kodową. Jeśli nie jest to możliwe, dos2unix używa
|
||||
domyślnej strony kodowej CP437, stosowanej głównie w USA. Aby
|
||||
wymusić określoną stronę kodową, należy użyć opcji -437 (US), -850
|
||||
(zachodnioeuropejska), -860 (portugalska), -863 (kanadyjska
|
||||
francuska) lub -865 (nordycka). Ponadto obsługiwana jest strona
|
||||
kodowa Windows CP1252 (zachodnioeuropejska) przy użyciu opcji -1252.
|
||||
W przypadku innych stron kodowych można użyć narzędzia dos2unix wraz
|
||||
z iconv(1). Iconv potrafi konwertować między wieloma kodowaniami
|
||||
znaków.
|
||||
|
||||
Nigdy nie należy używać konwersji ISO na plikach tekstowych w
|
||||
Unicode. Uszkodziłaby pliki kodowane UTF-8.
|
||||
|
||||
Kilka przykładów:
|
||||
|
||||
Konwersja z domyślnej strony kodowej DOS do uniksowego Latin-1:
|
||||
|
||||
dos2unix -iso -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja ze strony kodowej DOS CP850 do uniksowego Latin-1:
|
||||
|
||||
dos2unix -850 -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja ze strony kodowej Windows CP1252 do uniksowego Latin-1:
|
||||
|
||||
dos2unix -1252 -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja ze strony kodowej Windows CP1252 do uniksowego UTF-8
|
||||
(Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 wejście.txt | dos2unix > wynik.txt
|
||||
|
||||
Konwersa z uniksowego Latin-1 do domyślnej strony kodowej DOS:
|
||||
|
||||
unix2dos -iso -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja z uniksowego Latin-1 do strony kodowej DOS CP850:
|
||||
|
||||
unix2dos -850 -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja z uniksowego Latin-1 do strony kodowej Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja z uniksowego UTF-8 (Unicode) do strony kodowej Windows
|
||||
CP1252:
|
||||
|
||||
unix2dos < wejście.txt | iconv -f UTF-8 -t CP1252 > wynik.txt
|
||||
|
||||
Więcej pod adresem <https://czyborra.com/charsets/codepages.html>
|
||||
oraz <https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Kodowania
|
||||
Istnieją różne kodowania Unicode. Pod Uniksem i Linuksem pliki Unicode
|
||||
są zwykle kodowane z użyciem UTF-8. Pod Windows pliki tekstowe Unicode
|
||||
mogą być kodowane w UTF-8, UTF-16, UTF-16 big-endian, ale przeważnie są
|
||||
kodowane w UTF-16.
|
||||
|
||||
Konwersje
|
||||
Pliki tekstowe Unicode mogą mieć znaki końca linii systemu DOS, Unix lub
|
||||
Mac, podobnie jak pliki tekstowe ASCII.
|
||||
|
||||
Wszystkie wersje dos2unix i unix2dos potrafią konwertować pliki kodowane
|
||||
UTF-8, ponieważ UTF-8 jest wstecznie zgodne z ASCII.
|
||||
|
||||
dos2unix i unix2dos z obsługą Unicode UTF-16 potrafią odczytywać pliki
|
||||
tekstowe kodowane UTF-16 little- oraz big-endian. Aby sprawdzić, czy
|
||||
dos2unix został zbudowany z obsługą UTF-16, należy napisać "dos2unix
|
||||
-V".
|
||||
|
||||
Pod Uniksem/Linuksem pliki w kodowaniu UTF-16 są konwertowane do
|
||||
kodowania znaków ustawionej lokalizacji. Kodowanie znaków dla
|
||||
lokalizacji można sprawdzić poleceniem locale(1). Jeśli konwersja nie
|
||||
jest możliwa, wystąpi błąd, a plik zostanie pominięty.
|
||||
|
||||
Pod Windows pliki UTF-16 są domyślnie konwertowane do UTF-8. Pliki
|
||||
tekstkowe w kodowaniu UTF-8 są dobrze obsługiwane zarówno pod Windows,
|
||||
jak i Uniksem/Linuksem.
|
||||
|
||||
Kodowania UTF-16 i UTF-8 są w pełni zgodne, konwersja nie spowoduje
|
||||
utraty żadnej części tekstu. W przypadku wystąpienia błędu konwersji, na
|
||||
przykład w przypadku błędu w pliku wejściowym UTF-16, plik zostanie
|
||||
pominięty.
|
||||
|
||||
W przypadku użycia opcji "-u", plik wejściowy zostanie zapisany w tym
|
||||
samym kodowaniu UTF-16, co plik wejściowy. Opcja "-u" zapobiega
|
||||
konwersji do UTF-8.
|
||||
|
||||
dos2unix oraz unix2dos nie mają opcji pozwalającej na konwersję plików
|
||||
UTF-8 do UTF-16.
|
||||
|
||||
Tryby konwersji ISO i 7-bit nie działają na plikach UTF-16.
|
||||
|
||||
Znacznik BOM
|
||||
W systemie Windows pliki tekstowe zwykle zawierają znacznik BOM (Byte
|
||||
Order Mark), ponieważ wiele programów dla Windows (w tym Notepad) dodaje
|
||||
domyślnie znaczniki BOM. Więcej informacji można znaleźć pod adresem
|
||||
<https://pl.wikipedia.org/wiki/BOM_(informatyka)>.
|
||||
|
||||
Pod Uniksem pliki Unicode zwykle nie mają znacznika BOM. Pliki tekstowe
|
||||
są traktowane jako kodowane zgodnie z kodowaniem znaków ustawionej
|
||||
lokalizacji.
|
||||
|
||||
dos2unix potrafi wykryć tylko, czy plik jest w formacie UTF-16, jeśli
|
||||
zawiera znacznik BOM. Jeśli plik UTF-16 nie ma tego znacznika, dos2unix
|
||||
potraktuje plik jako binarny.
|
||||
|
||||
Do konwersji pliku UTF-16 bez znacznika BOM można użyć opcji "-ul" lub
|
||||
"-ub".
|
||||
|
||||
dos2unix nie zapisuje domyślnie znaku BOM w pliku wyjściowym. Z opcją
|
||||
"-b" dos2unix zapisuje BOM, jeśli plik wejściowy zawiera BOM.
|
||||
|
||||
unix2dos domyślnie zapisuje znaczniki BOM w pliku wyjściowym, jeśli plik
|
||||
wejściowy ma BOM. Aby usunąć BOM, można użyć opcji "-r".
|
||||
|
||||
dos2unix oraz unix2dos zawsze zapisują znaczniki BOM, jeśli użyta
|
||||
zostanie opcja "-m".
|
||||
|
||||
Unikodowe nazwy plików w Windows
|
||||
dos2unix ma opcjonalną obsługę odczytu i zapisu nazw plików Unicode w
|
||||
linii poleceń Windows. Oznacza to, że dos2unix potrafi otwierać pliki
|
||||
zawierające w nazwie znaki spoza domyślnej systemowej strony kodowej
|
||||
ANSI. Aby sprawdzić, czy dos2unix dla Windows został zbudowany z obsługą
|
||||
nazw plików Unicode, można wpisać "dos2unix -V".
|
||||
|
||||
Przy wyświetlaniu nazw plików Unicode w konsoli Windows występuje kilka
|
||||
problemów. Więcej informacji w opisie opcji "-D", "--display-enc". Nazwy
|
||||
plików mogą być wyświetlane błędnie na konsoli, ale pliki będą
|
||||
zapisywane z poprawną nazwą.
|
||||
|
||||
Przykłady Unicode
|
||||
Konwersja pliku UTF-16 (z BOM) z formatu Windows do uniksowego UTF-8:
|
||||
|
||||
dos2unix -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja pliku UTF-16LE (bez BOM) z formatu Windows do uniksowego
|
||||
UTF-8:
|
||||
|
||||
dos2unix -ul -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja z uniksowego UTF-8 do UTF-8 z BOM dla Windows:
|
||||
|
||||
unix2dos -m -n wejście.txt wynik.txt
|
||||
|
||||
Konwersja z uniksowego UTF-8 do UTF-16 dla Windows:
|
||||
|
||||
unix2dos < wejście.txt | iconv -f UTF-8 -t UTF-16 > wynik.txt
|
||||
|
||||
GB18030
|
||||
GB18030 to standard urzędowy w Chinach. Obowiązkowy podzbiór standardu
|
||||
GB18030 jest oficjalnym wymaganiem każdego oprogramowania sprzedawanego
|
||||
w Chinach. Więcej pod adresem <https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 jest w pełni zgodny z Unicode i może być uważany za format
|
||||
transformacji unikodu. Podobnie jak UTF-8, GB18030 jest zgodny z ASCII.
|
||||
Jest także zgodny ze stroną kodową Windows 936, znaną też jako GBK.
|
||||
|
||||
Pod Uniksem/Linuksem pliki UTF-16 są konwertowane do GB18030, jeśli
|
||||
kodowanie dla lokalizacji jest ustawione na GB18030. Uwaga: będzie to
|
||||
działać tylko, jeśli lokalizacja jest obsługiwana przez system. Listę
|
||||
obsługiwanych lokalizacji można sprawdzić poleceniem "locale -a".
|
||||
|
||||
Pod Windows w celu konwersji plików UTF-16 do GB18030 należy użyć opcji
|
||||
"-gb".
|
||||
|
||||
Pliki w kodowaniu GB18030 mogą mieć znacznik BOM, podobnie jak pliki w
|
||||
Unicode.
|
||||
|
||||
PRZYKŁADY
|
||||
Odczyt ze standardowego wejścia i zapis na standardowe wyjście:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Konwersja i zastąpienie a.txt; konwersja i zastąpienie b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Konwersja i zastąpienie a.txt w trybie ascii:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Konwersja i zastąpienie a.txt w trybie ascii; konwersja i zastąpienie
|
||||
b.txt w trybie 7-bitowym:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Konwersja a.txt z formatu Mac do formatu uniksowego:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Konwersja a.txt z formatu uniksowego do formatu Mac:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Konwersja i zastąpienie a.txt z zachowaniem oryginalnego znacznika
|
||||
czasu:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Konwersja a.txt i zapis do e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Konwersja a.txt i zapis do e.txt z zachowaniem znacznika czasu e.txt
|
||||
takiego, jak a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Konwersja i zastąpienie a.txt; konwersja b.txt i zapis do e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Konwersja c.txt i zapis do e.txt; konwersja i zastąpienie a.txt;
|
||||
konwersja i zastąpienie b.txt; konwersja d.txt i zapis do f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
KONWERSJA REKURENCYJNA
|
||||
W powłoce uniksowej można użyć poleceń find(1) i xargs(1) do
|
||||
rekurencyjnego uruchomienia dos2unix na wszystkich plikach tekstowych w
|
||||
strukturze drzewa katalogów. Na przykład, aby przekonwertować wszystkie
|
||||
pliki .txt w drzewie katalogów poniżej katalogu bieżącego, należy
|
||||
napisać:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
Opcja "-print0" polecenia find(1) i odpowiadająca jej opcja -0 polecenia
|
||||
xargs(1) są potrzebne, jeśli istnieją pliki ze spacjami lub cudzysłowami
|
||||
w nazwie. W przeciwnym wypadku opcje te można pominąć. Inny sposób to
|
||||
użycie find(1) z opcją "-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
Z poziomu linii poleceń Windows można użyć następującego polecenia:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
Użytkownicy powłoki PowerShell mogą użyć następującego polecenia w
|
||||
Windows PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOKALIZACJA
|
||||
LANG
|
||||
Główny język wybiera się zmienną środowiskową LANG. Zmienna LANG
|
||||
składa się z kilku części. Pierwsza część to małe litery oznaczające
|
||||
kod języka. Druga część jest opcjonalna i zawiera kod kraju pisany
|
||||
wielkimi literami, poprzedzony podkreśleniem. Jest także opcjonalna
|
||||
trzecia część: kodowanie znaków, poprzedzone kropką. Kilka
|
||||
przykładów dla powłok zgodnych ze standardem POSIX:
|
||||
|
||||
export LANG=nl holenderski
|
||||
export LANG=nl_NL holenderski, Holandia
|
||||
export LANG=nl_BE holenderski, Belgia
|
||||
export LANG=es_ES hiszpański, Hiszpania
|
||||
export LANG=es_MX hiszpański, Meksyk
|
||||
export LANG=en_US.iso88591 angielski, USA, kodowanie Latin-1
|
||||
export LANG=en_GB.UTF-8 angielski, Wlk. Brytania, kodowanie UTF-8
|
||||
|
||||
Pełną listę kodów języków i krajów można znaleźć w podręczniku do
|
||||
gettexta:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
W systemach uniksowych do uzyskania informacji dotyczących
|
||||
lokalizacji można użyć polecenia locale(1).
|
||||
|
||||
LANGUAGE
|
||||
Przy użyciu zmiennej środowiskowej LANGUAGE można określić listę
|
||||
języków wg priorytetu, oddzielonych dwukropkami. dos2unix przyjmuje
|
||||
pierwszeństwo zmiennej LANGUAGE nad LANG. Na przykład, najpierw
|
||||
holenderski, następnie niemiecki: "LANGUAGE=nl:de". Aby skorzystać z
|
||||
listy wg priorytetów ze zmiennej LANGUAGE, trzeba najpierw włączyć
|
||||
lokalizację przez ustawienie zmiennej LANG (lub LC_ALL) na wartość
|
||||
inną niż "C". Więcej informacji znajduje się w podręczniku do
|
||||
gettexta:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
W przypadku wybrania niedostępnego języka, otrzymamy standardowe,
|
||||
angielskie komunikaty.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Przy użyciu zmiennej środowiskowej DOS2UNIX_LOCALEDIR, można
|
||||
nadpisać ustawienie LOCALEDIR z czasu kompilacji. LOCALEDIR to
|
||||
katalog używany do znalezienia plików lokalizacji. Domyślną
|
||||
wartością dla GNU jest "/usr/local/share/locale". Opcja --version
|
||||
wyświetla używaną wartość LOCALEDIR.
|
||||
|
||||
Przykład (dla powłoki POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
WARTOŚĆ ZWRACANA
|
||||
W przypadku powodzenia zwracane jest zero. Jeśli wystąpi błąd systemowy,
|
||||
zwracany jest ostatni błąd systemowy. W przypadku innych błędów zwracane
|
||||
jest 1.
|
||||
|
||||
Wartość zwracana w trybie cichym to zawsze zero, z wyjątkiem sytuacji
|
||||
podania błędnych opcji linii poleceń.
|
||||
|
||||
STANDARDY
|
||||
<https://pl.wikipedia.org/wiki/Plik_tekstowy>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://pl.wikipedia.org/wiki/Koniec_linii>
|
||||
|
||||
<https://pl.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTORZY
|
||||
Benjamin Lin <blin@socs.uts.edu.au>; Bernd Johannes Wuebben (tryb
|
||||
mac2unix) <wuebben@kde.org>; Christian Wurll (dodawanie dodatkowej nowej
|
||||
linii) <wurll@ira.uka.de>; Erwin Waterlander <waterlan@xs4all.nl>
|
||||
(prowadzący)
|
||||
|
||||
Strona projektu: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Strona SourceForge: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
ZOBACZ TAKŻE
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/pt_BR/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/pt_BR/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - Conversor de formato de arquivo texto de DOS/Mac para Unix e vice-versa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NOME">NOME</a></li>
|
||||
<li><a href="#SINOPSE">SINOPSE</a></li>
|
||||
<li><a href="#DESCRI-O">DESCRIÇÃO</a></li>
|
||||
<li><a href="#OP-ES">OPÇÕES</a></li>
|
||||
<li><a href="#MODO-MAC">MODO MAC</a></li>
|
||||
<li><a href="#MODOS-DE-CONVERS-O">MODOS DE CONVERSÃO</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Codifica-es">Codificações</a></li>
|
||||
<li><a href="#Convers-o">Conversão</a></li>
|
||||
<li><a href="#Marca-de-ordem-de-byte">Marca de ordem de byte</a></li>
|
||||
<li><a href="#Nomes-de-arquivos-Unicode-no-Windows">Nomes de arquivos Unicode no Windows</a></li>
|
||||
<li><a href="#Exemplos-de-Unicode">Exemplos de Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EXEMPLOS">EXEMPLOS</a></li>
|
||||
<li><a href="#CONVERS-O-RECURSIVA">CONVERSÃO RECURSIVA</a></li>
|
||||
<li><a href="#LOCALIZA-O">LOCALIZAÇÃO</a></li>
|
||||
<li><a href="#VALOR-RETORNADO">VALOR RETORNADO</a></li>
|
||||
<li><a href="#PADR-ES">PADRÕES</a></li>
|
||||
<li><a href="#AUTORES">AUTORES</a></li>
|
||||
<li><a href="#VEJA-TAMB-M">VEJA TAMBÉM</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NOME">NOME</h1>
|
||||
|
||||
<p>dos2unix - Conversor de formato de arquivo texto de DOS/Mac para Unix e vice-versa</p>
|
||||
|
||||
<h1 id="SINOPSE">SINOPSE</h1>
|
||||
|
||||
<pre><code>dos2unix [opções] [ARQUIVO ...] [-n ARQENT ARQSAÍDA ...]
|
||||
unix2dos [opções] [ARQUIVO ...] [-n ARQENT ARQSAÍDA ...]</code></pre>
|
||||
|
||||
<h1 id="DESCRI-O">DESCRIÇÃO</h1>
|
||||
|
||||
<p>O pacote dos2unix inclui utilitários de <code>dos2unix</code> e <code>unix2dos</code> para converter arquivos texto nos formatos DOS ou Mac para formato Unix e vice-versa.</p>
|
||||
|
||||
<p>Em arquivos texto DOS/Windows uma quebra de linha, também conhecida como nova linha, é uma combinação de dois caracteres: um Carriage Return (CR) seguido por um Line Feed (LF). Em arquivos texto do Unix uma quebra de linha é um único caractere: o Line Feed (LF). Em arquivos texto do Mac, anteriores ao Mac OS X, uma quebra de linha era um único caractere Carriage Return (CR). Hoje em dia, Mac OS usa quebras de linha no estilo do Unix (LF).</p>
|
||||
|
||||
<p>Além das quebras de linhas, dos2unix também pode converter as codificações de arquivos. Algumas poucas páginas podem ser convertidos para Latin-1 para Unix. E arquivos Unicode do Windows (UTF-16) podem ser convertidos para arquivos Unicode do Unix (UTF-8).</p>
|
||||
|
||||
<p>Arquivos binários são ignorados automaticamente, a menos que a conversão seja forçada.</p>
|
||||
|
||||
<p>Arquivos não regulares, tais como diretórios e FIFOs, são ignorados automaticamente.</p>
|
||||
|
||||
<p>Ligações simbólicas e seus alvos são por padrão mantidas intocáveis. Ligações simbólicas podem opcionalmente ser substituídas, ou a saída pode ser escrita para o alvo das ligações simbólicas. Não há suporte às ligações simbólicas do Windows.</p>
|
||||
|
||||
<p>O dos2unix foi modelado seguindo dos2unix do SunOS/Solaris. Há uma diferença importante em relação à versão original do SunOS/Solaris. Por padrão, essa versão faz conversão no-lugar (modo de arquivo antigo), enquanto a versão original do SunOS/Solaris fornecia suporte apenas a conversão pareada (modo de novo arquivo). Veja também as opções <code>-o</code> e <code>-n</code>. Uma outra diferença é que a versão do SunOS/Solaris usa, por padrão, a conversão de modo do <i>iso</i> enquanto esta versão usa o do <i>ascii</i>.</p>
|
||||
|
||||
<h1 id="OP-ES">OPÇÕES</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Trata as opções seguintes como nomes de arquivos. Use essa opção se você quiser converter arquivos cujos nomes iniciam com um traço. Por exemplo, para converter um arquivo chamado "foo", você pode usar este comando:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Ou em modo de novo arquivo:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo saída.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Permite alteração da propriedade de arquivo no modo de arquivo antigo.</p>
|
||||
|
||||
<p>Quando esta opção é usada, a conversão não será abortada quando a propriedade do usuário e/ou do grupo do arquivo original não puder ser preservada no modo de arquivo antigo. A conversão continuará e o arquivo convertido receberá a mesma propriedade nova como se tivesse convertido no modo de novo arquivo. Veja também as opções <code>-o</code> e <code>-n</code>. Esta opção só está disponível se o dos2unix oferecer suporte a preservação da propriedade do usuário e do grupo de arquivos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo de conversão padrão. Veja também a seção MODOS DE CONVERSÃO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversão entre conjunto de caractere do DOS e ISO-8859-1. Veja também a seção MODOS DE CONVERSÃO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 1252 do Windows (Europa ocidental).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 437 do DOS (EUA). Essa é a página de código padrão usada para conversão ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 850 do DOS (Europa ocidental).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 860 do DOS (Português).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 863 do DOS (Francês do Canadá).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Usa a página de código 865 do DOS (Nórdico).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Converte caracteres de 8 bits para espaço de 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mantém marca de ordem de bytes (BOM). Quando o arquivo de entrada possuir um BOM, escreve um BOM no arquivo de saída. Esse é o comportamento padrão ao converter para quebras de linha do DOS. Veja também a opção <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-MODOCONV"><b>-c, --convmode MODOCONV</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Define o modo de conversão, sendo MODOCONV um dentre: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> com ascii sendo o padrão.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-CODIFICA-O"><b>-D, --display-enc CODIFICAÇÃO</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Define a codificação do texto exibido, sendo CODIFICAÇÃO um dentre: <i>ansi</i>, <i>unicode</i>, <i>utf8</i>, <i>utf8bom</i> com ansi sendo o padrão.</p>
|
||||
|
||||
<p>Essa opção está disponível apenas no dos2unix para Windows com suporte a nome de arquivo em Unicode. Essa opção não possui efeito nos nomes de arquivos lidos e escritos, apenas em como eles são exibidos.</p>
|
||||
|
||||
<p>Há vários métodos para exibir texto em um console Windows baseado na codificação do texto. Todos eles possuem suas próprias vantagens e desvantagens.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>O método padrão do dos2unix é usar o texto codificado em ANSI. A sua vantagem é a compatibilidade reversa. Ele funciona com fontes raster e TrueType. Em algumas regiões você pode precisar alterar a página de código OEM do DOS para ANSI do sistema Windows usando o comando <code>chcp</code>, porque dos2unix usa a página de código do sistema Windows.</p>
|
||||
|
||||
<p>A desvantagem do ansi é que nomes de arquivos internacionais com caracteres fora a página de código padrão do sistema não são exibidos apropriadamente. Você verá um sinal de interrogação, ou um símbolo incorreto. Quando você não utiliza nomes de arquivos estrangeiros, esse método funciona bem.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>A vantagem da codificação do unicode (o nome Windows para UTF-16) é que o texto é normalmente exibido apropriadamente. Não há necessidade para alterar a página de código ativa. Você pode precisar definir a fonte do console para uma fonte TrueType para que caracteres internacionais sejam exibidos apropriadamente. Quando um caractere não está incluído na fonte TrueType, geralmente você vê um pequeno quadrado, algumas vezes com um sinal de interrogação nele.</p>
|
||||
|
||||
<p>Quando você usa o console ConEmu todo texto é exibido apropriadamente, porque o ConEmu seleciona automaticamente um fonte boa.</p>
|
||||
|
||||
<p>A desvantagem do unicode é que ele não é compatível com ASCII. A saída não é fácil de lidar quando você o redireciona para um outro programa.</p>
|
||||
|
||||
<p>Quando o método <unicodebom> é usado, o texto Unicode será precedido com um BOM (Byte Order Mark, ou marca de ordem de byte). Um BOM é necessário para o redirecionamento, ou "piping", correto no PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>A vantagem do utf8 é que ele é compatível com ASCII. Você precisa definir a fonte do console para uma fonte TrueType. Com uma fonte TrueType, o texto é exibido similar a uma codificação <code>unicode</code>.</p>
|
||||
|
||||
<p>A desvantagem é que quando você usa a fonte "raster" padrão, caracteres não-ASCII são exibidos incorretamente. Não apenas nomes de arquivos unicode, mas também mensagens traduzidas ficam ilegíveis. No Windows configurado para uma região leste da Ásia, você pode ver muitas falhas no console quando as mensagens são exibidas.</p>
|
||||
|
||||
<p>Em um console ConEmu, o método de codificação utf8 funciona bem.</p>
|
||||
|
||||
<p>Quando o método <utf8bom> é usado, o texto UTF-8 será precedido com um BOM (Byte Order Mark, ou marca de ordem de byte). Um BOM é necessário para o redirecionamento, ou "piping", correto no PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>A codificação padrão pode ser alterada com a variável de ambiente DOS2UNIX_DISPLAY_ENC definindo-a para <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> ou <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adiciona uma quebra de linha à última linha se não houver uma. Isso funciona para todas as conversões.</p>
|
||||
|
||||
<p>Um arquivo convertido do formato DOS para Unix pode não ter uma quebra de linha na última linha. Existem editores de texto que escrevem arquivos de texto sem uma quebra de linha na última linha. Alguns programas Unix têm problemas para processar esses arquivos, porque o padrão POSIX define que cada linha em um arquivo de texto deve terminar com um caractere de nova linha de terminação. Por exemplo, concatenar arquivos pode não dar o resultado esperado.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Retorna um erro se um arquivo binário for ignorado.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Força a conversão de arquivos binários.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>No Windows, arquivos UTF-16 são convertidos, por padrão, para UTF-8, independentemente da localização definida. Use esta opção para converter arquivos UTF-16 para GB18030. Essa opção está disponível apenas no Windows. Veja também a seção GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe ajuda e sai.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-OP-ES---info-OP-ES-ARQUIVO"><b>-i[OPÇÕES], --info[=OPÇÕES] ARQUIVO ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe informação do arquivo. Nenhuma conversão é feita.</p>
|
||||
|
||||
<p>A seguinte informação é exibida, nesta ordem: número de quebras de linha do DOS, número de quebras de linha do Unix, número de quebras de linha do Mac, marca de ordem de byte, "text" ou "binary", nome de arquivo.</p>
|
||||
|
||||
<p>Exemplo de saída:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Note que em algumas vezes um arquivo binário pode ser confundido com um arquivo texto. Veja também a opção <code>-s</code>.</p>
|
||||
|
||||
<p>Se, além disso, a opção <code>-e</code> ou <code>--add-eol</code> for usada, o tipo de quebra de linha da última linha também será impresso, ou <code>noeol</code> se não houver nenhuma.</p>
|
||||
|
||||
<p>Exemplo de saída:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Opcionalmente, opções extra podem ser definidas para alterar a saída. Uma ou mais opções podem ser adicionadas.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe as linhas de informações de arquivo seguido por um caractere nulo em vez de um caractere de nova linha. Isso habilita interpretação correta de nomes de arquivo com espaços ou aspas quando a opção c é usada. Use essa opção na combinação com opções <code>-0</code> ou <code>--null</code> do xargs(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe o número de quebras de linhas do DOS.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe o número de quebras de linhas do Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe o número de quebras de linhas do Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe a marca de ordem de byte.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe se arquivo é texto ou binário.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Imprime o tipo de quebra de linha da última linha, ou <code>noeol</code> se não houver nenhuma.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe apenas os arquivos que seriam convertidos.</p>
|
||||
|
||||
<p>Com a opção <code>c</code>, dos2unix vai exibir apenas os arquivos que contêm quebras de linha do DOS, unix2dos vai exibir apenas os nomes de arquivos que contêm quebras de linha do Unix.</p>
|
||||
|
||||
<p>Se, além disso, a opção <code>-e</code> ou <code>--add-eol</code> for usada, os arquivos que não tiverem uma quebra de linha na última linha também serão impressos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe um cabeçalho.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mostra nomes de arquivos sem caminho.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Exemplos:</p>
|
||||
|
||||
<p>Mostra informação sobre todos os arquivos *.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Mostra apenas o número de quebras de linha DOS e Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Mostra apenas a marca de ordem de byte:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Lista os arquivos que possuem quebras de linha do DOS:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Lista os arquivos que possuem quebras de linha do Unix:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Lista os arquivos que têm quebras de linha DOS ou não têm quebra de linha na última linha:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Converte apenas arquivos que possuem quebras de linha do DOS e não altera outros arquivos:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Localiza arquivos de texto que possuam quebras de linha do DOS:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mantém a marca da data do arquivo de saída igual ao do arquivo de entrada.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe a licença do programa.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adiciona nova linha adicional.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Apenas quebras de linha do DOS são alteradas para duas quebras de linha do Unix. No modo Mac, apenas quebras de linha do Mac são alterados para duas quebras de linha do Unix.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Apenas quebras de linha do Unix são alteradas para duas quebras de linha do DOS. No modo Mac, quebras de linha do Unix são alteradas para duas quebras de linha do Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Escreve uma marca de ordem de byte (BOM) no arquivo de saída. Por padrão, um BOM UTF-8 é escrito.</p>
|
||||
|
||||
<p>Quando o arquivo de entrada é UTF-16, e a opção <code>-u</code> é usada, um BOM UTF-16 será escrito.</p>
|
||||
|
||||
<p>Nunca use essa opção quando a codificação de saída é outra além de UTF-8, UTF-16 ou GB18030. Veja também a seção UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-ARQENT-ARQSA-DA"><b>-n, --newfile ARQENT ARQSAÍDA ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo de novo arquivo. Converte o arquivo ARQENT e escreve a saída para o arquivo ARQSAÍDA. Os nomes de arquivos devem ser fornecidos em pares e nome coringa <i>não</i> deveriam ser usados ou você <i>vai</i> perder seus arquivos.</p>
|
||||
|
||||
<p>A pessoa que começa a conversão em modo de novo arquivo (pareado) será o dono do arquivo convertido. As permissões de leitura/escrita do novo arquivo serão as permissões do arquivo original menos a umask(1) da pessoa que executa a conversão.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Não permite alteração da propriedade do arquivo no modo de arquivo antigo (padrão).</p>
|
||||
|
||||
<p>Aborta a conversão quando a propriedade do usuário e/ou do grupo do arquivo original não puder ser preservada no modo de arquivo antigo. Veja também as opções <code>-o</code> e <code>-n</code>. Esta opção só está disponível se o dos2unix oferecer suporte à preservação da propriedade do usuário e do grupo de arquivos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Não adiciona uma quebra de linha à última linha se não houver uma (padrão).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Não retorna um erro se um arquivo binário é ignorado (padrão).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Escreve na saída padrão, como um filtro Unix. Use a opção <code>-o</code> para voltar ao modo de arquivo antigo (in-place).</p>
|
||||
|
||||
<p>Combinado com a opção <code>-e</code>, os arquivos podem ser concatenados corretamente. Nenhuma última e primeira linhas mescladas e nenhuma marca de ordem de bytes Unicode no meio do arquivo concatenado. Exemplo:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O arquivo1.txt arquivo2.txt > saída.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-ARQUIVO"><b>-o, --oldfile ARQUIVO ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo de arquivo antigo. Converte o arquivo ARQUIVO e o sobrescreve com a saída. O programa, por padrão, executa neste modo. Nomes coringas podem ser usados.</p>
|
||||
|
||||
<p>No modo de arquivo antigo (no-lugar) o arquivo convertido recebe no mesmo dono, grupo e permissões de leitura/escrita que o arquivo original. Também, quando o arquivo é convertido por outro usuário que tenha permissões de escrita no arquivo (ex.: usuário root). A conversão será abortada quando não for possível preservar os valores originais. Alteração do dono pode significar que o dono original não é mais capaz de ler o arquivo. Alteração do grupo pode ser um risco para a segurança, pois o arquivo pode ficar legível para pessoas cujo acesso não é desejado. Preservação do dono, grupo e permissões de leitura/escrita tem suporte apenas no Unix.</p>
|
||||
|
||||
<p>Para verificar se dos2unix oferece suporte à preservação da propriedade de usuário e de grupo de arquivos, digite <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>A conversão sempre é feita através de um arquivo temporário. Quando um erro ocorre no meio da conversão, o arquivo temporário é excluído e o arquivo original permanece intacto. Quando a conversão é bem sucedida, o arquivo original é substituído pelo arquivo temporário. Você pode ter permissão de gravação no arquivo original, mas nenhuma permissão para colocar a mesma propriedade de usuário e/ou de grupo no arquivo temporário como o arquivo original. Isso significa que você não consegue preservar a propriedade de usuário e/ou de grupo do arquivo original. Neste caso, você pode usar a opção <code>-allow-chown</code> para continuar com a conversão:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Outra opção é usar o novo modo de arquivo:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>A vantagem da opção <code>--allow-chown</code> é que você pode usar coringas e as informações de propriedade serão preservadas quando possível.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modo quieto. Suprime todos os avios e mensagens. O valor retornado é zero. Exceto quando opções de linha de comando erradas forem usadas.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Remove marca de ordem de bytes (BOM). Não escreve um BOM no arquivo de saída. Esse é o comportamento padrão ao converter para quebras de linha Unix. Veja também a opção <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ignora arquivo binários (padrão).</p>
|
||||
|
||||
<p>A ação de ignorar arquivos binários é feita para evitar equívocos acidentais. Fique ciente de que a detecção de arquivos binários não é 100% à prova de erros. Arquivos de entrada são analisados por símbolos binários que, geralmente, não são encontrados em arquivos textos. É possível que um arquivo binário contenha apenas caracteres de texto normais. tal arquivo binário pode ser acidentalmente visto como um arquivo de texto.</p>
|
||||
|
||||
<p>Por padrão, não é retornado nenhum erro quando um arquivo binário é ignorado. Quando a opção C <--error-binary> é usada, é retornado um erro.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Presume que o formato de arquivo de entrada é UTF-16LE.</p>
|
||||
|
||||
<p>Quando há uma marca de ordem de byte no arquivo de entrada, esta tem prioridade sobre essa opção.</p>
|
||||
|
||||
<p>Quando você fizer uma presunção equivocada (o arquivo de entrada não estava no formato UTF-16LE) e a conversão funcionar, você terá um arquivo de saída UTF-8 com texto errado. Você pode desfazer a conversão errada com iconv(1) pela conversão do arquivo de saída UTF-8 de volta para UTF-16LE. Isso vai trazer de volta o arquivo para o original.</p>
|
||||
|
||||
<p>A presunção de UTF-16LE funciona como um <i>modo de conversão</i>. Ao alternara o modo <i>ascii</i> padrão, a presunção de UTF-16LE é desativada.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Presume que o formato de arquivo de entrada é UTF-16BE.</p>
|
||||
|
||||
<p>Essa opção funciona o mesmo que a opção <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe mensagens detalhadas. Informação extra é exibida sobre marcas de ordem de byte e a quantidade de quebras de linha convertidas.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Segue ligações simbólicas e converte os alvos.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Substitui ligações simbólicas com arquivos convertidos (arquivos alvo originais permanecem inalterados).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mentém ligações simbólicas e alvos inalterados (padrão).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Exibe informação da versão e sai.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MODO-MAC">MODO MAC</h1>
|
||||
|
||||
<p>Por padrão, as quebras de linha são convertidas de DOS para Unix e vice-versa. As quebras de linha do Mac não são convertidas.</p>
|
||||
|
||||
<p>No modo Mac, quebras de linha são convertidas de Mac para Unix e vice-versa. Quebras de linha do DOS não são alteradas.</p>
|
||||
|
||||
<p>Para executar no modo Mac, use a opção de linha de comando <code>-c mac</code> ou use os comandos <code>mac2unix</code> ou <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="MODOS-DE-CONVERS-O">MODOS DE CONVERSÃO</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Este é o modo de conversão padrão. Este modo é para converter arquivos codificados ASCII e compatíveis com ASCII, como UTF-8. Habilitar o modo <b>ascii</b> desabilita o modo <b>7bit</b> e <b>iso</b>.</p>
|
||||
|
||||
<p>Se dos2unix tiver suporte a UTF-16, os arquivos codificados em UTF-16 serão convertidos para a codificação de caracteres de localidade atual em sistemas POSIX e para UTF-8 no Windows. Habilitar o modo <b>ascii</b> desabilita a opção de manter a codificação UTF-16 (<code>-u</code>) e as opções para assumir a entrada UTF-16 (<code>-ul</code> e <code>-ub</code>). Para ver se dos2unix tem suporte a UTF-16, digite <code>dos2unix -V</code>. Veja também a seção UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Neste modo todos os caracteres não-ASCII de 8 bits (com valores entre 128 e 255) são convertidos para um espaço de 7 bits.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Caracteres são convertidos entre um conjunto de caracteres do DOS (página de código) e conjunto de caracteres ISO-8859-1 (Latin-1) no Unix. Caracteres de DOS sem um equivalente ISO-8859-1, para os quais a conversão não é possível, são convertidos para um ponto. O mesmo vale para caracteres ISO-8859-1 sem a contraparte DOS.</p>
|
||||
|
||||
<p>Quando apenas a opção <code>-iso</code> for usada, dos2unix vai tentar determinar a página de código ativa. Quando isso não for possível, dos2unix vai usar a página de código padrão CP437, a qual é usada principalmente nos EUA. Para forçar uma página de código específica, use as opções <code>-437</code> (EUA), <code>-850</code> (Europeu oriental), <code>-860</code> (Português), <code>-863</code> (Franco-canadense) ou <code>-865</code> (Nórdico). Também há suporte à página de código do Windows CP1252 (Europeu ocidental) com a opção <code>-1252</code>. Para outras páginas de código, use dos2unix em combinação cm iconv(1). Iconv pode converter entre uma lista grande de codificações de caracteres.</p>
|
||||
|
||||
<p>Nunca use conversão ISO em arquivos textos Unicode. Isso vai corromper os arquivos codificados em UTF-8.</p>
|
||||
|
||||
<p>Alguns exemplos:</p>
|
||||
|
||||
<p>Conversão da página de código padrão do DOS para Latin-1 do Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão da CP850 do DOS para Latin-1 do Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão da CP1252 do Windows para Latin-1 do Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão da CP1252 do Windows para UTF-8 (Unicode) do Unix:</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 entrada.txt | dos2unix > saída.txt</code></pre>
|
||||
|
||||
<p>Conversão de Latin-1 do Unix para página de código padrão do DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão do Latin-1 do Unix para CP850 do DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão do Latin-1 do unix para CP1252 do Windows:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão do UTF-8 (Unicode) do Unix para CP1252 do Windows:</p>
|
||||
|
||||
<pre><code>unix2dos < entrada.txt | iconv -f UTF-8 -t CP1252 > saída.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Codifica-es">Codificações</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Convers-o">Conversão</h2>
|
||||
|
||||
<p>Arquivos texto em Unicode pode ter quebras de linha DOS, Unix ou Mac, como arquivos texto em ASCII.</p>
|
||||
|
||||
<p>Todas as versões do dos2unix e unix2dos podem converter arquivos codificados em UTF-8 porque UTF-8 foi projetado para ter compatibilidade reversa com ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>No Unix/Linux, arquivos codificados em UTF-16 são convertidos para a codificação de caracteres do localização. Use o comando locale(1) para descobrir qual é a codificação de caracteres da localização. Quando a conversão não for possível, ocorrerá um erro e o arquivo será ignorado.</p>
|
||||
|
||||
<p>No Windows, arquivos UTF-16 são convertidos, por padrão, para UTF-8. Arquivos texto formatados em UTF-8 possuem ótimo suporte em ambos Windows e Unix/Linux.</p>
|
||||
|
||||
<p>Codificações UTF-16 e UTF-8 são completamente compatíveis, não havendo qualquer perda de texto na conversão. Quando um erro de conversão UTF-16 para UTF-8 ocorre, por exemplo quando o arquivo de entrada UTF-16 contém um erro, o arquivo será ignorado.</p>
|
||||
|
||||
<p>Quando a opção <code>-u</code> é usada, o arquivo de saída será escrito na mesma codificação UTF-16 que o arquivo de saída. A opção <code>-u</code> evita conversão para UTF-8.</p>
|
||||
|
||||
<p>dos2unix e unix2dos não possuem opção para converter arquivos UTF-8 para UTF-16.</p>
|
||||
|
||||
<p>Modo de conversão ISO e 7 bits não funcionam em arquivos UTF-16.</p>
|
||||
|
||||
<h2 id="Marca-de-ordem-de-byte">Marca de ordem de byte</h2>
|
||||
|
||||
<p>No Windows, arquivos texto em Unicode normalmente têm uma Marca de Ordem de Byte (BOM), porque muitos programas Windows (incluindo o Bloco de Notas) adiciona BOMs por padrão. Veja também <a href="https://pt.wikipedia.org/wiki/Marca_de_ordem_de_byte">https://pt.wikipedia.org/wiki/Marca_de_ordem_de_byte</a>.</p>
|
||||
|
||||
<p>No Unix, arquivos Unicode normalmente não têm BOM. Presume-se que arquivos texto são codificados na codificação de caracteres da localização.</p>
|
||||
|
||||
<p>dos2unix pode detectar apenas se um arquivo está no formato UTF-16 se o arquivo tiver BOM. Quando um arquivo UTF-16 não tiver BOM, dos2unix vai ver se o arquivo é um arquivo binário.</p>
|
||||
|
||||
<p>Use a opção <code>-ul</code> ou <code>-ub</code> para converter um arquivo UTF-16 sem BOM.</p>
|
||||
|
||||
<p>dos2unix escreve por padrão nenhum BOM no arquivo de saída. Com a opção <code>-b</code>, o dos2unix escreve um BOM quando o arquivo de entrada possuir BOM.</p>
|
||||
|
||||
<p>unix2dos escreve por padrão um BOM no arquivo de saída quando o arquivo de entrada tem BOM. Use a opção <code>-m</code> para remover BOM.</p>
|
||||
|
||||
<p>dos2unix e unix2dos sempre escrevem BOM quando a opção <code>-m</code> é usada.</p>
|
||||
|
||||
<h2 id="Nomes-de-arquivos-Unicode-no-Windows">Nomes de arquivos Unicode no Windows</h2>
|
||||
|
||||
<p>dos2unix possui um suporte opcional para leitura e escrita de nomes de arquivos Unicode no Prompt de Comando Windows. Isso significa que dos2unix pode abrir arquivos que possuam caracteres no nome que não são parte da página de código ANSI padrão do sistema. Para ver se dos2unix para Windows foi compilado com suporte a nomes de arquivos em Unicode, digite <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Há alguns problemas com a exibição de nomes de arquivos Unicode em um console Windows. Veja a opção <code>-D</code>, <code>--display-enc</code>. Para nomes de arquivos pode ser exibido incorretamente, mas os arquivos serão escritos com o nome correto.</p>
|
||||
|
||||
<h2 id="Exemplos-de-Unicode">Exemplos de Unicode</h2>
|
||||
|
||||
<p>Conversão de UTF-16 do Windows (com BOM) para UTF-8 do Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão de UTF-16LE do Windows (sem BOM) para UTF-8 do Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão de UTF-8 Unix para UTF-8 do Windows com BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n entrada.txt saída.txt</code></pre>
|
||||
|
||||
<p>Conversão de UTF-8 do Unix para UTF-16 do Windows:</p>
|
||||
|
||||
<pre><code>unix2dos < entrada.txt | iconv -f UTF-8 -t UTF-16 > saída.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 é um padrão do governo chinês. Um subconjunto obrigatório do padrão GB18030 é exigido oficialmente para todos os produtos de software vendidos na China. Veja também <a href="http://en.wikipedia.org/wiki/GB_18030">http://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 é completamente compatível com Unicode e pode ser considerado um formato de transformação de unicode. Assim como UTF-8, GB18030 é compatível com ASCII. GB18030 também é compatível com a página de código 936 do Windows, também conhecida como GBK.</p>
|
||||
|
||||
<p>No Unix/Linux, arquivos UTF-16 são convertidos para GB18030 quando a codificação da localização é definida para GB18030. Note que isso vai funcionar apenas se o sistemas oferecer suporte à localização. Use o comando <code>locale -a</code> para obter a lista de localizações às quais há suporte.</p>
|
||||
|
||||
<p>No Windows, você precisa usar a opção <code>-gb</code> para converter arquivos UTF-16 para GB18030.</p>
|
||||
|
||||
<p>Arquivos codificados em GB18030 possuem uma marca de ordem de bytes, como arquivos Unicode.</p>
|
||||
|
||||
<h1 id="EXEMPLOS">EXEMPLOS</h1>
|
||||
|
||||
<p>Lê a entrada da "stdin" e escreve a saída para "stdout":</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Converte e substitui a.txt. Converte e substitui b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Converte e substitui a.txt no modo de conversão ascii:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Converte e substitui a.txt no modo de conversão ascii. Converte e substitui b.txt no modo de conversão 7bit:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Converte a.txt do formato do Mac para Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Converte a.txt do formato do Unix para Mac:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Converte e substitui a.txt enquanto mantém a marca de data original:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Converte a.txt e escreve para e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Converte a.txt e escreve para e.txt, mantém a marca de data de e.txt igual a a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Converte e substitui a.txt. Converte b.txt e escreve para e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Converte c.txt e escreve para e.txt. Converte e substitui a.txt. Converte e substitui b.txt. Converte d.txt e escreve para f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="CONVERS-O-RECURSIVA">CONVERSÃO RECURSIVA</h1>
|
||||
|
||||
<p>Em um shell Unix, os comandos find(1) e xargs(1) podem ser usados para executar recursivamente o dos2unix em todos os arquivos texto em uma árvore de diretórios. Por exemplo, para converter todos os arquivos .txt na árvore de diretórios sob o diretório atual, digite:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>A opção do find(1) <code>-print0</code> e a opção correspondente do xargs(1) <code>-0</code> são necessárias quando houver arquivos com espaços ou aspas no nome. Do contrário, essas opções podem ser omitidas. Outra alternativa é usar find(1) com a opção <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>Em um Prompt de Comando do Windows o seguinte comando pode ser usado:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>Usuários do PowerShell podem usar o seguinte comando no Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOCALIZA-O">LOCALIZAÇÃO</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>O idioma primário é selecionado com a variável de ambiente LANG. A variável LANG consiste em várias partes. A primeira parte está em letras pequenas no código do idioma. A segunda parte é opcional e é o código do país em letras maiúsculo, precedida de um sublinhado. Há também uma terceira parte opcional: codificação de caractere, precedida com um ponto. Alguns exemplos para shells do tipo padrão POSIX:</p>
|
||||
|
||||
<pre><code>export LANG=nl Holandês
|
||||
export LANG=nl_NL Holandês, Holanda
|
||||
export LANG=nl_BE Holandês, Bélgica
|
||||
export LANG=es_ES Espanhol, Espanha
|
||||
export LANG=es_MX Espanhol, México
|
||||
export LANG=en_US.iso88591 Inglês, EUA, codificação Latin-1
|
||||
export LANG=en_GB.UTF-8 Inglês, Reino Unido, codificação UTF-8</code></pre>
|
||||
|
||||
<p>Para a lista completa de códigos de idioma e país, veja o manual do gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>Nos sistemas Unix, você pode usar o comando locale(1) para obter informação específica da localização.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Com a variável de ambiente LANGUAGE, você pode especificar uma lista de prioridades de idiomas, separada por vírgulas. O dos2unix fornece preferência à LANGUAGE sobre LANG. Por exemplo, primeiro holandês e, então, alemão: <code>LANGUAGE=nl:de</code>. Você primeiro tem que habilitar localização, definindo LANG (ou LC_ALL) para valor diferente de "C", antes que você possa usar uma lista de prioridade de idiomas por meio da variável LANGUAGE. Veja também o manual do gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Se você selecionou um idioma que não está disponível, você vai terá as mensagens em inglês (padrão).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Com a variável de ambiente DOS2UNIX_LOCALEDIR, o LOCALEDIR definido durante a compilação pode ser sobrescrito. LOCALEDIR é usada para localizar os arquivos de idioma. O valor padrão do GNU é <code>/usr/local/share/locale</code>. A opção <b>--version</b> vai exibir o LOCALEDIR que é usado.</p>
|
||||
|
||||
<p>Exemplo (shell POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="VALOR-RETORNADO">VALOR RETORNADO</h1>
|
||||
|
||||
<p>No sucesso, zero é retornado. Quando um erro de sistema ocorre, o último erro de sistema será retornado. Para outros erros, 1 é retornado.</p>
|
||||
|
||||
<p>O valor retornado é sempre zero no modo quieto, exceto quando opções de linha de comando erradas são usadas.</p>
|
||||
|
||||
<h1 id="PADR-ES">PADRÕES</h1>
|
||||
|
||||
<p><a href="https://pt.wikipedia.org/wiki/Arquivo_de_texto">https://pt.wikipedia.org/wiki/Arquivo_de_texto</a></p>
|
||||
|
||||
<p><a href="https://pt.wikipedia.org/wiki/Retorno_de_carro">https://pt.wikipedia.org/wiki/Retorno_de_carro</a></p>
|
||||
|
||||
<p><a href="https://pt.wikipedia.org/wiki/Nova_linha">https://pt.wikipedia.org/wiki/Nova_linha</a></p>
|
||||
|
||||
<p><a href="https://pt.wikipedia.org/wiki/Unicode">https://pt.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTORES">AUTORES</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (modo mac2unix) - <wuebben@kde.org>, Christian Wurll (adiciona nova linha extra) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (mantenedor)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Página do SourceForge: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="VEJA-TAMB-M">VEJA TAMBÉM</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
853
Agent-Windows/OGP64/usr/share/doc/dos2unix/pt_BR/dos2unix.txt
Normal file
853
Agent-Windows/OGP64/usr/share/doc/dos2unix/pt_BR/dos2unix.txt
Normal file
|
|
@ -0,0 +1,853 @@
|
|||
NOME
|
||||
dos2unix - Conversor de formato de arquivo texto de DOS/Mac para Unix e
|
||||
vice-versa
|
||||
|
||||
SINOPSE
|
||||
dos2unix [opções] [ARQUIVO ...] [-n ARQENT ARQSAÍDA ...]
|
||||
unix2dos [opções] [ARQUIVO ...] [-n ARQENT ARQSAÍDA ...]
|
||||
|
||||
DESCRIÇÃO
|
||||
O pacote dos2unix inclui utilitários de "dos2unix" e "unix2dos" para
|
||||
converter arquivos texto nos formatos DOS ou Mac para formato Unix e
|
||||
vice-versa.
|
||||
|
||||
Em arquivos texto DOS/Windows uma quebra de linha, também conhecida como
|
||||
nova linha, é uma combinação de dois caracteres: um Carriage Return (CR)
|
||||
seguido por um Line Feed (LF). Em arquivos texto do Unix uma quebra de
|
||||
linha é um único caractere: o Line Feed (LF). Em arquivos texto do Mac,
|
||||
anteriores ao Mac OS X, uma quebra de linha era um único caractere
|
||||
Carriage Return (CR). Hoje em dia, Mac OS usa quebras de linha no estilo
|
||||
do Unix (LF).
|
||||
|
||||
Além das quebras de linhas, dos2unix também pode converter as
|
||||
codificações de arquivos. Algumas poucas páginas podem ser convertidos
|
||||
para Latin-1 para Unix. E arquivos Unicode do Windows (UTF-16) podem ser
|
||||
convertidos para arquivos Unicode do Unix (UTF-8).
|
||||
|
||||
Arquivos binários são ignorados automaticamente, a menos que a conversão
|
||||
seja forçada.
|
||||
|
||||
Arquivos não regulares, tais como diretórios e FIFOs, são ignorados
|
||||
automaticamente.
|
||||
|
||||
Ligações simbólicas e seus alvos são por padrão mantidas intocáveis.
|
||||
Ligações simbólicas podem opcionalmente ser substituídas, ou a saída
|
||||
pode ser escrita para o alvo das ligações simbólicas. Não há suporte às
|
||||
ligações simbólicas do Windows.
|
||||
|
||||
O dos2unix foi modelado seguindo dos2unix do SunOS/Solaris. Há uma
|
||||
diferença importante em relação à versão original do SunOS/Solaris. Por
|
||||
padrão, essa versão faz conversão no-lugar (modo de arquivo antigo),
|
||||
enquanto a versão original do SunOS/Solaris fornecia suporte apenas a
|
||||
conversão pareada (modo de novo arquivo). Veja também as opções "-o" e
|
||||
"-n". Uma outra diferença é que a versão do SunOS/Solaris usa, por
|
||||
padrão, a conversão de modo do *iso* enquanto esta versão usa o do
|
||||
*ascii*.
|
||||
|
||||
OPÇÕES
|
||||
-- Trata as opções seguintes como nomes de arquivos. Use essa opção se
|
||||
você quiser converter arquivos cujos nomes iniciam com um traço. Por
|
||||
exemplo, para converter um arquivo chamado "foo", você pode usar
|
||||
este comando:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Ou em modo de novo arquivo:
|
||||
|
||||
dos2unix -n -- -foo saída.txt
|
||||
|
||||
--allow-chown
|
||||
Permite alteração da propriedade de arquivo no modo de arquivo
|
||||
antigo.
|
||||
|
||||
Quando esta opção é usada, a conversão não será abortada quando a
|
||||
propriedade do usuário e/ou do grupo do arquivo original não puder
|
||||
ser preservada no modo de arquivo antigo. A conversão continuará e o
|
||||
arquivo convertido receberá a mesma propriedade nova como se tivesse
|
||||
convertido no modo de novo arquivo. Veja também as opções "-o" e
|
||||
"-n". Esta opção só está disponível se o dos2unix oferecer suporte a
|
||||
preservação da propriedade do usuário e do grupo de arquivos.
|
||||
|
||||
-ascii
|
||||
Modo de conversão padrão. Veja também a seção MODOS DE CONVERSÃO.
|
||||
|
||||
-iso
|
||||
Conversão entre conjunto de caractere do DOS e ISO-8859-1. Veja
|
||||
também a seção MODOS DE CONVERSÃO.
|
||||
|
||||
-1252
|
||||
Usa a página de código 1252 do Windows (Europa ocidental).
|
||||
|
||||
-437
|
||||
Usa a página de código 437 do DOS (EUA). Essa é a página de código
|
||||
padrão usada para conversão ISO.
|
||||
|
||||
-850
|
||||
Usa a página de código 850 do DOS (Europa ocidental).
|
||||
|
||||
-860
|
||||
Usa a página de código 860 do DOS (Português).
|
||||
|
||||
-863
|
||||
Usa a página de código 863 do DOS (Francês do Canadá).
|
||||
|
||||
-865
|
||||
Usa a página de código 865 do DOS (Nórdico).
|
||||
|
||||
-7 Converte caracteres de 8 bits para espaço de 7 bits.
|
||||
|
||||
-b, --keep-bom
|
||||
Mantém marca de ordem de bytes (BOM). Quando o arquivo de entrada
|
||||
possuir um BOM, escreve um BOM no arquivo de saída. Esse é o
|
||||
comportamento padrão ao converter para quebras de linha do DOS. Veja
|
||||
também a opção "-r".
|
||||
|
||||
-c, --convmode MODOCONV
|
||||
Define o modo de conversão, sendo MODOCONV um dentre: *ascii*,
|
||||
*7bit*, *iso*, *mac* com ascii sendo o padrão.
|
||||
|
||||
-D, --display-enc CODIFICAÇÃO
|
||||
Define a codificação do texto exibido, sendo CODIFICAÇÃO um dentre:
|
||||
*ansi*, *unicode*, *utf8*, *utf8bom* com ansi sendo o padrão.
|
||||
|
||||
Essa opção está disponível apenas no dos2unix para Windows com
|
||||
suporte a nome de arquivo em Unicode. Essa opção não possui efeito
|
||||
nos nomes de arquivos lidos e escritos, apenas em como eles são
|
||||
exibidos.
|
||||
|
||||
Há vários métodos para exibir texto em um console Windows baseado na
|
||||
codificação do texto. Todos eles possuem suas próprias vantagens e
|
||||
desvantagens.
|
||||
|
||||
ansi
|
||||
O método padrão do dos2unix é usar o texto codificado em ANSI. A
|
||||
sua vantagem é a compatibilidade reversa. Ele funciona com
|
||||
fontes raster e TrueType. Em algumas regiões você pode precisar
|
||||
alterar a página de código OEM do DOS para ANSI do sistema
|
||||
Windows usando o comando "chcp", porque dos2unix usa a página de
|
||||
código do sistema Windows.
|
||||
|
||||
A desvantagem do ansi é que nomes de arquivos internacionais com
|
||||
caracteres fora a página de código padrão do sistema não são
|
||||
exibidos apropriadamente. Você verá um sinal de interrogação, ou
|
||||
um símbolo incorreto. Quando você não utiliza nomes de arquivos
|
||||
estrangeiros, esse método funciona bem.
|
||||
|
||||
unicode, unicodebom
|
||||
A vantagem da codificação do unicode (o nome Windows para
|
||||
UTF-16) é que o texto é normalmente exibido apropriadamente. Não
|
||||
há necessidade para alterar a página de código ativa. Você pode
|
||||
precisar definir a fonte do console para uma fonte TrueType para
|
||||
que caracteres internacionais sejam exibidos apropriadamente.
|
||||
Quando um caractere não está incluído na fonte TrueType,
|
||||
geralmente você vê um pequeno quadrado, algumas vezes com um
|
||||
sinal de interrogação nele.
|
||||
|
||||
Quando você usa o console ConEmu todo texto é exibido
|
||||
apropriadamente, porque o ConEmu seleciona automaticamente um
|
||||
fonte boa.
|
||||
|
||||
A desvantagem do unicode é que ele não é compatível com ASCII. A
|
||||
saída não é fácil de lidar quando você o redireciona para um
|
||||
outro programa.
|
||||
|
||||
Quando o método <unicodebom> é usado, o texto Unicode será
|
||||
precedido com um BOM (Byte Order Mark, ou marca de ordem de
|
||||
byte). Um BOM é necessário para o redirecionamento, ou "piping",
|
||||
correto no PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
A vantagem do utf8 é que ele é compatível com ASCII. Você
|
||||
precisa definir a fonte do console para uma fonte TrueType. Com
|
||||
uma fonte TrueType, o texto é exibido similar a uma codificação
|
||||
"unicode".
|
||||
|
||||
A desvantagem é que quando você usa a fonte "raster" padrão,
|
||||
caracteres não-ASCII são exibidos incorretamente. Não apenas
|
||||
nomes de arquivos unicode, mas também mensagens traduzidas ficam
|
||||
ilegíveis. No Windows configurado para uma região leste da Ásia,
|
||||
você pode ver muitas falhas no console quando as mensagens são
|
||||
exibidas.
|
||||
|
||||
Em um console ConEmu, o método de codificação utf8 funciona bem.
|
||||
|
||||
Quando o método <utf8bom> é usado, o texto UTF-8 será precedido
|
||||
com um BOM (Byte Order Mark, ou marca de ordem de byte). Um BOM
|
||||
é necessário para o redirecionamento, ou "piping", correto no
|
||||
PowerShell.
|
||||
|
||||
A codificação padrão pode ser alterada com a variável de ambiente
|
||||
DOS2UNIX_DISPLAY_ENC definindo-a para "unicode", "unicodebom",
|
||||
"utf8" ou "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Adiciona uma quebra de linha à última linha se não houver uma. Isso
|
||||
funciona para todas as conversões.
|
||||
|
||||
Um arquivo convertido do formato DOS para Unix pode não ter uma
|
||||
quebra de linha na última linha. Existem editores de texto que
|
||||
escrevem arquivos de texto sem uma quebra de linha na última linha.
|
||||
Alguns programas Unix têm problemas para processar esses arquivos,
|
||||
porque o padrão POSIX define que cada linha em um arquivo de texto
|
||||
deve terminar com um caractere de nova linha de terminação. Por
|
||||
exemplo, concatenar arquivos pode não dar o resultado esperado.
|
||||
|
||||
--error-binary
|
||||
Retorna um erro se um arquivo binário for ignorado.
|
||||
|
||||
-f, --force
|
||||
Força a conversão de arquivos binários.
|
||||
|
||||
-gb, --gb18030
|
||||
No Windows, arquivos UTF-16 são convertidos, por padrão, para UTF-8,
|
||||
independentemente da localização definida. Use esta opção para
|
||||
converter arquivos UTF-16 para GB18030. Essa opção está disponível
|
||||
apenas no Windows. Veja também a seção GB18030.
|
||||
|
||||
-h, --help
|
||||
Exibe ajuda e sai.
|
||||
|
||||
-i[OPÇÕES], --info[=OPÇÕES] ARQUIVO ...
|
||||
Exibe informação do arquivo. Nenhuma conversão é feita.
|
||||
|
||||
A seguinte informação é exibida, nesta ordem: número de quebras de
|
||||
linha do DOS, número de quebras de linha do Unix, número de quebras
|
||||
de linha do Mac, marca de ordem de byte, "text" ou "binary", nome de
|
||||
arquivo.
|
||||
|
||||
Exemplo de saída:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Note que em algumas vezes um arquivo binário pode ser confundido com
|
||||
um arquivo texto. Veja também a opção "-s".
|
||||
|
||||
Se, além disso, a opção "-e" ou "--add-eol" for usada, o tipo de
|
||||
quebra de linha da última linha também será impresso, ou "noeol" se
|
||||
não houver nenhuma.
|
||||
|
||||
Exemplo de saída:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Opcionalmente, opções extra podem ser definidas para alterar a
|
||||
saída. Uma ou mais opções podem ser adicionadas.
|
||||
|
||||
0 Exibe as linhas de informações de arquivo seguido por um
|
||||
caractere nulo em vez de um caractere de nova linha. Isso
|
||||
habilita interpretação correta de nomes de arquivo com espaços
|
||||
ou aspas quando a opção c é usada. Use essa opção na combinação
|
||||
com opções -0 ou "--null" do xargs(1).
|
||||
|
||||
d Exibe o número de quebras de linhas do DOS.
|
||||
|
||||
u Exibe o número de quebras de linhas do Unix.
|
||||
|
||||
m Exibe o número de quebras de linhas do Mac.
|
||||
|
||||
b Exibe a marca de ordem de byte.
|
||||
|
||||
t Exibe se arquivo é texto ou binário.
|
||||
|
||||
e Imprime o tipo de quebra de linha da última linha, ou "noeol" se
|
||||
não houver nenhuma.
|
||||
|
||||
c Exibe apenas os arquivos que seriam convertidos.
|
||||
|
||||
Com a opção "c", dos2unix vai exibir apenas os arquivos que
|
||||
contêm quebras de linha do DOS, unix2dos vai exibir apenas os
|
||||
nomes de arquivos que contêm quebras de linha do Unix.
|
||||
|
||||
Se, além disso, a opção "-e" ou "--add-eol" for usada, os
|
||||
arquivos que não tiverem uma quebra de linha na última linha
|
||||
também serão impressos.
|
||||
|
||||
h Exibe um cabeçalho.
|
||||
|
||||
p Mostra nomes de arquivos sem caminho.
|
||||
|
||||
Exemplos:
|
||||
|
||||
Mostra informação sobre todos os arquivos *.txt:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Mostra apenas o número de quebras de linha DOS e Unix:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Mostra apenas a marca de ordem de byte:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Lista os arquivos que possuem quebras de linha do DOS:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Lista os arquivos que possuem quebras de linha do Unix:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Lista os arquivos que têm quebras de linha DOS ou não têm quebra de
|
||||
linha na última linha:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Converte apenas arquivos que possuem quebras de linha do DOS e não
|
||||
altera outros arquivos:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Localiza arquivos de texto que possuam quebras de linha do DOS:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Mantém a marca da data do arquivo de saída igual ao do arquivo de
|
||||
entrada.
|
||||
|
||||
-L, --license
|
||||
Exibe a licença do programa.
|
||||
|
||||
-l, --newline
|
||||
Adiciona nova linha adicional.
|
||||
|
||||
dos2unix: Apenas quebras de linha do DOS são alteradas para duas
|
||||
quebras de linha do Unix. No modo Mac, apenas quebras de linha do
|
||||
Mac são alterados para duas quebras de linha do Unix.
|
||||
|
||||
unix2dos: Apenas quebras de linha do Unix são alteradas para duas
|
||||
quebras de linha do DOS. No modo Mac, quebras de linha do Unix são
|
||||
alteradas para duas quebras de linha do Mac.
|
||||
|
||||
-m, --add-bom
|
||||
Escreve uma marca de ordem de byte (BOM) no arquivo de saída. Por
|
||||
padrão, um BOM UTF-8 é escrito.
|
||||
|
||||
Quando o arquivo de entrada é UTF-16, e a opção "-u" é usada, um BOM
|
||||
UTF-16 será escrito.
|
||||
|
||||
Nunca use essa opção quando a codificação de saída é outra além de
|
||||
UTF-8, UTF-16 ou GB18030. Veja também a seção UNICODE.
|
||||
|
||||
-n, --newfile ARQENT ARQSAÍDA ...
|
||||
Modo de novo arquivo. Converte o arquivo ARQENT e escreve a saída
|
||||
para o arquivo ARQSAÍDA. Os nomes de arquivos devem ser fornecidos
|
||||
em pares e nome coringa *não* deveriam ser usados ou você *vai*
|
||||
perder seus arquivos.
|
||||
|
||||
A pessoa que começa a conversão em modo de novo arquivo (pareado)
|
||||
será o dono do arquivo convertido. As permissões de leitura/escrita
|
||||
do novo arquivo serão as permissões do arquivo original menos a
|
||||
umask(1) da pessoa que executa a conversão.
|
||||
|
||||
--no-allow-chown
|
||||
Não permite alteração da propriedade do arquivo no modo de arquivo
|
||||
antigo (padrão).
|
||||
|
||||
Aborta a conversão quando a propriedade do usuário e/ou do grupo do
|
||||
arquivo original não puder ser preservada no modo de arquivo antigo.
|
||||
Veja também as opções "-o" e "-n". Esta opção só está disponível se
|
||||
o dos2unix oferecer suporte à preservação da propriedade do usuário
|
||||
e do grupo de arquivos.
|
||||
|
||||
--no-add-eol
|
||||
Não adiciona uma quebra de linha à última linha se não houver uma
|
||||
(padrão).
|
||||
|
||||
--no-error-binary
|
||||
Não retorna um erro se um arquivo binário é ignorado (padrão).
|
||||
|
||||
-O, --to-stdout
|
||||
Escreve na saída padrão, como um filtro Unix. Use a opção "-o" para
|
||||
voltar ao modo de arquivo antigo (in-place).
|
||||
|
||||
Combinado com a opção "-e", os arquivos podem ser concatenados
|
||||
corretamente. Nenhuma última e primeira linhas mescladas e nenhuma
|
||||
marca de ordem de bytes Unicode no meio do arquivo concatenado.
|
||||
Exemplo:
|
||||
|
||||
dos2unix -e -O arquivo1.txt arquivo2.txt > saída.txt
|
||||
|
||||
-o, --oldfile ARQUIVO ...
|
||||
Modo de arquivo antigo. Converte o arquivo ARQUIVO e o sobrescreve
|
||||
com a saída. O programa, por padrão, executa neste modo. Nomes
|
||||
coringas podem ser usados.
|
||||
|
||||
No modo de arquivo antigo (no-lugar) o arquivo convertido recebe no
|
||||
mesmo dono, grupo e permissões de leitura/escrita que o arquivo
|
||||
original. Também, quando o arquivo é convertido por outro usuário
|
||||
que tenha permissões de escrita no arquivo (ex.: usuário root). A
|
||||
conversão será abortada quando não for possível preservar os valores
|
||||
originais. Alteração do dono pode significar que o dono original não
|
||||
é mais capaz de ler o arquivo. Alteração do grupo pode ser um risco
|
||||
para a segurança, pois o arquivo pode ficar legível para pessoas
|
||||
cujo acesso não é desejado. Preservação do dono, grupo e permissões
|
||||
de leitura/escrita tem suporte apenas no Unix.
|
||||
|
||||
Para verificar se dos2unix oferece suporte à preservação da
|
||||
propriedade de usuário e de grupo de arquivos, digite "dos2unix -V".
|
||||
|
||||
A conversão sempre é feita através de um arquivo temporário. Quando
|
||||
um erro ocorre no meio da conversão, o arquivo temporário é excluído
|
||||
e o arquivo original permanece intacto. Quando a conversão é bem
|
||||
sucedida, o arquivo original é substituído pelo arquivo temporário.
|
||||
Você pode ter permissão de gravação no arquivo original, mas nenhuma
|
||||
permissão para colocar a mesma propriedade de usuário e/ou de grupo
|
||||
no arquivo temporário como o arquivo original. Isso significa que
|
||||
você não consegue preservar a propriedade de usuário e/ou de grupo
|
||||
do arquivo original. Neste caso, você pode usar a opção
|
||||
"-allow-chown" para continuar com a conversão:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Outra opção é usar o novo modo de arquivo:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
A vantagem da opção "--allow-chown" é que você pode usar coringas e
|
||||
as informações de propriedade serão preservadas quando possível.
|
||||
|
||||
-q, --quiet
|
||||
Modo quieto. Suprime todos os avios e mensagens. O valor retornado é
|
||||
zero. Exceto quando opções de linha de comando erradas forem usadas.
|
||||
|
||||
-r, --remove-bom
|
||||
Remove marca de ordem de bytes (BOM). Não escreve um BOM no arquivo
|
||||
de saída. Esse é o comportamento padrão ao converter para quebras de
|
||||
linha Unix. Veja também a opção "-b".
|
||||
|
||||
-s, --safe
|
||||
Ignora arquivo binários (padrão).
|
||||
|
||||
A ação de ignorar arquivos binários é feita para evitar equívocos
|
||||
acidentais. Fique ciente de que a detecção de arquivos binários não
|
||||
é 100% à prova de erros. Arquivos de entrada são analisados por
|
||||
símbolos binários que, geralmente, não são encontrados em arquivos
|
||||
textos. É possível que um arquivo binário contenha apenas caracteres
|
||||
de texto normais. tal arquivo binário pode ser acidentalmente visto
|
||||
como um arquivo de texto.
|
||||
|
||||
Por padrão, não é retornado nenhum erro quando um arquivo binário é
|
||||
ignorado. Quando a opção C <--error-binary> é usada, é retornado um
|
||||
erro.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Presume que o formato de arquivo de entrada é UTF-16LE.
|
||||
|
||||
Quando há uma marca de ordem de byte no arquivo de entrada, esta tem
|
||||
prioridade sobre essa opção.
|
||||
|
||||
Quando você fizer uma presunção equivocada (o arquivo de entrada não
|
||||
estava no formato UTF-16LE) e a conversão funcionar, você terá um
|
||||
arquivo de saída UTF-8 com texto errado. Você pode desfazer a
|
||||
conversão errada com iconv(1) pela conversão do arquivo de saída
|
||||
UTF-8 de volta para UTF-16LE. Isso vai trazer de volta o arquivo
|
||||
para o original.
|
||||
|
||||
A presunção de UTF-16LE funciona como um *modo de conversão*. Ao
|
||||
alternara o modo *ascii* padrão, a presunção de UTF-16LE é
|
||||
desativada.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Presume que o formato de arquivo de entrada é UTF-16BE.
|
||||
|
||||
Essa opção funciona o mesmo que a opção "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Exibe mensagens detalhadas. Informação extra é exibida sobre marcas
|
||||
de ordem de byte e a quantidade de quebras de linha convertidas.
|
||||
|
||||
-F, --follow-symlink
|
||||
Segue ligações simbólicas e converte os alvos.
|
||||
|
||||
-R, --replace-symlink
|
||||
Substitui ligações simbólicas com arquivos convertidos (arquivos
|
||||
alvo originais permanecem inalterados).
|
||||
|
||||
-S, --skip-symlink
|
||||
Mentém ligações simbólicas e alvos inalterados (padrão).
|
||||
|
||||
-V, --version
|
||||
Exibe informação da versão e sai.
|
||||
|
||||
MODO MAC
|
||||
Por padrão, as quebras de linha são convertidas de DOS para Unix e
|
||||
vice-versa. As quebras de linha do Mac não são convertidas.
|
||||
|
||||
No modo Mac, quebras de linha são convertidas de Mac para Unix e
|
||||
vice-versa. Quebras de linha do DOS não são alteradas.
|
||||
|
||||
Para executar no modo Mac, use a opção de linha de comando "-c mac" ou
|
||||
use os comandos "mac2unix" ou "unix2mac".
|
||||
|
||||
MODOS DE CONVERSÃO
|
||||
ascii
|
||||
Este é o modo de conversão padrão. Este modo é para converter
|
||||
arquivos codificados ASCII e compatíveis com ASCII, como UTF-8.
|
||||
Habilitar o modo ascii desabilita o modo 7bit e iso.
|
||||
|
||||
Se dos2unix tiver suporte a UTF-16, os arquivos codificados em
|
||||
UTF-16 serão convertidos para a codificação de caracteres de
|
||||
localidade atual em sistemas POSIX e para UTF-8 no Windows.
|
||||
Habilitar o modo ascii desabilita a opção de manter a codificação
|
||||
UTF-16 ("-u") e as opções para assumir a entrada UTF-16 ("-ul" e
|
||||
"-ub"). Para ver se dos2unix tem suporte a UTF-16, digite "dos2unix
|
||||
-V". Veja também a seção UNICODE.
|
||||
|
||||
7bit
|
||||
Neste modo todos os caracteres não-ASCII de 8 bits (com valores
|
||||
entre 128 e 255) são convertidos para um espaço de 7 bits.
|
||||
|
||||
iso Caracteres são convertidos entre um conjunto de caracteres do DOS
|
||||
(página de código) e conjunto de caracteres ISO-8859-1 (Latin-1) no
|
||||
Unix. Caracteres de DOS sem um equivalente ISO-8859-1, para os quais
|
||||
a conversão não é possível, são convertidos para um ponto. O mesmo
|
||||
vale para caracteres ISO-8859-1 sem a contraparte DOS.
|
||||
|
||||
Quando apenas a opção "-iso" for usada, dos2unix vai tentar
|
||||
determinar a página de código ativa. Quando isso não for possível,
|
||||
dos2unix vai usar a página de código padrão CP437, a qual é usada
|
||||
principalmente nos EUA. Para forçar uma página de código específica,
|
||||
use as opções -437 (EUA), -850 (Europeu oriental), -860 (Português),
|
||||
-863 (Franco-canadense) ou -865 (Nórdico). Também há suporte à
|
||||
página de código do Windows CP1252 (Europeu ocidental) com a opção
|
||||
-1252. Para outras páginas de código, use dos2unix em combinação cm
|
||||
iconv(1). Iconv pode converter entre uma lista grande de
|
||||
codificações de caracteres.
|
||||
|
||||
Nunca use conversão ISO em arquivos textos Unicode. Isso vai
|
||||
corromper os arquivos codificados em UTF-8.
|
||||
|
||||
Alguns exemplos:
|
||||
|
||||
Conversão da página de código padrão do DOS para Latin-1 do Unix:
|
||||
|
||||
dos2unix -iso -n entrada.txt saída.txt
|
||||
|
||||
Conversão da CP850 do DOS para Latin-1 do Unix:
|
||||
|
||||
dos2unix -850 -n entrada.txt saída.txt
|
||||
|
||||
Conversão da CP1252 do Windows para Latin-1 do Unix:
|
||||
|
||||
dos2unix -1252 -n entrada.txt saída.txt
|
||||
|
||||
Conversão da CP1252 do Windows para UTF-8 (Unicode) do Unix:
|
||||
|
||||
iconv -f CP1252 -t UTF-8 entrada.txt | dos2unix > saída.txt
|
||||
|
||||
Conversão de Latin-1 do Unix para página de código padrão do DOS:
|
||||
|
||||
unix2dos -iso -n entrada.txt saída.txt
|
||||
|
||||
Conversão do Latin-1 do Unix para CP850 do DOS:
|
||||
|
||||
unix2dos -850 -n entrada.txt saída.txt
|
||||
|
||||
Conversão do Latin-1 do unix para CP1252 do Windows:
|
||||
|
||||
unix2dos -1252 -n entrada.txt saída.txt
|
||||
|
||||
Conversão do UTF-8 (Unicode) do Unix para CP1252 do Windows:
|
||||
|
||||
unix2dos < entrada.txt | iconv -f UTF-8 -t CP1252 > saída.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Codificações
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversão
|
||||
Arquivos texto em Unicode pode ter quebras de linha DOS, Unix ou Mac,
|
||||
como arquivos texto em ASCII.
|
||||
|
||||
Todas as versões do dos2unix e unix2dos podem converter arquivos
|
||||
codificados em UTF-8 porque UTF-8 foi projetado para ter compatibilidade
|
||||
reversa com ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
No Unix/Linux, arquivos codificados em UTF-16 são convertidos para a
|
||||
codificação de caracteres do localização. Use o comando locale(1) para
|
||||
descobrir qual é a codificação de caracteres da localização. Quando a
|
||||
conversão não for possível, ocorrerá um erro e o arquivo será ignorado.
|
||||
|
||||
No Windows, arquivos UTF-16 são convertidos, por padrão, para UTF-8.
|
||||
Arquivos texto formatados em UTF-8 possuem ótimo suporte em ambos
|
||||
Windows e Unix/Linux.
|
||||
|
||||
Codificações UTF-16 e UTF-8 são completamente compatíveis, não havendo
|
||||
qualquer perda de texto na conversão. Quando um erro de conversão UTF-16
|
||||
para UTF-8 ocorre, por exemplo quando o arquivo de entrada UTF-16 contém
|
||||
um erro, o arquivo será ignorado.
|
||||
|
||||
Quando a opção "-u" é usada, o arquivo de saída será escrito na mesma
|
||||
codificação UTF-16 que o arquivo de saída. A opção "-u" evita conversão
|
||||
para UTF-8.
|
||||
|
||||
dos2unix e unix2dos não possuem opção para converter arquivos UTF-8 para
|
||||
UTF-16.
|
||||
|
||||
Modo de conversão ISO e 7 bits não funcionam em arquivos UTF-16.
|
||||
|
||||
Marca de ordem de byte
|
||||
No Windows, arquivos texto em Unicode normalmente têm uma Marca de Ordem
|
||||
de Byte (BOM), porque muitos programas Windows (incluindo o Bloco de
|
||||
Notas) adiciona BOMs por padrão. Veja também
|
||||
<https://pt.wikipedia.org/wiki/Marca_de_ordem_de_byte>.
|
||||
|
||||
No Unix, arquivos Unicode normalmente não têm BOM. Presume-se que
|
||||
arquivos texto são codificados na codificação de caracteres da
|
||||
localização.
|
||||
|
||||
dos2unix pode detectar apenas se um arquivo está no formato UTF-16 se o
|
||||
arquivo tiver BOM. Quando um arquivo UTF-16 não tiver BOM, dos2unix vai
|
||||
ver se o arquivo é um arquivo binário.
|
||||
|
||||
Use a opção "-ul" ou "-ub" para converter um arquivo UTF-16 sem BOM.
|
||||
|
||||
dos2unix escreve por padrão nenhum BOM no arquivo de saída. Com a opção
|
||||
"-b", o dos2unix escreve um BOM quando o arquivo de entrada possuir BOM.
|
||||
|
||||
unix2dos escreve por padrão um BOM no arquivo de saída quando o arquivo
|
||||
de entrada tem BOM. Use a opção "-m" para remover BOM.
|
||||
|
||||
dos2unix e unix2dos sempre escrevem BOM quando a opção "-m" é usada.
|
||||
|
||||
Nomes de arquivos Unicode no Windows
|
||||
dos2unix possui um suporte opcional para leitura e escrita de nomes de
|
||||
arquivos Unicode no Prompt de Comando Windows. Isso significa que
|
||||
dos2unix pode abrir arquivos que possuam caracteres no nome que não são
|
||||
parte da página de código ANSI padrão do sistema. Para ver se dos2unix
|
||||
para Windows foi compilado com suporte a nomes de arquivos em Unicode,
|
||||
digite "dos2unix -V".
|
||||
|
||||
Há alguns problemas com a exibição de nomes de arquivos Unicode em um
|
||||
console Windows. Veja a opção "-D", "--display-enc". Para nomes de
|
||||
arquivos pode ser exibido incorretamente, mas os arquivos serão escritos
|
||||
com o nome correto.
|
||||
|
||||
Exemplos de Unicode
|
||||
Conversão de UTF-16 do Windows (com BOM) para UTF-8 do Unix:
|
||||
|
||||
dos2unix -n entrada.txt saída.txt
|
||||
|
||||
Conversão de UTF-16LE do Windows (sem BOM) para UTF-8 do Unix:
|
||||
|
||||
dos2unix -ul -n entrada.txt saída.txt
|
||||
|
||||
Conversão de UTF-8 Unix para UTF-8 do Windows com BOM:
|
||||
|
||||
unix2dos -m -n entrada.txt saída.txt
|
||||
|
||||
Conversão de UTF-8 do Unix para UTF-16 do Windows:
|
||||
|
||||
unix2dos < entrada.txt | iconv -f UTF-8 -t UTF-16 > saída.txt
|
||||
|
||||
GB18030
|
||||
GB18030 é um padrão do governo chinês. Um subconjunto obrigatório do
|
||||
padrão GB18030 é exigido oficialmente para todos os produtos de software
|
||||
vendidos na China. Veja também <http://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 é completamente compatível com Unicode e pode ser considerado um
|
||||
formato de transformação de unicode. Assim como UTF-8, GB18030 é
|
||||
compatível com ASCII. GB18030 também é compatível com a página de código
|
||||
936 do Windows, também conhecida como GBK.
|
||||
|
||||
No Unix/Linux, arquivos UTF-16 são convertidos para GB18030 quando a
|
||||
codificação da localização é definida para GB18030. Note que isso vai
|
||||
funcionar apenas se o sistemas oferecer suporte à localização. Use o
|
||||
comando "locale -a" para obter a lista de localizações às quais há
|
||||
suporte.
|
||||
|
||||
No Windows, você precisa usar a opção "-gb" para converter arquivos
|
||||
UTF-16 para GB18030.
|
||||
|
||||
Arquivos codificados em GB18030 possuem uma marca de ordem de bytes,
|
||||
como arquivos Unicode.
|
||||
|
||||
EXEMPLOS
|
||||
Lê a entrada da "stdin" e escreve a saída para "stdout":
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Converte e substitui a.txt. Converte e substitui b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Converte e substitui a.txt no modo de conversão ascii:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Converte e substitui a.txt no modo de conversão ascii. Converte e
|
||||
substitui b.txt no modo de conversão 7bit:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Converte a.txt do formato do Mac para Unix:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Converte a.txt do formato do Unix para Mac:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Converte e substitui a.txt enquanto mantém a marca de data original:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Converte a.txt e escreve para e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Converte a.txt e escreve para e.txt, mantém a marca de data de e.txt
|
||||
igual a a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Converte e substitui a.txt. Converte b.txt e escreve para e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Converte c.txt e escreve para e.txt. Converte e substitui a.txt.
|
||||
Converte e substitui b.txt. Converte d.txt e escreve para f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
CONVERSÃO RECURSIVA
|
||||
Em um shell Unix, os comandos find(1) e xargs(1) podem ser usados para
|
||||
executar recursivamente o dos2unix em todos os arquivos texto em uma
|
||||
árvore de diretórios. Por exemplo, para converter todos os arquivos .txt
|
||||
na árvore de diretórios sob o diretório atual, digite:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
A opção do find(1) "-print0" e a opção correspondente do xargs(1) -0 são
|
||||
necessárias quando houver arquivos com espaços ou aspas no nome. Do
|
||||
contrário, essas opções podem ser omitidas. Outra alternativa é usar
|
||||
find(1) com a opção "-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
Em um Prompt de Comando do Windows o seguinte comando pode ser usado:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
Usuários do PowerShell podem usar o seguinte comando no Windows
|
||||
PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOCALIZAÇÃO
|
||||
LANG
|
||||
O idioma primário é selecionado com a variável de ambiente LANG. A
|
||||
variável LANG consiste em várias partes. A primeira parte está em
|
||||
letras pequenas no código do idioma. A segunda parte é opcional e é
|
||||
o código do país em letras maiúsculo, precedida de um sublinhado. Há
|
||||
também uma terceira parte opcional: codificação de caractere,
|
||||
precedida com um ponto. Alguns exemplos para shells do tipo padrão
|
||||
POSIX:
|
||||
|
||||
export LANG=nl Holandês
|
||||
export LANG=nl_NL Holandês, Holanda
|
||||
export LANG=nl_BE Holandês, Bélgica
|
||||
export LANG=es_ES Espanhol, Espanha
|
||||
export LANG=es_MX Espanhol, México
|
||||
export LANG=en_US.iso88591 Inglês, EUA, codificação Latin-1
|
||||
export LANG=en_GB.UTF-8 Inglês, Reino Unido, codificação UTF-8
|
||||
|
||||
Para a lista completa de códigos de idioma e país, veja o manual do
|
||||
gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
Nos sistemas Unix, você pode usar o comando locale(1) para obter
|
||||
informação específica da localização.
|
||||
|
||||
LANGUAGE
|
||||
Com a variável de ambiente LANGUAGE, você pode especificar uma lista
|
||||
de prioridades de idiomas, separada por vírgulas. O dos2unix fornece
|
||||
preferência à LANGUAGE sobre LANG. Por exemplo, primeiro holandês e,
|
||||
então, alemão: "LANGUAGE=nl:de". Você primeiro tem que habilitar
|
||||
localização, definindo LANG (ou LC_ALL) para valor diferente de "C",
|
||||
antes que você possa usar uma lista de prioridade de idiomas por
|
||||
meio da variável LANGUAGE. Veja também o manual do gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Se você selecionou um idioma que não está disponível, você vai terá
|
||||
as mensagens em inglês (padrão).
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Com a variável de ambiente DOS2UNIX_LOCALEDIR, o LOCALEDIR definido
|
||||
durante a compilação pode ser sobrescrito. LOCALEDIR é usada para
|
||||
localizar os arquivos de idioma. O valor padrão do GNU é
|
||||
"/usr/local/share/locale". A opção --version vai exibir o LOCALEDIR
|
||||
que é usado.
|
||||
|
||||
Exemplo (shell POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
VALOR RETORNADO
|
||||
No sucesso, zero é retornado. Quando um erro de sistema ocorre, o último
|
||||
erro de sistema será retornado. Para outros erros, 1 é retornado.
|
||||
|
||||
O valor retornado é sempre zero no modo quieto, exceto quando opções de
|
||||
linha de comando erradas são usadas.
|
||||
|
||||
PADRÕES
|
||||
<https://pt.wikipedia.org/wiki/Arquivo_de_texto>
|
||||
|
||||
<https://pt.wikipedia.org/wiki/Retorno_de_carro>
|
||||
|
||||
<https://pt.wikipedia.org/wiki/Nova_linha>
|
||||
|
||||
<https://pt.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTORES
|
||||
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (modo
|
||||
mac2unix) - <wuebben@kde.org>, Christian Wurll (adiciona nova linha
|
||||
extra) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl>
|
||||
(mantenedor)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Página do SourceForge: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
VEJA TAMBÉM
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/ro/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/ro/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - Convertor de format de fișier text din DOS/Mac în Unix și viceversa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NUME">NUME</a></li>
|
||||
<li><a href="#SINOPSIS">SINOPSIS</a></li>
|
||||
<li><a href="#DESCRIERE">DESCRIERE</a></li>
|
||||
<li><a href="#OP-IUNI">OPȚIUNI</a></li>
|
||||
<li><a href="#MODUL-MAC">MODUL MAC</a></li>
|
||||
<li><a href="#MODURI-DE-CONVERSIE">MODURI DE CONVERSIE</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Codific-ri">Codificări</a></li>
|
||||
<li><a href="#Conversie">Conversie</a></li>
|
||||
<li><a href="#Marcajul-de-ordine-a-octe-ilor">Marcajul de ordine a octeților</a></li>
|
||||
<li><a href="#Nume-de-fi-iere-Unicode-n-Windows">Nume de fișiere Unicode în Windows</a></li>
|
||||
<li><a href="#Exemple-Unicode">Exemple Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EXEMPLE">EXEMPLE</a></li>
|
||||
<li><a href="#CONVERSIE-RECURSIV">CONVERSIE RECURSIVĂ</a></li>
|
||||
<li><a href="#LOCALIZAREA">LOCALIZAREA</a></li>
|
||||
<li><a href="#VALOAREA-RETURNAT">VALOAREA RETURNATĂ</a></li>
|
||||
<li><a href="#STANDARDE">STANDARDE</a></li>
|
||||
<li><a href="#AUTORI">AUTORI</a></li>
|
||||
<li><a href="#CONSULTA-I-I">CONSULTAȚI ȘI</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NUME">NUME</h1>
|
||||
|
||||
<p>dos2unix - Convertor de format de fișier text din DOS/Mac în Unix și viceversa</p>
|
||||
|
||||
<h1 id="SINOPSIS">SINOPSIS</h1>
|
||||
|
||||
<pre><code>dos2unix [opțiuni] [FIȘIER ...] [-n FIȘIER_INTRARE FIȘIER_IEȘIRE ...]
|
||||
unix2dos [opțiuni] [FIȘIER ...] [-n FIȘIER_INTRARE FIȘIER_IEȘIRE ...]</code></pre>
|
||||
|
||||
<h1 id="DESCRIERE">DESCRIERE</h1>
|
||||
|
||||
<p>Pachetul «dos2unix» include utilitarele <code>dos2unix</code> și <code>unix2dos</code> pentru a converti fișierele text simplu din formatul DOS sau Mac în formatul Unix și invers.</p>
|
||||
|
||||
<p>În fișierele text DOS/Windows, o întrerupere de linie, cunoscută și sub numele de linie nouă, este o combinație de două caractere: un retur de caret (CR) urmat de un salt de linie (LF). În fișierele text Unix, o întrerupere de linie este un singur caracter: saltul de linie (LF). În fișierele text Mac, înainte de Mac OS X, o întrerupere de linie era un singur caracter retur de caret (CR). În prezent, Mac OS folosește întreruperi de linie în stil Unix (LF).</p>
|
||||
|
||||
<p>Pe lângă întreruperile de linie, «dos2unix» poate converti și codificarea fișierelor. Câteva pagini de cod DOS pot fi convertite în Latin-1 Unix. Și fișierele Unicode Windows (UTF-16) pot fi convertite în fișiere Unicode Unix (UTF-8).</p>
|
||||
|
||||
<p>Fișierele binare sunt omise automat, cu excepția cazului în care conversia este forțată.</p>
|
||||
|
||||
<p>Fișierele care nu sunt obișnuite, cum ar fi directoarele și liniile de conectare cu nume (FIFOs), sunt omise automat.</p>
|
||||
|
||||
<p>Legăturile simbolice și țintele lor sunt în mod implicit păstrate neatinse. Legăturile simbolice pot fi înlocuite opțional sau rezultatul poate fi scris în ținta legăturii simbolice, Scrierea la o țintă de legătură simbolică nu este acceptată în Windows.</p>
|
||||
|
||||
<p>«dos2unix» a fost modelat după «dos2unix» din SunOS/Solaris. Există o diferență importantă față de versiunea originală a SunOS/Solaris. Această versiune efectuează în mod implicit conversia „în același loc”, în cazul de față, în același fișier (mod-fișier_vechi), în timp ce versiunea originală SunOS/Solaris acceptă doar conversia împerecheată (mod-fișier_nou). A se vedea, de asemenea, opțiunile <code>-o</code> și <code>-n</code>. O altă diferență este că versiunea SunOS/Solaris utilizează implicit conversia în modul <i>iso</i>, în timp ce această versiune utilizează implicit conversia în modul <i>ascii</i>.</p>
|
||||
|
||||
<h1 id="OP-IUNI">OPȚIUNI</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tratează toate opțiunile următoare ca nume de fișiere. Utilizați această opțiune dacă doriți să convertiți fișiere ale căror nume încep cu o liniuță. De exemplu, pentru a converti un fișier numit „-foo”, puteți folosi această comandă:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Sau în modul-fișier_nou:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo ieșire.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Permite schimbarea proprietarului fișierului în modul-fișier_vechi.</p>
|
||||
|
||||
<p>Când este utilizată această opțiune, conversia nu va fi întreruptă atunci când utilizatorul și/sau grupul proprietar al fișierului original nu poate fi păstrat în modul-fișier_vechi. Conversia va continua și fișierul convertit va primi același nou proprietar ca și cum ar fi fost convertit în modul-fișier_nou. A se vedea, de asemenea, opțiunile <code>-o</code> și <code>-n</code>. Această opțiune este disponibilă numai dacă «dos2unix» are suport pentru păstrarea utilizatorului și grupului proprietar al fișierelor.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modul de conversie implicit (între setul de caractere DOS și ISO-8859-1). Consultați, de asemenea, secțiunea MODURI DE CONVERSIE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Conversie între setul de caractere DOS și ISO-8859-1. Consultați, de asemenea, secțiunea MODURI DE CONVERSIE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod Windows 1252 (Europa de vest).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod DOS 437 (SUA). Aceasta este pagina de cod implicită utilizată pentru conversia ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod DOS 850 (Europa de vest).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod DOS 860 (Portugalia).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod DOS 863 (Franceza Canadiană).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Utilizează pagina de cod DOS 865 (Scandinavia).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convertește caractere de 8 biți în spațiu de 7 biți.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Păstrează marcajul de ordine a octeților (BOM). Când fișierul de intrare are un marcaj de ordine a octeților, scrie marcajul de ordine a octeților în fișierul de ieșire. Acesta este comportamentul implicit la conversia de întreruperi de linie DOS. A se vedea, de asemenea, opțiunea <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-MOD_CONVERSIE"><b>-c, --convmode MOD_CONVERSIE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Stabilește modul de conversie. Unde MOD_CONVERSIE este unul dintre: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> „ascii” fiind valoarea implicită.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-COFIFICAREA"><b>-D, --display-enc COFIFICAREA</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Stabilește codificarea textului afișat. Unde CODIFICAREA este una dintre: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i>; „ascii” fiind valoarea implicită.</p>
|
||||
|
||||
<p>Această opțiune este disponibilă numai în «dos2uni» pentru Windows cu suport pentru numele fișierelor în Unicode. Această opțiune nu are efect asupra numelor de fișiere citite și scrise, ci doar asupra modului în care acestea sunt afișate.</p>
|
||||
|
||||
<p>Există mai multe metode de afișare a textului într-o consolă Windows bazate pe codificarea textului. Toate acestea au propriile lor avantaje și dezavantaje.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Metoda implicită a «dos2unix» este utilizarea textului codificat ANSI. Avantajul este acela că este compatibilă cu versiunea anterioară. Această opțiune funcționează cu fonturi bitmap și TrueType. În unele regiuni, poate fi necesar să schimbați pagina de coduri OEM DOS activă în pagina de coduri ANSI a sistemului Windows folosind comanda <code>chcp</code>, deoarece «dos2unix» utilizează pagina de coduri a sistemului Windows.</p>
|
||||
|
||||
<p>Dezavantajul lui „ansi” este că numele fișierelor internaționale cu caractere care nu sunt în interiorul paginii de cod implicite a sistemului, nu sunt afișate corect. Veți vedea în schimb un semn de întrebare sau un simbol greșit. Când nu lucrați cu nume de fișiere străine, această metodă este OK.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Avantajul codificării Unicode (numele Windows pentru UTF-16) este că textul este de obicei afișat corect. Nu este nevoie să schimbați pagina de cod activă. Poate fi necesar să definiți fontul consolei la un font TrueType pentru ca toate caracterele internaționale să fie afișate corect. Când un caracter nu este inclus în fontul TrueType, de obicei vedeți un pătrat mic, uneori cu un semn de întrebare în el.</p>
|
||||
|
||||
<p>Când utilizați consola ConEmu, tot textul este afișat corect, deoarece ConEmu selectează automat un font bun.</p>
|
||||
|
||||
<p>Dezavantajul unicode (UTF-16) este că nu este compatibil cu ASCII. Ieșirea nu este ușor de gestionat atunci când o redirecționați către alt program.</p>
|
||||
|
||||
<p>Când se folosește metoda <code>unicodebom</code>, textul Unicode va fi precedat de un BOM („Byte Order Mark” = marcaj de ordine a octeților). Este necesar un marcaj de ordine a octeților pentru redirecționarea corectă sau canalizarea în PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Avantajul lui utf8 este faptul că este compatibil cu ASCII. Trebuie să definiți fontul consolei la un font TrueType. Cu un font TrueType, textul este afișat similar cu codificarea <code>unicode</code>.</p>
|
||||
|
||||
<p>Dezavantajul este că atunci când utilizați fontul bitmap implicit, toate caracterele non-ASCII sunt afișate greșit. Nu numai numele fișierelor Unicode, ci și mesajele traduse devin imposibil de citit. În Windows configurat pentru o regiune din Asia de Est, este posibil să observați o mulțime de pâlpâiri ale consolei când mesajele sunt afișate.</p>
|
||||
|
||||
<p>Într-o consolă ConEmu, metoda de codificare utf8 funcționează bine.</p>
|
||||
|
||||
<p>Când se folosește metoda <code>utf8bom</code>, textul UTF-8 va fi precedat de un BOM („Byte Order Mark” = marcaj de ordine a octeților). Este necesar un marcaj de ordine a octeților pentru redirecționarea corectă sau canalizarea în PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Codificarea implicită poate fi schimbată cu variabila de mediu DOS2UNIX_DISPLAY_ENC definindu-i valoarea: <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> sau <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adaugă o întrerupere de linie la ultima linie, dacă nu există una. Acest lucru funcționează pentru fiecare conversie.</p>
|
||||
|
||||
<p>Un fișier convertit din formatul DOS în formatul Unix poate să nu aibă o întrerupere de linie pe ultima linie. Există editoare de text care scriu fișiere de text fără o întrerupere de linie pe ultima linie. Unele programe Unix au probleme în procesarea acestor fișiere, deoarece standardul POSIX definește că fiecare linie dintr-un fișier text trebuie să se încheie cu un caracter de sfârșit de linie nouă. De exemplu, concatenarea fișierelor poate să nu dea rezultatul așteptat.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returnează o eroare atunci când un fișier binar este omis.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Forțează conversia fișierelor binare.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>În Windows, fișierele UTF-16 sunt convertite implicit în UTF-8, indiferent de configurarea locală. Utilizați această opțiune pentru a converti fișierele UTF-16 în GB18030. Această opțiune este disponibilă numai în Windows. A se vedea, de asemenea, secțiunea GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează mesajul de ajutor și iese.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-FLAGS---info-FLAGS-FILE"><b>-i[FLAGS], --info[=FLAGS] FILE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează informații despre fișier. Nu se face nicio conversie.</p>
|
||||
|
||||
<p>Sunt afișate următoarele informații, în această ordine: numărul de întreruperi de linie DOS, numărul de întreruperi de linie Unix, numărul de întreruperi de linie Mac, marcajul de ordine a octeților, text sau binar, numele fișierului.</p>
|
||||
|
||||
<p>Exemplu de ieșire:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Rețineți că, uneori, un fișier binar poate fi confundat cu un fișier text. A se vedea, de asemenea, opțiunea <code>-s</code>.</p>
|
||||
|
||||
<p>Dacă, în plus, se utilizează opțiunea <code>-e</code> sau <code>--add-eol</code>, se imprimă, de asemenea, tipul întreruperii de linie de pe ultima linie sau <code>noeol</code>, dacă nu există.</p>
|
||||
|
||||
<p>Exemplu de ieșire:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Opțional, pot fi adăugate fanioane suplimentare pentru a modifica rezultatul. Se pot adăuga unul sau mai multe fanioane.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează liniile de informații ale fișierului urmate de un caracter null în loc de un caracter de linie nouă. Acest lucru permite interpretarea corectă a numelor de fișiere cu spații sau ghilimele atunci când este utilizat fanionul „c”. Utilizați acest fanion în combinație cu opțiunea xargs(1) <code>-0</code> sau <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează numărul de întreruperi de linie al formatului DOS.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează numărul de întreruperi de linie al formatului Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează numărul de întreruperi de linie al formatului Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează marcajul de ordine a octeților.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Indică dacă fișierul este text sau binar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Imprimă tipul întreruperii de linie de pe ultima linie sau <code>noeol</code> dacă nu există.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează numai fișierele care vor fi convertite.</p>
|
||||
|
||||
<p>Cu fanionul <code>c</code>, «dos2unix» va afișa numai fișierele care conțin întreruperi de linie DOS, «unix2dos» va afișa numai numele de fișiere care au întreruperi de linie Unix.</p>
|
||||
|
||||
<p>Dacă, în plus, se utilizează opțiunea <code>-e</code> sau <code>--add-eol</code>, vor fi afișate și fișierele cărora le lipsește o întrerupere de linie pe ultima linie.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează titlul.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează (doar) numele fișierelor, fără ruta către ele.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Exemple:</p>
|
||||
|
||||
<p>Afișează informații pentru toate fișierele *.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Afișează doar numărul de întreruperi de linie DOS și de întreruperi de linie Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Afișează doar marcajul de ordine a octeților:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Listează fișierele care au întreruperi de linie DOS:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Listează fișierele care au întreruperi de linie Unix:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Listează fișierele care au întreruperi de linie DOS sau care nu au întreruperi de linie pe ultima linie:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Convertește numai fișierele care au întreruperi de linie DOS și lasă celelalte fișiere neatinse:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Găsește fișiere text care au întreruperi de linie DOS:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Păstrează marcajul de dată al fișierului de ieșire la fel ca al fișierului de intrare.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează licența programului.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adaugă o linie nouă suplimentară.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Numai întreruperile de linie DOS sunt modificate în două întreruperi de linie Unix. În modul Mac, numai întreruperile de linie Mac sunt modificate în două întreruperi de linie Unix.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Numai întreruperile de linie Unix sunt modificate în două întreruperi de linie DOS. În modul Mac, întreruperile de linie Unix sunt modificate în două întreruperi de linie Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Scrie un marcaj de ordine a octeților (BOM) în fișierul de ieșire. În mod implicit, este scris un marcaj de ordine a octeților UTF-8.</p>
|
||||
|
||||
<p>Când fișierul de intrare este UTF-16 și este utilizată opțiunea <code>-u</code>, va fi scris un marcaj de ordine a octeților UTF-16.</p>
|
||||
|
||||
<p>Nu utilizați niciodată această opțiune când codificarea de ieșire este alta decât UTF-8, UTF-16 sau GB18030. Vedeți, de asemenea, secțiunea UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-FI-IER_INTRARE-FI-IER_IE-IRE"><b>-n, --newfile FIȘIER_INTRARE FIȘIER_IEȘIRE ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modul de fișier nou. Convertiți fișierul FIȘIER_INTRARE și scrieți rezultatul în fișierul FIȘIER_IEȘIRE. Numele fișierelor trebuie să fie date în perechi, iar numele cu metacaractere ar trebui să <i>nu</i> fi folosite sau v-ați puteai pierde fișierele.</p>
|
||||
|
||||
<p>Persoana care începe conversia în modul-fișier_nou (pereche) va fi proprietarul fișierului convertit. Permisiunile de citire/scriere ale noului fișier vor fi permisiunile fișierului original minus umask(1) al persoanei care execută conversia.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nu permite schimbarea proprietarului fișierului în modul-fișier_vechi (implicit).</p>
|
||||
|
||||
<p>Anulează conversia atunci când utilizatorul și/sau grupul proprietar al fișierului original nu poate fi păstrat în modul-fișier_vechi. A se vedea, de asemenea, opțiunile <code>-o</code> și <code>-n</code>. Această opțiune este disponibilă doar dacă «dos2unix» are suport pentru păstrarea dreptului de proprietate asupra fișierelor de către utilizator și grup.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nu adaugă o întrerupere de linie la ultima linie, dacă nu există una (implicit).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nu returnează o eroare atunci când un fișier binar este omis (implicit).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Scrie la ieșirea standard, ca un filtru Unix. Folosiți opțiunea <code>-o</code> pentru a reveni la modul-fișier_vechi (în același loc / în același fișier).</p>
|
||||
|
||||
<p>În combinație cu opțiunea <code>-e</code>, fișierele pot fi concatenate în mod corespunzător. Nu se fuzionează ultima și prima linie și nici marcajele de ordine a octeților (BOM) Unicode în mijlocul fișierului concatenat. Exemplu:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O fișier1.txt fișier2.txt > fișier_ieșire.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-FI-IER"><b>-o, --oldfile FIȘIER ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modul fișier vechi. Convertește fișierul FIȘIER și suprascrie rezultatul în el. Programul rulează implicit în acest mod. Pot fi folosite nume cu metacaractere.</p>
|
||||
|
||||
<p>În modul-fișier_vechi (în același loc / în același fișier), fișierul convertit primește același proprietar, grup și permisiuni de citire/scriere ca fișierul original. De asemenea, atunci când fișierul este convertit de un alt utilizator care are permisiuni de scriere în fișier (de exemplu, utilizatorul root). Conversia va fi anulată atunci când nu este posibil să se păstreze valorile originale. Schimbarea proprietarului ar putea însemna că proprietarul inițial nu mai poate citi fișierul. Schimbarea grupului ar putea reprezenta un risc de securitate, fișierul ar putea fi făcut vizibil pentru persoanele cărora nu este destinat. Păstrarea permisiunilor de proprietar, de grup și de citire/scriere este acceptată numai în Unix.</p>
|
||||
|
||||
<p>Pentru a verifica dacă «dos2unix» are suport pentru păstrarea proprietății utilizatorului și grupului de fișiere, tastați <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Conversia se face întotdeauna printr-un fișier temporar. Când apare o eroare la jumătatea conversiei, fișierul temporar este șters și fișierul original rămâne intact. Când conversia are succes, fișierul original este înlocuit cu fișierul temporar. Este posibil să aveți permisiunea de scriere în fișierul original, dar nu aveți permisiunea de a pune aceleași proprietăți de proprietate ale utilizatorului și/sau grupului asupra fișierului temporar ca cele pe care le are fișierul original. Aceasta înseamnă că nu puteți păstra utilizatorul și/sau grupul proprietar al fișierului original. În acest caz, puteți utiliza opțiunea <code>--allow-chown</code> pentru a continua conversia:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>O altă opțiune este să utilizați modul-fișier_nou:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Avantajul opțiunii <code>--allow-chown</code> este că puteți folosi metacaractere, iar proprietățile de proprietate vor fi păstrate atunci când este posibil.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Modul silențios. Suprimă toate avertismentele și mesajele. Valoarea returnată este zero. Cu excepția cazului în care sunt utilizate opțiuni greșite în linia de comandă.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Elimină marcajul de ordine a octeților (BOM). Nu scrie un marcaj de ordine a octeților în fișierul de ieșire. Acesta este comportamentul implicit la conversia întreruperilor de linie Unix. A se vedea, de asemenea, opțiunea <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Omite fișierele binare (implicit).</p>
|
||||
|
||||
<p>Omiterea fișierelor binare se face pentru a evita greșelile accidentale. Rețineți că detectarea fișierelor binare nu este 100% sigură. Fișierele de intrare sunt scanate pentru simboluri binare care de obicei nu se găsesc în fișierele text. Este posibil ca un fișier binar să conțină doar caractere de text normale. Un astfel de fișier binar va fi văzut din greșeală ca un fișier text.</p>
|
||||
|
||||
<p>În mod implicit, nu se returnează nicio eroare atunci când un fișier binar este omis. Atunci când se utilizează opțiunea <code>--error-binary</code>, se returnează o eroare.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Presupune că formatul fișierului de intrare este UTF-16LE.</p>
|
||||
|
||||
<p>Când există un marcaj de ordine a octeților în fișierul de intrare, marcajul de ordine a octeților are prioritate față de această opțiune.</p>
|
||||
|
||||
<p>Când ați făcut o presupunere greșită (fișierul de intrare nu era în format UTF-16LE) și conversia a reușit, veți obține un fișier de ieșire UTF-8 cu text greșit. Puteți anula conversia greșită cu iconv(1) prin conversia fișierului de ieșire UTF-8 înapoi în UTF-16LE. Acest lucru va reface fișierul original.</p>
|
||||
|
||||
<p>Presupunerea UTF-16LE funcționează ca un <i>mod de conversie</i>. Prin trecerea la modul <i>ascii</i> implicit, presupunerea UTF-16LE este dezactivată.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Presupune că formatul fișierului de intrare este UTF-16BE.</p>
|
||||
|
||||
<p>Această opțiune funcționează la fel ca și opțiunea <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează mesaje detaliate. Sunt afișate informații suplimentare despre mărcile de ordine ale octeților și cantitatea de întreruperi de linie convertite.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Urmează legăturile simbolice și convertește țintele.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Înlocuiește legăturile simbolice cu fișierele convertite (fișierele țintă originale rămân neschimbate).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Păstrează legăturile simbolice și țintele neschimbate (implicit).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Afișează informațiile despre versiune și iese.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MODUL-MAC">MODUL MAC</h1>
|
||||
|
||||
<p>În mod implicit, salturile (întreruperile) de linie sunt convertite din DOS în Unix și invers. Întreruperile de linie Mac nu sunt convertite.</p>
|
||||
|
||||
<p>În modul Mac, întreruperile de linie sunt convertite din Mac în Unix și invers. Întreruperile de linie DOS nu sunt modificate.</p>
|
||||
|
||||
<p>Pentru a rula în modul Mac, utilizați opțiunea din linie de comandă <code>-c mac</code> sau utilizați comenzile <code>mac2unix</code> sau <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="MODURI-DE-CONVERSIE">MODURI DE CONVERSIE</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Acesta este modul de conversie implicit. Acest mod este destinat conversiei fișierelor codificate ASCII și compatibile cu ASCII, cum ar fi UTF-8. Activarea modului <b>ascii</b> dezactivează modurile <b>7bit</b> și <b>iso</b>.</p>
|
||||
|
||||
<p>Dacă «dos2unix» are suport UTF-16, fișierele codificate UTF-16 sunt convertite la codificarea caracterelor locale curente pe sistemele POSIX și la UTF-8 pe Windows. Activarea modului <b>ascii</b> dezactivează opțiunea de păstrare a codificării UTF-16 (<code>-u</code>) și opțiunile de asumare a intrării UTF-16 (<code>-ul</code> și <code>-ub</code>). Pentru a vedea dacă «dos2unix» are suport UTF-16, tastați <code>dos2unix -V</code>. A se vedea și secțiunea UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>În acest mod, toate caracterele de 8 biți non-ASCII (cu valori de la 128 la 255) sunt convertite într-un spațiu de 7 biți.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Caracterele sunt convertite între un set de caractere DOS (pagina de cod) și un set de caractere ISO ISO-8859-1 (Latin-1) în Unix. Caracterele DOS fără echivalent ISO-8859-1, pentru care conversia nu este posibilă, sunt convertite într-un punct. Același lucru este valabil și pentru caracterele ISO-8859-1 fără omolog în DOS.</p>
|
||||
|
||||
<p>Când este folosită numai opțiunea <code>-iso</code>, «dos2unix» va încerca să determine pagina de cod activă. Când acest lucru nu este posibil, «dos2unix» va folosi pagina de cod implicită CP437, care este folosită în principal în SUA. Pentru a forța o anumită pagină de coduri, utilizați opțiunile <code>-437</code> (SUA), <code>-850</code> (Europa de Vest), <code>-860</code> (Portugheză), <code>-863</code> (Franceză Canadiană) sau <code>- 865</code> (Scandinavă). Pagina de coduri CP1252 (Europa de Vest) Windows este, de asemenea, acceptată cu opțiunea <code>-1252</code>. Pentru alte pagini de cod, utilizați «dos2unix» în combinație cu iconv(1). «iconv» poate converti o listă lungă de codificări de caractere. Puteți vizualiza această listă rulând comanda: «iconv -l».</p>
|
||||
|
||||
<p>Nu utilizați niciodată conversia ISO pe fișiere text Unicode. Acesta va deteriora fișierele codificate UTF-8.</p>
|
||||
|
||||
<p>Câteva exemple:</p>
|
||||
|
||||
<p>Convertește din pagina de cod implicită DOS în Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din CP850 DOS în Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din CP1252 Windows în Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din CP1252 Windows în UTF-8 (Unicode) Unix:</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 fișier_intrare.txt | dos2unix > fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din Latin-1 Unix la pagina de cod implicită DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din Latin-1 Unix în CP850 DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din Latin-1 Unix în CP1252 Windows:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din UTF-8 (Unicode) Unix în CP1252 Windows:</p>
|
||||
|
||||
<pre><code>unix2dos < fișier_intrare.txt | iconv -f UTF-8 -t CP1252 > fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Codific-ri">Codificări</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Conversie">Conversie</h2>
|
||||
|
||||
<p>Fișierele text Unicode pot avea întreruperi de linie DOS, Unix sau Mac, ca și fișierele text ASCII.</p>
|
||||
|
||||
<p>Toate versiunile de «dos2unix» și «unix2dos» pot converti fișiere codificate în formatul UTF-8, deoarece UTF-8 a fost conceput pentru compatibilitate cu ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>În Unix/Linux, fișierele codificate UTF-16 sunt convertite în codificarea caracterelor locale. Utilizați comanda locale(1) pentru a afla care este codificarea caracterelor stabilită de localizare. Atunci când conversia nu este posibilă, va apărea o eroare de conversie și fișierul va fi omis.</p>
|
||||
|
||||
<p>În Windows, fișierele UTF-16 sunt convertite în mod implicit în UTF-8. Fișierele text formatate UTF-8 sunt bine acceptate atât în Windows, cât și în Unix/Linux.</p>
|
||||
|
||||
<p>Codificările UTF-16 și UTF-8 sunt pe deplin compatibile, nu se va pierde text în conversie. Când apare o eroare de conversie din UTF-16 în UTF-8, de exemplu când fișierul de intrare UTF-16 conține o eroare, fișierul va fi omis.</p>
|
||||
|
||||
<p>Când se utilizează opțiunea <code>-u</code>, fișierul de ieșire va fi scris în aceeași codificare UTF-16 ca și fișierul de intrare. Opțiunea <code>-u</code> împiedică conversia în UTF-8.</p>
|
||||
|
||||
<p>«dos2unix» și «unix2dos» nu au nicio opțiune de a converti fișierele UTF-8 în UTF-16.</p>
|
||||
|
||||
<p>Modurile de conversie ISO și 7 biți nu funcționează pe fișierele UTF-16.</p>
|
||||
|
||||
<h2 id="Marcajul-de-ordine-a-octe-ilor">Marcajul de ordine a octeților</h2>
|
||||
|
||||
<p>În Windows, fișierele text Unicode au de obicei un marcaj de ordine a octeților (BOM), deoarece multe programe Windows (inclusiv Notepad) adaugă marcajul de ordine a octeților în mod implicit. A se vedea, de asemenea, <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>În Unix, fișierele Unicode nu au de obicei un marcaj de ordine a octeților (BOM). Se presupune că fișierele text sunt codificate în codificarea caracterelor stabilită de localizare.</p>
|
||||
|
||||
<p>«dos2unix» poate detecta dacă un fișier este în formatul UTF-16 numai dacă fișierul are un marcaj de ordine a octeților (BOM). Când un fișier UTF-16 nu are un marcaj de ordine a octeților, «dos2unix» va vedea fișierul ca un fișier binar.</p>
|
||||
|
||||
<p>Utilizați opțiunea <code>-ul</code> sau <code>-ub</code> pentru a converti un fișier UTF-16 fără un marcaj de ordine a octeților (BOM).</p>
|
||||
|
||||
<p>«dos2unix» nu scrie în mod implicit niciun marcaj de ordine a octeților (BOM) în fișierul de ieșire. Cu opțiunea <code>-b</code> «dos2unix» scrie un marcaj de ordine a octeților atunci când fișierul de intrare are un marcaj de ordine a octeților.</p>
|
||||
|
||||
<p>«unix2dos» scrie implicit un marcaj de ordine a octeților în fișierul de ieșire când fișierul de intrare are un marcaj de ordine a octeților. Utilizați opțiunea <code>-r</code> pentru a elimina un marcaj de ordine a octeților.</p>
|
||||
|
||||
<p>«dos2unix» și «unix2dos» scriu întotdeauna un marcaj de ordine a octeților atunci când se utilizează opțiunea <code>-m</code>.</p>
|
||||
|
||||
<h2 id="Nume-de-fi-iere-Unicode-n-Windows">Nume de fișiere Unicode în Windows</h2>
|
||||
|
||||
<p>«dos2unix» are suport opțional pentru citirea și scrierea numelor de fișiere Unicode în linia de comandă Windows. Asta înseamnă că «dos2unix» poate deschide fișiere care au caractere în nume care nu fac parte din pagina de cod ANSI implicită a sistemului. Pentru a vedea dacă «dos2unix» pentru Windows a fost construit cu suport pentru nume de fișier Unicode, tastați: <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Există unele probleme cu afișarea numelor de fișiere Unicode într-o consolă Windows. Vedeți opțiunea <code>-D</code>, <code>--display-enc</code>. Numele fișierelor pot fi afișate greșit în consolă, dar fișierele vor fi scrise cu numele corect.</p>
|
||||
|
||||
<h2 id="Exemple-Unicode">Exemple Unicode</h2>
|
||||
|
||||
<p>Convertește din UTF-16 Windows (fără BOM) în UTF-8 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din UTF-16LE Windows (fără BOM) în UTF-8 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din UTF-8 Unix în Windows UTF-8 Windows cu BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n fișier_intrare.txt fișier_ieșire.txt</code></pre>
|
||||
|
||||
<p>Convertește din UTF-8 Unix în UTF-16 Windows:</p>
|
||||
|
||||
<pre><code>unix2dos < fișier_intrare.txt | iconv -f UTF-8 -t UTF-16 > fișier_ieșire.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 este un standard guvernamental chinez. Un subset obligatoriu al standardului GB18030 este obligatoriu oficial pentru toate produsele software vândute în China. A se vedea, de asemenea, <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>Standardul GB18030 este pe deplin compatibil cu Unicode și poate fi considerat un format de transformare unicode. La fel ca UTF-8, GB18030 este compatibil cu ASCII. GB18030 este, de asemenea, compatibil cu pagina de cod 936 Windows, cunoscută și sub numele de GBK.</p>
|
||||
|
||||
<p>În Unix/Linux, fișierele UTF-16 sunt convertite în GB18030 atunci când codificarea locală este setată la GB18030. Rețineți că acest lucru va funcționa numai dacă localizarea este acceptată de sistem. Utilizați comanda <code>locale -a</code> pentru a obține lista localizărilor acceptate.</p>
|
||||
|
||||
<p>În Windows, trebuie să utilizați opțiunea <code>-gb</code> pentru a converti fișierele UTF-16 în GB18030.</p>
|
||||
|
||||
<p>Fișierele codificate GB18030 pot avea un marcaj de ordine a octeților, precum fișierele Unicode.</p>
|
||||
|
||||
<h1 id="EXEMPLE">EXEMPLE</h1>
|
||||
|
||||
<p>Citește intrarea din „stdin” (intrarea standard) și scrie ieșirea la „stdout” (ieșirea standard):</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Convertește și înlocuiește a.txt. Convertește și înlocuiește b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Convertește și înlocuiește a.txt în modul de conversie ascii:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Convertește și înlocuiește a.txt în modul de conversie ascii, convertește și înlocuiește b.txt în modul de conversie pe 7 biți:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Convertește a.txt din formatul Mac în formatul Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Convertește a.txt din formatul Unix în formatul Mac:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Convertește și înlocuiește a.txt, păstrând marcajul original al datei:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Convertește a.txt și scrie în e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertește a.txt și scrie în e.txt, și face ca marcajul de dată al lui e.txt să fie la fel cu cel al lui a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertește și înlocuiește a.txt, converteștei b.txt și scrie în e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Convertește c.txt și scrie în e.txt, convertește și înlocuiește a.txt, convertește și înlocuiește b.txt, convertește d.txt și scrie în f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="CONVERSIE-RECURSIV">CONVERSIE RECURSIVĂ</h1>
|
||||
|
||||
<p>Într-un shell Unix, comenzile find(1) și xargs(1) pot să fie folosite pentru a rula «dos2unix» în mod recursiv asupra tuturor fișierele text dintr-un arbore de directoare. De exemplu, pentru a converti toate fișierele .txt din arborele de directoare sub directorul curent, tastați:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Opțiunea find(1) <code>-print0</code> și opțiunea corespunzătoare xargs(1) <code>-0</code> sunt necesare atunci când există fișiere cu spații sau ghilimele în nume. În caz contrar, aceste opțiuni pot fi omise. O altă opțiune este să utilizați find(1) cu opțiunea <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>Într-un prompt de comandă Windows se poate folosi următoarea comandă:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>Utilizatorii de PowerShell pot folosi următoarea comandă a PowerShell de Windows:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOCALIZAREA">LOCALIZAREA</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Limba principală este selectată cu variabila de mediu LANG. Variabila LANG constă din mai multe părți. Prima parte este codul limbii cu litere mici. Al doilea este opțional și este codul țării cu majuscule, precedat de un caracter de subliniere. Există, de asemenea, o a treia parte opțională: codificarea caracterelor, precedată de un punct. Câteva exemple pentru shell-uri de tip standard POSIX:</p>
|
||||
|
||||
<pre><code>export LANG=nl Olandeză
|
||||
export LANG=nl_NL Olandeză, Olanda
|
||||
export LANG=nl_BE Olandeză, Belgia
|
||||
export LANG=es_ES Spaniolă, Spania
|
||||
export LANG=es_MX Spaniolă, Mexic
|
||||
export LANG=en_US.iso88591 Engleză, SUA, codificarea Latin-1
|
||||
export LANG=en_GB.UTF-8 Engleză, UK, codificarea UTF-8</code></pre>
|
||||
|
||||
<p>Pentru o listă completă a codurilor de limbă și de țară, consultați manualul «gettext»: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>În sistemele Unix, puteți utiliza comanda locale(1) pentru a obține informații specifice despre localizare.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Cu variabila de mediu LANGUAGE puteți specifica o listă cu prioritate de limbi, separate prin două puncte. «dos2unix» dă preferință variabilei LANGUAGE în detrimentul variabilei LANG. De exemplu, mai întâi olandeză și apoi germană: <code>LANGUAGE=nl:de</code>. Mai întâi trebuie să activați localizarea, definind LANG (sau LC_ALL) la o altă valoare decât „C”, înainte de a putea utiliza o listă cu prioritate de limbă prin variabila LANGUAGE. Consultați și manualul «gettext»: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Dacă selectați o limbă care nu este disponibilă, veți primi mesajele standard în limba engleză.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Cu variabila de mediu DOS2UNIX_LOCALEDIR, variabila LOCALEDIR definită în timpul compilării poate fi înlocuită. LOCALEDIR este folosită pentru a găsi fișierele de limbă. Valoarea implicită GNU este <code>/usr/local/share/locale</code>. Opțiunea <b>--version</b> va afișa valoarea pe care LOCALEDIR o utilizează.</p>
|
||||
|
||||
<p>Exemplu (shell POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="VALOAREA-RETURNAT">VALOAREA RETURNATĂ</h1>
|
||||
|
||||
<p>La succes, se returnează zero. Când apare o eroare de sistem, va fi returnată ultima eroare de sistem. Pentru alte erori se returnează 1.</p>
|
||||
|
||||
<p>Valoarea returnată este întotdeauna zero în modul silențios, cu excepția cazului în care sunt utilizate opțiuni greșite ale liniei de comandă.</p>
|
||||
|
||||
<h1 id="STANDARDE">STANDARDE</h1>
|
||||
|
||||
<p><a href="https://ro.wikipedia.org/wiki/Fi%C8%99ier_text">https://ro.wikipedia.org/wiki/Fi%C8%99ier_text</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://ro.wikipedia.org/wiki/Unicode">https://ro.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="AUTORI">AUTORI</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (modul mac2unix) - <wuebben@kde.org>, Christian Wurll (adăugarea unei linii noi suplimentare) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (menținător)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Pagina din SourceForge a proiectului: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="CONSULTA-I-I">CONSULTAȚI ȘI</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
885
Agent-Windows/OGP64/usr/share/doc/dos2unix/ro/dos2unix.txt
Normal file
885
Agent-Windows/OGP64/usr/share/doc/dos2unix/ro/dos2unix.txt
Normal file
|
|
@ -0,0 +1,885 @@
|
|||
NUME
|
||||
dos2unix - Convertor de format de fișier text din DOS/Mac în Unix și
|
||||
viceversa
|
||||
|
||||
SINOPSIS
|
||||
dos2unix [opțiuni] [FIȘIER ...] [-n FIȘIER_INTRARE FIȘIER_IEȘIRE ...]
|
||||
unix2dos [opțiuni] [FIȘIER ...] [-n FIȘIER_INTRARE FIȘIER_IEȘIRE ...]
|
||||
|
||||
DESCRIERE
|
||||
Pachetul «dos2unix» include utilitarele "dos2unix" și "unix2dos" pentru
|
||||
a converti fișierele text simplu din formatul DOS sau Mac în formatul
|
||||
Unix și invers.
|
||||
|
||||
În fișierele text DOS/Windows, o întrerupere de linie, cunoscută și sub
|
||||
numele de linie nouă, este o combinație de două caractere: un retur de
|
||||
caret (CR) urmat de un salt de linie (LF). În fișierele text Unix, o
|
||||
întrerupere de linie este un singur caracter: saltul de linie (LF). În
|
||||
fișierele text Mac, înainte de Mac OS X, o întrerupere de linie era un
|
||||
singur caracter retur de caret (CR). În prezent, Mac OS folosește
|
||||
întreruperi de linie în stil Unix (LF).
|
||||
|
||||
Pe lângă întreruperile de linie, «dos2unix» poate converti și
|
||||
codificarea fișierelor. Câteva pagini de cod DOS pot fi convertite în
|
||||
Latin-1 Unix. Și fișierele Unicode Windows (UTF-16) pot fi convertite în
|
||||
fișiere Unicode Unix (UTF-8).
|
||||
|
||||
Fișierele binare sunt omise automat, cu excepția cazului în care
|
||||
conversia este forțată.
|
||||
|
||||
Fișierele care nu sunt obișnuite, cum ar fi directoarele și liniile de
|
||||
conectare cu nume (FIFOs), sunt omise automat.
|
||||
|
||||
Legăturile simbolice și țintele lor sunt în mod implicit păstrate
|
||||
neatinse. Legăturile simbolice pot fi înlocuite opțional sau rezultatul
|
||||
poate fi scris în ținta legăturii simbolice, Scrierea la o țintă de
|
||||
legătură simbolică nu este acceptată în Windows.
|
||||
|
||||
«dos2unix» a fost modelat după «dos2unix» din SunOS/Solaris. Există o
|
||||
diferență importantă față de versiunea originală a SunOS/Solaris.
|
||||
Această versiune efectuează în mod implicit conversia „în același loc”,
|
||||
în cazul de față, în același fișier (mod-fișier_vechi), în timp ce
|
||||
versiunea originală SunOS/Solaris acceptă doar conversia împerecheată
|
||||
(mod-fișier_nou). A se vedea, de asemenea, opțiunile "-o" și "-n". O
|
||||
altă diferență este că versiunea SunOS/Solaris utilizează implicit
|
||||
conversia în modul *iso*, în timp ce această versiune utilizează
|
||||
implicit conversia în modul *ascii*.
|
||||
|
||||
OPȚIUNI
|
||||
-- Tratează toate opțiunile următoare ca nume de fișiere. Utilizați
|
||||
această opțiune dacă doriți să convertiți fișiere ale căror nume
|
||||
încep cu o liniuță. De exemplu, pentru a converti un fișier numit
|
||||
„-foo”, puteți folosi această comandă:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Sau în modul-fișier_nou:
|
||||
|
||||
dos2unix -n -- -foo ieșire.txt
|
||||
|
||||
--allow-chown
|
||||
Permite schimbarea proprietarului fișierului în modul-fișier_vechi.
|
||||
|
||||
Când este utilizată această opțiune, conversia nu va fi întreruptă
|
||||
atunci când utilizatorul și/sau grupul proprietar al fișierului
|
||||
original nu poate fi păstrat în modul-fișier_vechi. Conversia va
|
||||
continua și fișierul convertit va primi același nou proprietar ca și
|
||||
cum ar fi fost convertit în modul-fișier_nou. A se vedea, de
|
||||
asemenea, opțiunile "-o" și "-n". Această opțiune este disponibilă
|
||||
numai dacă «dos2unix» are suport pentru păstrarea utilizatorului și
|
||||
grupului proprietar al fișierelor.
|
||||
|
||||
-ascii
|
||||
Modul de conversie implicit (între setul de caractere DOS și
|
||||
ISO-8859-1). Consultați, de asemenea, secțiunea MODURI DE CONVERSIE.
|
||||
|
||||
-iso
|
||||
Conversie între setul de caractere DOS și ISO-8859-1. Consultați, de
|
||||
asemenea, secțiunea MODURI DE CONVERSIE.
|
||||
|
||||
-1252
|
||||
Utilizează pagina de cod Windows 1252 (Europa de vest).
|
||||
|
||||
-437
|
||||
Utilizează pagina de cod DOS 437 (SUA). Aceasta este pagina de cod
|
||||
implicită utilizată pentru conversia ISO.
|
||||
|
||||
-850
|
||||
Utilizează pagina de cod DOS 850 (Europa de vest).
|
||||
|
||||
-860
|
||||
Utilizează pagina de cod DOS 860 (Portugalia).
|
||||
|
||||
-863
|
||||
Utilizează pagina de cod DOS 863 (Franceza Canadiană).
|
||||
|
||||
-865
|
||||
Utilizează pagina de cod DOS 865 (Scandinavia).
|
||||
|
||||
-7 Convertește caractere de 8 biți în spațiu de 7 biți.
|
||||
|
||||
-b, --keep-bom
|
||||
Păstrează marcajul de ordine a octeților (BOM). Când fișierul de
|
||||
intrare are un marcaj de ordine a octeților, scrie marcajul de
|
||||
ordine a octeților în fișierul de ieșire. Acesta este comportamentul
|
||||
implicit la conversia de întreruperi de linie DOS. A se vedea, de
|
||||
asemenea, opțiunea "-r".
|
||||
|
||||
-c, --convmode MOD_CONVERSIE
|
||||
Stabilește modul de conversie. Unde MOD_CONVERSIE este unul dintre:
|
||||
*ascii*, *7bit*, *iso*, *mac* „ascii” fiind valoarea implicită.
|
||||
|
||||
-D, --display-enc COFIFICAREA
|
||||
Stabilește codificarea textului afișat. Unde CODIFICAREA este una
|
||||
dintre: *ansi*, *unicode*, *unicodebom*, *utf8*, *utf8bom*; „ascii”
|
||||
fiind valoarea implicită.
|
||||
|
||||
Această opțiune este disponibilă numai în «dos2uni» pentru Windows
|
||||
cu suport pentru numele fișierelor în Unicode. Această opțiune nu
|
||||
are efect asupra numelor de fișiere citite și scrise, ci doar asupra
|
||||
modului în care acestea sunt afișate.
|
||||
|
||||
Există mai multe metode de afișare a textului într-o consolă Windows
|
||||
bazate pe codificarea textului. Toate acestea au propriile lor
|
||||
avantaje și dezavantaje.
|
||||
|
||||
ansi
|
||||
Metoda implicită a «dos2unix» este utilizarea textului codificat
|
||||
ANSI. Avantajul este acela că este compatibilă cu versiunea
|
||||
anterioară. Această opțiune funcționează cu fonturi bitmap și
|
||||
TrueType. În unele regiuni, poate fi necesar să schimbați pagina
|
||||
de coduri OEM DOS activă în pagina de coduri ANSI a sistemului
|
||||
Windows folosind comanda "chcp", deoarece «dos2unix» utilizează
|
||||
pagina de coduri a sistemului Windows.
|
||||
|
||||
Dezavantajul lui „ansi” este că numele fișierelor internaționale
|
||||
cu caractere care nu sunt în interiorul paginii de cod implicite
|
||||
a sistemului, nu sunt afișate corect. Veți vedea în schimb un
|
||||
semn de întrebare sau un simbol greșit. Când nu lucrați cu nume
|
||||
de fișiere străine, această metodă este OK.
|
||||
|
||||
unicode, unicodebom
|
||||
Avantajul codificării Unicode (numele Windows pentru UTF-16)
|
||||
este că textul este de obicei afișat corect. Nu este nevoie să
|
||||
schimbați pagina de cod activă. Poate fi necesar să definiți
|
||||
fontul consolei la un font TrueType pentru ca toate caracterele
|
||||
internaționale să fie afișate corect. Când un caracter nu este
|
||||
inclus în fontul TrueType, de obicei vedeți un pătrat mic,
|
||||
uneori cu un semn de întrebare în el.
|
||||
|
||||
Când utilizați consola ConEmu, tot textul este afișat corect,
|
||||
deoarece ConEmu selectează automat un font bun.
|
||||
|
||||
Dezavantajul unicode (UTF-16) este că nu este compatibil cu
|
||||
ASCII. Ieșirea nu este ușor de gestionat atunci când o
|
||||
redirecționați către alt program.
|
||||
|
||||
Când se folosește metoda "unicodebom", textul Unicode va fi
|
||||
precedat de un BOM („Byte Order Mark” = marcaj de ordine a
|
||||
octeților). Este necesar un marcaj de ordine a octeților pentru
|
||||
redirecționarea corectă sau canalizarea în PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
Avantajul lui utf8 este faptul că este compatibil cu ASCII.
|
||||
Trebuie să definiți fontul consolei la un font TrueType. Cu un
|
||||
font TrueType, textul este afișat similar cu codificarea
|
||||
"unicode".
|
||||
|
||||
Dezavantajul este că atunci când utilizați fontul bitmap
|
||||
implicit, toate caracterele non-ASCII sunt afișate greșit. Nu
|
||||
numai numele fișierelor Unicode, ci și mesajele traduse devin
|
||||
imposibil de citit. În Windows configurat pentru o regiune din
|
||||
Asia de Est, este posibil să observați o mulțime de pâlpâiri ale
|
||||
consolei când mesajele sunt afișate.
|
||||
|
||||
Într-o consolă ConEmu, metoda de codificare utf8 funcționează
|
||||
bine.
|
||||
|
||||
Când se folosește metoda "utf8bom", textul UTF-8 va fi precedat
|
||||
de un BOM („Byte Order Mark” = marcaj de ordine a octeților).
|
||||
Este necesar un marcaj de ordine a octeților pentru
|
||||
redirecționarea corectă sau canalizarea în PowerShell.
|
||||
|
||||
Codificarea implicită poate fi schimbată cu variabila de mediu
|
||||
DOS2UNIX_DISPLAY_ENC definindu-i valoarea: "unicode", "unicodebom",
|
||||
"utf8" sau "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Adaugă o întrerupere de linie la ultima linie, dacă nu există una.
|
||||
Acest lucru funcționează pentru fiecare conversie.
|
||||
|
||||
Un fișier convertit din formatul DOS în formatul Unix poate să nu
|
||||
aibă o întrerupere de linie pe ultima linie. Există editoare de text
|
||||
care scriu fișiere de text fără o întrerupere de linie pe ultima
|
||||
linie. Unele programe Unix au probleme în procesarea acestor
|
||||
fișiere, deoarece standardul POSIX definește că fiecare linie
|
||||
dintr-un fișier text trebuie să se încheie cu un caracter de sfârșit
|
||||
de linie nouă. De exemplu, concatenarea fișierelor poate să nu dea
|
||||
rezultatul așteptat.
|
||||
|
||||
--error-binary
|
||||
Returnează o eroare atunci când un fișier binar este omis.
|
||||
|
||||
-f, --force
|
||||
Forțează conversia fișierelor binare.
|
||||
|
||||
-gb, --gb18030
|
||||
În Windows, fișierele UTF-16 sunt convertite implicit în UTF-8,
|
||||
indiferent de configurarea locală. Utilizați această opțiune pentru
|
||||
a converti fișierele UTF-16 în GB18030. Această opțiune este
|
||||
disponibilă numai în Windows. A se vedea, de asemenea, secțiunea
|
||||
GB18030.
|
||||
|
||||
-h, --help
|
||||
Afișează mesajul de ajutor și iese.
|
||||
|
||||
-i[FLAGS], --info[=FLAGS] FILE ...
|
||||
Afișează informații despre fișier. Nu se face nicio conversie.
|
||||
|
||||
Sunt afișate următoarele informații, în această ordine: numărul de
|
||||
întreruperi de linie DOS, numărul de întreruperi de linie Unix,
|
||||
numărul de întreruperi de linie Mac, marcajul de ordine a octeților,
|
||||
text sau binar, numele fișierului.
|
||||
|
||||
Exemplu de ieșire:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Rețineți că, uneori, un fișier binar poate fi confundat cu un fișier
|
||||
text. A se vedea, de asemenea, opțiunea "-s".
|
||||
|
||||
Dacă, în plus, se utilizează opțiunea "-e" sau "--add-eol", se
|
||||
imprimă, de asemenea, tipul întreruperii de linie de pe ultima linie
|
||||
sau "noeol", dacă nu există.
|
||||
|
||||
Exemplu de ieșire:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Opțional, pot fi adăugate fanioane suplimentare pentru a modifica
|
||||
rezultatul. Se pot adăuga unul sau mai multe fanioane.
|
||||
|
||||
0 Afișează liniile de informații ale fișierului urmate de un
|
||||
caracter null în loc de un caracter de linie nouă. Acest lucru
|
||||
permite interpretarea corectă a numelor de fișiere cu spații sau
|
||||
ghilimele atunci când este utilizat fanionul „c”. Utilizați
|
||||
acest fanion în combinație cu opțiunea xargs(1) -0 sau "--null".
|
||||
|
||||
d Afișează numărul de întreruperi de linie al formatului DOS.
|
||||
|
||||
u Afișează numărul de întreruperi de linie al formatului Unix.
|
||||
|
||||
m Afișează numărul de întreruperi de linie al formatului Mac.
|
||||
|
||||
b Afișează marcajul de ordine a octeților.
|
||||
|
||||
t Indică dacă fișierul este text sau binar.
|
||||
|
||||
e Imprimă tipul întreruperii de linie de pe ultima linie sau
|
||||
"noeol" dacă nu există.
|
||||
|
||||
c Afișează numai fișierele care vor fi convertite.
|
||||
|
||||
Cu fanionul "c", «dos2unix» va afișa numai fișierele care conțin
|
||||
întreruperi de linie DOS, «unix2dos» va afișa numai numele de
|
||||
fișiere care au întreruperi de linie Unix.
|
||||
|
||||
Dacă, în plus, se utilizează opțiunea "-e" sau "--add-eol", vor
|
||||
fi afișate și fișierele cărora le lipsește o întrerupere de
|
||||
linie pe ultima linie.
|
||||
|
||||
h Afișează titlul.
|
||||
|
||||
p Afișează (doar) numele fișierelor, fără ruta către ele.
|
||||
|
||||
Exemple:
|
||||
|
||||
Afișează informații pentru toate fișierele *.txt:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Afișează doar numărul de întreruperi de linie DOS și de întreruperi
|
||||
de linie Unix:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Afișează doar marcajul de ordine a octeților:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Listează fișierele care au întreruperi de linie DOS:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Listează fișierele care au întreruperi de linie Unix:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Listează fișierele care au întreruperi de linie DOS sau care nu au
|
||||
întreruperi de linie pe ultima linie:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Convertește numai fișierele care au întreruperi de linie DOS și lasă
|
||||
celelalte fișiere neatinse:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Găsește fișiere text care au întreruperi de linie DOS:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Păstrează marcajul de dată al fișierului de ieșire la fel ca al
|
||||
fișierului de intrare.
|
||||
|
||||
-L, --license
|
||||
Afișează licența programului.
|
||||
|
||||
-l, --newline
|
||||
Adaugă o linie nouă suplimentară.
|
||||
|
||||
dos2unix: Numai întreruperile de linie DOS sunt modificate în două
|
||||
întreruperi de linie Unix. În modul Mac, numai întreruperile de
|
||||
linie Mac sunt modificate în două întreruperi de linie Unix.
|
||||
|
||||
unix2dos: Numai întreruperile de linie Unix sunt modificate în două
|
||||
întreruperi de linie DOS. În modul Mac, întreruperile de linie Unix
|
||||
sunt modificate în două întreruperi de linie Mac.
|
||||
|
||||
-m, --add-bom
|
||||
Scrie un marcaj de ordine a octeților (BOM) în fișierul de ieșire.
|
||||
În mod implicit, este scris un marcaj de ordine a octeților UTF-8.
|
||||
|
||||
Când fișierul de intrare este UTF-16 și este utilizată opțiunea
|
||||
"-u", va fi scris un marcaj de ordine a octeților UTF-16.
|
||||
|
||||
Nu utilizați niciodată această opțiune când codificarea de ieșire
|
||||
este alta decât UTF-8, UTF-16 sau GB18030. Vedeți, de asemenea,
|
||||
secțiunea UNICODE.
|
||||
|
||||
-n, --newfile FIȘIER_INTRARE FIȘIER_IEȘIRE ...
|
||||
Modul de fișier nou. Convertiți fișierul FIȘIER_INTRARE și scrieți
|
||||
rezultatul în fișierul FIȘIER_IEȘIRE. Numele fișierelor trebuie să
|
||||
fie date în perechi, iar numele cu metacaractere ar trebui să *nu*
|
||||
fi folosite sau v-ați puteai pierde fișierele.
|
||||
|
||||
Persoana care începe conversia în modul-fișier_nou (pereche) va fi
|
||||
proprietarul fișierului convertit. Permisiunile de citire/scriere
|
||||
ale noului fișier vor fi permisiunile fișierului original minus
|
||||
umask(1) al persoanei care execută conversia.
|
||||
|
||||
--no-allow-chown
|
||||
Nu permite schimbarea proprietarului fișierului în
|
||||
modul-fișier_vechi (implicit).
|
||||
|
||||
Anulează conversia atunci când utilizatorul și/sau grupul proprietar
|
||||
al fișierului original nu poate fi păstrat în modul-fișier_vechi. A
|
||||
se vedea, de asemenea, opțiunile "-o" și "-n". Această opțiune este
|
||||
disponibilă doar dacă «dos2unix» are suport pentru păstrarea
|
||||
dreptului de proprietate asupra fișierelor de către utilizator și
|
||||
grup.
|
||||
|
||||
--no-add-eol
|
||||
Nu adaugă o întrerupere de linie la ultima linie, dacă nu există una
|
||||
(implicit).
|
||||
|
||||
--no-error-binary
|
||||
Nu returnează o eroare atunci când un fișier binar este omis
|
||||
(implicit).
|
||||
|
||||
-O, --to-stdout
|
||||
Scrie la ieșirea standard, ca un filtru Unix. Folosiți opțiunea "-o"
|
||||
pentru a reveni la modul-fișier_vechi (în același loc / în același
|
||||
fișier).
|
||||
|
||||
În combinație cu opțiunea "-e", fișierele pot fi concatenate în mod
|
||||
corespunzător. Nu se fuzionează ultima și prima linie și nici
|
||||
marcajele de ordine a octeților (BOM) Unicode în mijlocul fișierului
|
||||
concatenat. Exemplu:
|
||||
|
||||
dos2unix -e -O fișier1.txt fișier2.txt > fișier_ieșire.txt
|
||||
|
||||
-o, --oldfile FIȘIER ...
|
||||
Modul fișier vechi. Convertește fișierul FIȘIER și suprascrie
|
||||
rezultatul în el. Programul rulează implicit în acest mod. Pot fi
|
||||
folosite nume cu metacaractere.
|
||||
|
||||
În modul-fișier_vechi (în același loc / în același fișier), fișierul
|
||||
convertit primește același proprietar, grup și permisiuni de
|
||||
citire/scriere ca fișierul original. De asemenea, atunci când
|
||||
fișierul este convertit de un alt utilizator care are permisiuni de
|
||||
scriere în fișier (de exemplu, utilizatorul root). Conversia va fi
|
||||
anulată atunci când nu este posibil să se păstreze valorile
|
||||
originale. Schimbarea proprietarului ar putea însemna că
|
||||
proprietarul inițial nu mai poate citi fișierul. Schimbarea grupului
|
||||
ar putea reprezenta un risc de securitate, fișierul ar putea fi
|
||||
făcut vizibil pentru persoanele cărora nu este destinat. Păstrarea
|
||||
permisiunilor de proprietar, de grup și de citire/scriere este
|
||||
acceptată numai în Unix.
|
||||
|
||||
Pentru a verifica dacă «dos2unix» are suport pentru păstrarea
|
||||
proprietății utilizatorului și grupului de fișiere, tastați
|
||||
"dos2unix -V".
|
||||
|
||||
Conversia se face întotdeauna printr-un fișier temporar. Când apare
|
||||
o eroare la jumătatea conversiei, fișierul temporar este șters și
|
||||
fișierul original rămâne intact. Când conversia are succes, fișierul
|
||||
original este înlocuit cu fișierul temporar. Este posibil să aveți
|
||||
permisiunea de scriere în fișierul original, dar nu aveți
|
||||
permisiunea de a pune aceleași proprietăți de proprietate ale
|
||||
utilizatorului și/sau grupului asupra fișierului temporar ca cele pe
|
||||
care le are fișierul original. Aceasta înseamnă că nu puteți păstra
|
||||
utilizatorul și/sau grupul proprietar al fișierului original. În
|
||||
acest caz, puteți utiliza opțiunea "--allow-chown" pentru a continua
|
||||
conversia:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
O altă opțiune este să utilizați modul-fișier_nou:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Avantajul opțiunii "--allow-chown" este că puteți folosi
|
||||
metacaractere, iar proprietățile de proprietate vor fi păstrate
|
||||
atunci când este posibil.
|
||||
|
||||
-q, --quiet
|
||||
Modul silențios. Suprimă toate avertismentele și mesajele. Valoarea
|
||||
returnată este zero. Cu excepția cazului în care sunt utilizate
|
||||
opțiuni greșite în linia de comandă.
|
||||
|
||||
-r, --remove-bom
|
||||
Elimină marcajul de ordine a octeților (BOM). Nu scrie un marcaj de
|
||||
ordine a octeților în fișierul de ieșire. Acesta este comportamentul
|
||||
implicit la conversia întreruperilor de linie Unix. A se vedea, de
|
||||
asemenea, opțiunea "-b".
|
||||
|
||||
-s, --safe
|
||||
Omite fișierele binare (implicit).
|
||||
|
||||
Omiterea fișierelor binare se face pentru a evita greșelile
|
||||
accidentale. Rețineți că detectarea fișierelor binare nu este 100%
|
||||
sigură. Fișierele de intrare sunt scanate pentru simboluri binare
|
||||
care de obicei nu se găsesc în fișierele text. Este posibil ca un
|
||||
fișier binar să conțină doar caractere de text normale. Un astfel de
|
||||
fișier binar va fi văzut din greșeală ca un fișier text.
|
||||
|
||||
În mod implicit, nu se returnează nicio eroare atunci când un fișier
|
||||
binar este omis. Atunci când se utilizează opțiunea
|
||||
"--error-binary", se returnează o eroare.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Presupune că formatul fișierului de intrare este UTF-16LE.
|
||||
|
||||
Când există un marcaj de ordine a octeților în fișierul de intrare,
|
||||
marcajul de ordine a octeților are prioritate față de această
|
||||
opțiune.
|
||||
|
||||
Când ați făcut o presupunere greșită (fișierul de intrare nu era în
|
||||
format UTF-16LE) și conversia a reușit, veți obține un fișier de
|
||||
ieșire UTF-8 cu text greșit. Puteți anula conversia greșită cu
|
||||
iconv(1) prin conversia fișierului de ieșire UTF-8 înapoi în
|
||||
UTF-16LE. Acest lucru va reface fișierul original.
|
||||
|
||||
Presupunerea UTF-16LE funcționează ca un *mod de conversie*. Prin
|
||||
trecerea la modul *ascii* implicit, presupunerea UTF-16LE este
|
||||
dezactivată.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Presupune că formatul fișierului de intrare este UTF-16BE.
|
||||
|
||||
Această opțiune funcționează la fel ca și opțiunea "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Afișează mesaje detaliate. Sunt afișate informații suplimentare
|
||||
despre mărcile de ordine ale octeților și cantitatea de întreruperi
|
||||
de linie convertite.
|
||||
|
||||
-F, --follow-symlink
|
||||
Urmează legăturile simbolice și convertește țintele.
|
||||
|
||||
-R, --replace-symlink
|
||||
Înlocuiește legăturile simbolice cu fișierele convertite (fișierele
|
||||
țintă originale rămân neschimbate).
|
||||
|
||||
-S, --skip-symlink
|
||||
Păstrează legăturile simbolice și țintele neschimbate (implicit).
|
||||
|
||||
-V, --version
|
||||
Afișează informațiile despre versiune și iese.
|
||||
|
||||
MODUL MAC
|
||||
În mod implicit, salturile (întreruperile) de linie sunt convertite din
|
||||
DOS în Unix și invers. Întreruperile de linie Mac nu sunt convertite.
|
||||
|
||||
În modul Mac, întreruperile de linie sunt convertite din Mac în Unix și
|
||||
invers. Întreruperile de linie DOS nu sunt modificate.
|
||||
|
||||
Pentru a rula în modul Mac, utilizați opțiunea din linie de comandă "-c
|
||||
mac" sau utilizați comenzile "mac2unix" sau "unix2mac".
|
||||
|
||||
MODURI DE CONVERSIE
|
||||
ascii
|
||||
Acesta este modul de conversie implicit. Acest mod este destinat
|
||||
conversiei fișierelor codificate ASCII și compatibile cu ASCII, cum
|
||||
ar fi UTF-8. Activarea modului ascii dezactivează modurile 7bit și
|
||||
iso.
|
||||
|
||||
Dacă «dos2unix» are suport UTF-16, fișierele codificate UTF-16 sunt
|
||||
convertite la codificarea caracterelor locale curente pe sistemele
|
||||
POSIX și la UTF-8 pe Windows. Activarea modului ascii dezactivează
|
||||
opțiunea de păstrare a codificării UTF-16 ("-u") și opțiunile de
|
||||
asumare a intrării UTF-16 ("-ul" și "-ub"). Pentru a vedea dacă
|
||||
«dos2unix» are suport UTF-16, tastați "dos2unix -V". A se vedea și
|
||||
secțiunea UNICODE.
|
||||
|
||||
7bit
|
||||
În acest mod, toate caracterele de 8 biți non-ASCII (cu valori de la
|
||||
128 la 255) sunt convertite într-un spațiu de 7 biți.
|
||||
|
||||
iso Caracterele sunt convertite între un set de caractere DOS (pagina de
|
||||
cod) și un set de caractere ISO ISO-8859-1 (Latin-1) în Unix.
|
||||
Caracterele DOS fără echivalent ISO-8859-1, pentru care conversia nu
|
||||
este posibilă, sunt convertite într-un punct. Același lucru este
|
||||
valabil și pentru caracterele ISO-8859-1 fără omolog în DOS.
|
||||
|
||||
Când este folosită numai opțiunea "-iso", «dos2unix» va încerca să
|
||||
determine pagina de cod activă. Când acest lucru nu este posibil,
|
||||
«dos2unix» va folosi pagina de cod implicită CP437, care este
|
||||
folosită în principal în SUA. Pentru a forța o anumită pagină de
|
||||
coduri, utilizați opțiunile -437 (SUA), -850 (Europa de Vest), -860
|
||||
(Portugheză), -863 (Franceză Canadiană) sau "- 865" (Scandinavă).
|
||||
Pagina de coduri CP1252 (Europa de Vest) Windows este, de asemenea,
|
||||
acceptată cu opțiunea -1252. Pentru alte pagini de cod, utilizați
|
||||
«dos2unix» în combinație cu iconv(1). «iconv» poate converti o listă
|
||||
lungă de codificări de caractere. Puteți vizualiza această listă
|
||||
rulând comanda: «iconv -l».
|
||||
|
||||
Nu utilizați niciodată conversia ISO pe fișiere text Unicode. Acesta
|
||||
va deteriora fișierele codificate UTF-8.
|
||||
|
||||
Câteva exemple:
|
||||
|
||||
Convertește din pagina de cod implicită DOS în Latin-1 Unix:
|
||||
|
||||
dos2unix -iso -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din CP850 DOS în Latin-1 Unix:
|
||||
|
||||
dos2unix -850 -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din CP1252 Windows în Latin-1 Unix:
|
||||
|
||||
dos2unix -1252 -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din CP1252 Windows în UTF-8 (Unicode) Unix:
|
||||
|
||||
iconv -f CP1252 -t UTF-8 fișier_intrare.txt | dos2unix > fișier_ieșire.txt
|
||||
|
||||
Convertește din Latin-1 Unix la pagina de cod implicită DOS:
|
||||
|
||||
unix2dos -iso -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din Latin-1 Unix în CP850 DOS:
|
||||
|
||||
unix2dos -850 -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din Latin-1 Unix în CP1252 Windows:
|
||||
|
||||
unix2dos -1252 -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din UTF-8 (Unicode) Unix în CP1252 Windows:
|
||||
|
||||
unix2dos < fișier_intrare.txt | iconv -f UTF-8 -t CP1252 > fișier_ieșire.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Codificări
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Conversie
|
||||
Fișierele text Unicode pot avea întreruperi de linie DOS, Unix sau Mac,
|
||||
ca și fișierele text ASCII.
|
||||
|
||||
Toate versiunile de «dos2unix» și «unix2dos» pot converti fișiere
|
||||
codificate în formatul UTF-8, deoarece UTF-8 a fost conceput pentru
|
||||
compatibilitate cu ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
În Unix/Linux, fișierele codificate UTF-16 sunt convertite în
|
||||
codificarea caracterelor locale. Utilizați comanda locale(1) pentru a
|
||||
afla care este codificarea caracterelor stabilită de localizare. Atunci
|
||||
când conversia nu este posibilă, va apărea o eroare de conversie și
|
||||
fișierul va fi omis.
|
||||
|
||||
În Windows, fișierele UTF-16 sunt convertite în mod implicit în UTF-8.
|
||||
Fișierele text formatate UTF-8 sunt bine acceptate atât în Windows, cât
|
||||
și în Unix/Linux.
|
||||
|
||||
Codificările UTF-16 și UTF-8 sunt pe deplin compatibile, nu se va pierde
|
||||
text în conversie. Când apare o eroare de conversie din UTF-16 în UTF-8,
|
||||
de exemplu când fișierul de intrare UTF-16 conține o eroare, fișierul va
|
||||
fi omis.
|
||||
|
||||
Când se utilizează opțiunea "-u", fișierul de ieșire va fi scris în
|
||||
aceeași codificare UTF-16 ca și fișierul de intrare. Opțiunea "-u"
|
||||
împiedică conversia în UTF-8.
|
||||
|
||||
«dos2unix» și «unix2dos» nu au nicio opțiune de a converti fișierele
|
||||
UTF-8 în UTF-16.
|
||||
|
||||
Modurile de conversie ISO și 7 biți nu funcționează pe fișierele UTF-16.
|
||||
|
||||
Marcajul de ordine a octeților
|
||||
În Windows, fișierele text Unicode au de obicei un marcaj de ordine a
|
||||
octeților (BOM), deoarece multe programe Windows (inclusiv Notepad)
|
||||
adaugă marcajul de ordine a octeților în mod implicit. A se vedea, de
|
||||
asemenea, <https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
În Unix, fișierele Unicode nu au de obicei un marcaj de ordine a
|
||||
octeților (BOM). Se presupune că fișierele text sunt codificate în
|
||||
codificarea caracterelor stabilită de localizare.
|
||||
|
||||
«dos2unix» poate detecta dacă un fișier este în formatul UTF-16 numai
|
||||
dacă fișierul are un marcaj de ordine a octeților (BOM). Când un fișier
|
||||
UTF-16 nu are un marcaj de ordine a octeților, «dos2unix» va vedea
|
||||
fișierul ca un fișier binar.
|
||||
|
||||
Utilizați opțiunea "-ul" sau "-ub" pentru a converti un fișier UTF-16
|
||||
fără un marcaj de ordine a octeților (BOM).
|
||||
|
||||
«dos2unix» nu scrie în mod implicit niciun marcaj de ordine a octeților
|
||||
(BOM) în fișierul de ieșire. Cu opțiunea "-b" «dos2unix» scrie un marcaj
|
||||
de ordine a octeților atunci când fișierul de intrare are un marcaj de
|
||||
ordine a octeților.
|
||||
|
||||
«unix2dos» scrie implicit un marcaj de ordine a octeților în fișierul de
|
||||
ieșire când fișierul de intrare are un marcaj de ordine a octeților.
|
||||
Utilizați opțiunea "-r" pentru a elimina un marcaj de ordine a
|
||||
octeților.
|
||||
|
||||
«dos2unix» și «unix2dos» scriu întotdeauna un marcaj de ordine a
|
||||
octeților atunci când se utilizează opțiunea "-m".
|
||||
|
||||
Nume de fișiere Unicode în Windows
|
||||
«dos2unix» are suport opțional pentru citirea și scrierea numelor de
|
||||
fișiere Unicode în linia de comandă Windows. Asta înseamnă că «dos2unix»
|
||||
poate deschide fișiere care au caractere în nume care nu fac parte din
|
||||
pagina de cod ANSI implicită a sistemului. Pentru a vedea dacă
|
||||
«dos2unix» pentru Windows a fost construit cu suport pentru nume de
|
||||
fișier Unicode, tastați: "dos2unix -V".
|
||||
|
||||
Există unele probleme cu afișarea numelor de fișiere Unicode într-o
|
||||
consolă Windows. Vedeți opțiunea "-D", "--display-enc". Numele
|
||||
fișierelor pot fi afișate greșit în consolă, dar fișierele vor fi scrise
|
||||
cu numele corect.
|
||||
|
||||
Exemple Unicode
|
||||
Convertește din UTF-16 Windows (fără BOM) în UTF-8 Unix:
|
||||
|
||||
dos2unix -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din UTF-16LE Windows (fără BOM) în UTF-8 Unix:
|
||||
|
||||
dos2unix -ul -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din UTF-8 Unix în Windows UTF-8 Windows cu BOM:
|
||||
|
||||
unix2dos -m -n fișier_intrare.txt fișier_ieșire.txt
|
||||
|
||||
Convertește din UTF-8 Unix în UTF-16 Windows:
|
||||
|
||||
unix2dos < fișier_intrare.txt | iconv -f UTF-8 -t UTF-16 > fișier_ieșire.txt
|
||||
|
||||
GB18030
|
||||
GB18030 este un standard guvernamental chinez. Un subset obligatoriu al
|
||||
standardului GB18030 este obligatoriu oficial pentru toate produsele
|
||||
software vândute în China. A se vedea, de asemenea,
|
||||
<https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
Standardul GB18030 este pe deplin compatibil cu Unicode și poate fi
|
||||
considerat un format de transformare unicode. La fel ca UTF-8, GB18030
|
||||
este compatibil cu ASCII. GB18030 este, de asemenea, compatibil cu
|
||||
pagina de cod 936 Windows, cunoscută și sub numele de GBK.
|
||||
|
||||
În Unix/Linux, fișierele UTF-16 sunt convertite în GB18030 atunci când
|
||||
codificarea locală este setată la GB18030. Rețineți că acest lucru va
|
||||
funcționa numai dacă localizarea este acceptată de sistem. Utilizați
|
||||
comanda "locale -a" pentru a obține lista localizărilor acceptate.
|
||||
|
||||
În Windows, trebuie să utilizați opțiunea "-gb" pentru a converti
|
||||
fișierele UTF-16 în GB18030.
|
||||
|
||||
Fișierele codificate GB18030 pot avea un marcaj de ordine a octeților,
|
||||
precum fișierele Unicode.
|
||||
|
||||
EXEMPLE
|
||||
Citește intrarea din „stdin” (intrarea standard) și scrie ieșirea la
|
||||
„stdout” (ieșirea standard):
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Convertește și înlocuiește a.txt. Convertește și înlocuiește b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Convertește și înlocuiește a.txt în modul de conversie ascii:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Convertește și înlocuiește a.txt în modul de conversie ascii,
|
||||
convertește și înlocuiește b.txt în modul de conversie pe 7 biți:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Convertește a.txt din formatul Mac în formatul Unix:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Convertește a.txt din formatul Unix în formatul Mac:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Convertește și înlocuiește a.txt, păstrând marcajul original al datei:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Convertește a.txt și scrie în e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Convertește a.txt și scrie în e.txt, și face ca marcajul de dată al lui
|
||||
e.txt să fie la fel cu cel al lui a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Convertește și înlocuiește a.txt, converteștei b.txt și scrie în e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Convertește c.txt și scrie în e.txt, convertește și înlocuiește a.txt,
|
||||
convertește și înlocuiește b.txt, convertește d.txt și scrie în f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
CONVERSIE RECURSIVĂ
|
||||
Într-un shell Unix, comenzile find(1) și xargs(1) pot să fie folosite
|
||||
pentru a rula «dos2unix» în mod recursiv asupra tuturor fișierele text
|
||||
dintr-un arbore de directoare. De exemplu, pentru a converti toate
|
||||
fișierele .txt din arborele de directoare sub directorul curent,
|
||||
tastați:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
Opțiunea find(1) "-print0" și opțiunea corespunzătoare xargs(1) -0 sunt
|
||||
necesare atunci când există fișiere cu spații sau ghilimele în nume. În
|
||||
caz contrar, aceste opțiuni pot fi omise. O altă opțiune este să
|
||||
utilizați find(1) cu opțiunea "-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
Într-un prompt de comandă Windows se poate folosi următoarea comandă:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
Utilizatorii de PowerShell pot folosi următoarea comandă a PowerShell de
|
||||
Windows:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOCALIZAREA
|
||||
LANG
|
||||
Limba principală este selectată cu variabila de mediu LANG.
|
||||
Variabila LANG constă din mai multe părți. Prima parte este codul
|
||||
limbii cu litere mici. Al doilea este opțional și este codul țării
|
||||
cu majuscule, precedat de un caracter de subliniere. Există, de
|
||||
asemenea, o a treia parte opțională: codificarea caracterelor,
|
||||
precedată de un punct. Câteva exemple pentru shell-uri de tip
|
||||
standard POSIX:
|
||||
|
||||
export LANG=nl Olandeză
|
||||
export LANG=nl_NL Olandeză, Olanda
|
||||
export LANG=nl_BE Olandeză, Belgia
|
||||
export LANG=es_ES Spaniolă, Spania
|
||||
export LANG=es_MX Spaniolă, Mexic
|
||||
export LANG=en_US.iso88591 Engleză, SUA, codificarea Latin-1
|
||||
export LANG=en_GB.UTF-8 Engleză, UK, codificarea UTF-8
|
||||
|
||||
Pentru o listă completă a codurilor de limbă și de țară, consultați
|
||||
manualul «gettext»:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
În sistemele Unix, puteți utiliza comanda locale(1) pentru a obține
|
||||
informații specifice despre localizare.
|
||||
|
||||
LANGUAGE
|
||||
Cu variabila de mediu LANGUAGE puteți specifica o listă cu
|
||||
prioritate de limbi, separate prin două puncte. «dos2unix» dă
|
||||
preferință variabilei LANGUAGE în detrimentul variabilei LANG. De
|
||||
exemplu, mai întâi olandeză și apoi germană: "LANGUAGE=nl:de". Mai
|
||||
întâi trebuie să activați localizarea, definind LANG (sau LC_ALL) la
|
||||
o altă valoare decât „C”, înainte de a putea utiliza o listă cu
|
||||
prioritate de limbă prin variabila LANGUAGE. Consultați și manualul
|
||||
«gettext»:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Dacă selectați o limbă care nu este disponibilă, veți primi mesajele
|
||||
standard în limba engleză.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Cu variabila de mediu DOS2UNIX_LOCALEDIR, variabila LOCALEDIR
|
||||
definită în timpul compilării poate fi înlocuită. LOCALEDIR este
|
||||
folosită pentru a găsi fișierele de limbă. Valoarea implicită GNU
|
||||
este "/usr/local/share/locale". Opțiunea --version va afișa valoarea
|
||||
pe care LOCALEDIR o utilizează.
|
||||
|
||||
Exemplu (shell POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
VALOAREA RETURNATĂ
|
||||
La succes, se returnează zero. Când apare o eroare de sistem, va fi
|
||||
returnată ultima eroare de sistem. Pentru alte erori se returnează 1.
|
||||
|
||||
Valoarea returnată este întotdeauna zero în modul silențios, cu excepția
|
||||
cazului în care sunt utilizate opțiuni greșite ale liniei de comandă.
|
||||
|
||||
STANDARDE
|
||||
<https://ro.wikipedia.org/wiki/Fi%C8%99ier_text>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://ro.wikipedia.org/wiki/Unicode>
|
||||
|
||||
AUTORI
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (modul
|
||||
mac2unix) - <wuebben@kde.org>, Christian Wurll (adăugarea unei linii noi
|
||||
suplimentare) - <wurll@ira.uka.de>, Erwin Waterlander -
|
||||
<waterlan@xs4all.nl> (menținător)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Pagina din SourceForge a proiectului:
|
||||
<https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
CONSULTAȚI ȘI
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/sr/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/sr/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - претварач формата текстуалних датотека из ДОС/Мек-а у Јуникс и обратно</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#pod">НАЗИВ</a></li>
|
||||
<li><a href="#pod1">УВОД</a></li>
|
||||
<li><a href="#pod2">ОПИС</a></li>
|
||||
<li><a href="#pod3">ОПЦИЈЕ</a></li>
|
||||
<li><a href="#pod5">МЕК РЕЖИМ</a></li>
|
||||
<li><a href="#pod6">РЕЖИМИ ПРЕТВАРАЊА</a></li>
|
||||
<li><a href="#pod7">УНИКОД</a>
|
||||
<ul>
|
||||
<li><a href="#pod8">Кодирања</a></li>
|
||||
<li><a href="#pod9">Претварање</a></li>
|
||||
<li><a href="#pod10">Ознака редоследа бајтова</a></li>
|
||||
<li><a href="#pod11">Јуникод називи датотека на Виндоузу</a></li>
|
||||
<li><a href="#pod12">Примери Уникода</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#pod13">ПРИМЕРИ</a></li>
|
||||
<li><a href="#pod14">ДУБИНСКО ПРЕТВАРАЊЕ</a></li>
|
||||
<li><a href="#pod15">ЈЕЗИЧЕЊЕ</a></li>
|
||||
<li><a href="#pod18">РЕЗУЛТНА ВРЕДНОСТ</a></li>
|
||||
<li><a href="#pod19">СТАНДАРДИ</a></li>
|
||||
<li><a href="#pod20">АУТОРИ</a></li>
|
||||
<li><a href="#pod21">ВИДИТЕ ТАКОЂЕ</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="pod">НАЗИВ</h1>
|
||||
|
||||
<p>dos2unix – претварач формата текстуалних датотека из ДОС/Мек-а у Јуникс и обратно</p>
|
||||
|
||||
<h1 id="pod1">УВОД</h1>
|
||||
|
||||
<pre><code>dos2unix [опције] [ДАТОТЕКА ...] [-n УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...]
|
||||
unix2dos [опције] [ДАТОТЕКА ...] [-n УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...]</code></pre>
|
||||
|
||||
<h1 id="pod2">ОПИС</h1>
|
||||
|
||||
<p>“dos2unix“ пакет укључује помагала „<code>dos2unix</code>“ и „<code>unix2dos</code>“ за претварање обичне текстуалне датотеке у ДОС или Мек формат у Јуникс формат и обратно.</p>
|
||||
|
||||
<p>У ДОС/Виндоуз текстуалним датотекама преламање реда, такође познато и као нови ред, је комбинација два знака: „Carriage Return“ (CR) за којим следи „Line Feed“ (LF). У Јуникс текстуалним датотекама преламање реда је један знак: „Line Feed“ (LF). У Мек текстуалним датотекама, пре Мек ОС Икс-а, преламање реда беше један знак „Carriage Return“ (CR). Данас Мек ОС користи преламање реда у Јуникс стилу (LF).</p>
|
||||
|
||||
<p>Поред преламања реда „dos2unix“ такође може претворити кодирање датотека. Неколико ДОС кодних страница се може претворити у Јуникс Latin-1. А Виндоуз Јуникод (UTF-16) датотеке се могу претворити у Јуникс Јуникод (UTF-8) датотеке.</p>
|
||||
|
||||
<p>Бинарне датотеке се аутоматски прескачу, осим ако претварање није приморано.</p>
|
||||
|
||||
<p>Нередовне датотеке, као што су директоријуму и ПУПИ, се аутоматски прескачу.</p>
|
||||
|
||||
<p>Симболичке везе и њихови циљеви се подразумевано не дирају. Симболичке везе се по жељи могу заменити, или се излаз може записати на мету симболичке везе. Писање на мету симболичке везе није подржано на Виндоузу.</p>
|
||||
|
||||
<p>„dos2unix“ је направљен по узору на „dos2unix“ под СанОС/Соларисом. Постоји једна важна разлика са изворним СанОС/Соларис издањем. Ово издање подразумевано врши претварање у месту (стари режим датотеке), док изворно СанОС/Соларис издање подржава само упарено претварање (нови режим датотеке). Такође погледајте опције „<code>-o</code>“ и „<code>-n</code>“. Друга разлика је у томе што издање СанОС/Солариса подразумевано користи режим „<i>iso</i>“ претварања док ово издање подразумевано користи режим „<i>ascii</i>“ претварања.</p>
|
||||
|
||||
<h1 id="pod3">ОПЦИЈЕ</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod4"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Сматра све следеће опције као називе датотека. Користите ову опцију ако желите да претворите датотеке чији називи почињу цртицом. На пример да претворите датотеку под називом „-foo“, можете користити ову наредбу:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Или у режим нове датотеке:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo излаз.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Сва власништва датотеке се мењају у режим старе датотеке.</p>
|
||||
|
||||
<p>Када се користи ова опција, претварање се неће прекинути када се власништво корисника и/или групе изворне датотеке не може сачувати у старом режиму датотеке. Претварање ће се наставити и претворена датотека ће добити исто ново власништво као да је претворена у режиму нове датотеке. Такође погледајте опције „<code>-o</code>“ и „<code>-n</code>“. Ова опција је доступна само ако „dos2unix“ има подршку за очување власништва корисника и групе над датотекама.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Основни режим претварања. Видите такође одељак РЕЖИМИ ПРЕТВАРАЊА.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Претварање између ДОС и ИСО-8859-1 скупа знакова. Видите такође одељак РЕЖИМИ ПРЕТВАРАЊА.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи Виндоуз кодну страницу 1252 (западноевропски).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи ДОС кодну страницу 437 (Сједињене Државе). Ово је основна кодна страница коришћена за ИСО претварање.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи ДОС кодну страницу 850 (западноевропски).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи ДОС кодну страницу 860 (португалски).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи ДОС кодну страницу 863 (француски канадски).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Користи ДОС кодну страницу 865 (нордијски).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Претвара 8 битне знакове у 7 битне размаке.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Задржава Ознаку редоследа бајта (BOM). Када улазна датотека има ОРБ, пише ОРБ у излазну датотеку. Ово је основно понашање приликом претварања у ДОС преламање реда. Видите такође опцију „<code>-r</code>“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-_"><b>-c, --convmode РЕЖИМ_ПРЕТВАРАЊА</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Поставља режим претварања. Где је РЕЖИМ_ПРЕТВАРАЊА један од: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> где је „ascii“ основни.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc"><b>-D, --display-enc КОДИРАЊЕ</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Поставља кодирање приказаног текста. Где је КОДИРАЊЕ једно од: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i> где је „ansi“ основно.</p>
|
||||
|
||||
<p>Ова опција је доступна само у „dos2unix“ за Виндоуз са подршком за Јуникод назив датотеке. Ова опција нема утицаја на стварно читање и писање назива датотека, већ само на начин на који се приказују.</p>
|
||||
|
||||
<p>Постоји неколико метода за приказивање текста у Виндоуз конзоли на основу кодирања текста. Сви они имају своје предности и недостатке.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Подразумевани метод „dos2unix“-а је да се користи АНСИ кодиран текст. Предност је у томе што је повратно сагласан. Ради са растерским и „TrueType“ словима. У неким регионима ћете можда морати да промените активну ДОС ОЕМ кодну страницу у АНСИ кодну страницу Виндоуз система помоћу наредбе „<code>chcp</code>“, јер „dos2unix“ користи кодну страницу Виндоуз система.</p>
|
||||
|
||||
<p>Недостатак анси-ја је што се међународни називи датотека са знаковима који нису унутар системски подразумеване кодне странице не приказују правилно. Уместо тога видећете знак питања, или погрешан симбол. Када не радите са страним називима датотека, овај метод је у реду.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Предност јуникод кодирања (Виндоуз назив за УТФ-16) је у томе што се текст обично правилно приказује. Нема потребе за променом активне кодне странице. Можда ћете морати да поставите слова конзоле на „TrueType“ да би се међународни знаци правилно приказивали. Када знак није укључен у „TrueType“ слова обично видите мали квадрат, понекад са знаком питања у њему.</p>
|
||||
|
||||
<p>Када користите „ConEmu“ конзолу сав текст се исправно приказује, јер „ConEmu“ аутоматски бира добра слова.</p>
|
||||
|
||||
<p>Недостатак јуникод-а је што није сагласан са АСКРИ-јем. Излазом није лако руковати када га преусмерите на други програм.</p>
|
||||
|
||||
<p>Када се користи „<code>unicodebom</code>“ метод Јуникод тексту ће претходити ОРБ (Ознака редоследа вбајтоа). ОРБ је потребан за правилно преусмеравање или преспајање у „PowerShell“-у.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Предност утф8 је у томе што је сагласан са АСКРИ-јем. Слова конзоле треба да поставити на „TrueType“ слова. Са „TrueType“ словима текст се приказује слично као и са „<code>unicode</code>“ кодирањем.</p>
|
||||
|
||||
<p>Недостатак је што се приликом коришћења подразумеваних растерских слова сви не-АСКРИ знакови се погрешно приказују. Не само да Јуникод називи датотека, већ и преведене поруке постају нечитљиве. У Виндоузу подешеном за регију Источне Азије, можда ћете видети пуно треперења конзоле приликом приказивања порука.</p>
|
||||
|
||||
<p>У „ConEmu“ конзоли утф8 метода кодирања ради лепо.</p>
|
||||
|
||||
<p>Када се користи „<code>utf8bom</code>“ метод УТФ-8 тексту ће претходити ОРБ (Ознака редоследа вбајтоа). ОРБ је потребна за правилно преусмеравање или преспајање у „PowerShell“-у.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Подразумевано кодирање можете изменити променљивом окружења „DOS2UNIX_DISPLAY_ENC“ тако што ћете је поставити на „<code>unicode</code>“, „<code>unicodebom</code>“, „<code>utf8</code>“, или „<code>utf8bom</code>“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Додаје прекид реда у последњи ред ако га нема. Ово ради за сва претварања.</p>
|
||||
|
||||
<p>Датотеци претвореној из ДОС у Јуникс формат може да недостаје прекид реда у последњем реду. Постоје уређивачи текста који пишу текстуалне датотеке без прекида реда у последњем реду. Неки Јуникс програми имају проблема са обрадом тих датотека, јер POSIX стандард одређује да сваки ред у текстуалној датотеци мора да се завршава крајњим знаком новог реда. Јер надовезане датотеке неће давати очекивани резултат.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Враћа грешку ако је бинарна датотека прескочена.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Присиљава претварање бинарних датотека.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>У Виндоузу УТФ-16 датотеке се подразумевано претварају у УТФ-8, без обзира на поставке језика. Користите ову опцију за претварање УТФ-16 датотека у „GB18030“. Ова опција је доступна само у Виндоузу. Такође погледајте одељак „GB18030“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује помоћ и излази.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i---info"><b>-i[ЗАСТАВИЦЕ], --info[=ЗАСТАВИЦЕ] ДАТОТЕКА ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује податке о датотеци. Претварање се не ради.</p>
|
||||
|
||||
<p>Следеће информације се исписују, овим редом: број ДОС прелома реда, број Јуникс прелома реда, број Мек прелома реда, ознака редоследа бајтова, текст или бинарна, назив датотеке.</p>
|
||||
|
||||
<p>Пример излаза:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom текст dos.txt
|
||||
0 6 0 no_bom текст unix.txt
|
||||
0 0 6 no_bom текст mac.txt
|
||||
6 6 6 no_bom текст mixed.txt
|
||||
50 0 0 UTF-16LE текст utf16le.txt
|
||||
0 50 0 no_bom текст utf8unix.txt
|
||||
50 0 0 UTF-8 текст utf8dos.txt
|
||||
2 418 219 no_bom бинарна dos2unix.exe</code></pre>
|
||||
|
||||
<p>Знајте да понекад бинарна датотека може грешком бити узета за текстуалну датотеку. Видите такође опцију „<code>-s</code>“.</p>
|
||||
|
||||
<p>Ако се у додатној опцији користи <code>-e</code> или <code>--add-eol</code> такође се исписује и врста прекида реда последњег реда, или <code>noeol</code> ако нема ничега.</p>
|
||||
|
||||
<p>Пример излаза:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom текст dos dos.txt
|
||||
0 6 0 no_bom текст unix unix.txt
|
||||
0 0 6 no_bom текст mac mac.txt
|
||||
1 0 0 no_bom текст noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Изборне додатне заставице се могу поставити да измене излаз. Могу се додати једна или више заставица.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује редове информација о датотеци за којима следи нулти знак уместо знака новог реда. Ово омогућава тачно тумачење назива датотека с размацима или наводницима када се користи заставица „c“. Користите ову заставицу у комбинацији са „xargs(1)“ опцијом „<code>-0</code>“ или „<code>--null</code>“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује број ДОС преламања реда.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује број Јуникс преламања реда.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује број Мек преламања реда.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује ознаку редоследа бајтова.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује да ли је датотека текстуална или бинарна.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује врсту прекида реда последњег реда, или <code>noeol</code> ако га нема.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује само датотеке које ће бити претворене.</p>
|
||||
|
||||
<p>Са заставицом „<code>c</code>“ „dos2unix“ ће исписати само датотеке које садрже ДОС преламања реда, „unix2dos“ ће исписат само називе датотека које имају Јуникс преламања реда.</p>
|
||||
|
||||
<p>Ако се у додатној опцији користи <code>-e</code> или <code>--add-eol</code> такође се исписују и датотеке којима недостаје прекид реда у последњем реду.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Исписује заглавље.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује називе датотека без путање.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Примери:</p>
|
||||
|
||||
<p>Приказује податке за све „*.txt“ датотеке:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Приказује само број ДОС преламања реда и број Јуникс преламања реда:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Приказује само ознаку редоследа бајтова:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Исписује датотеке које имају ДОС преламање реда:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Исписује датотеке које имају Јуникс преламање реда:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Исписује датотеке које имају ДОС преламања реда или им недостаје прекид реда у последњем реду:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Претвара само датотеке које имају ДОС преламање реда и оставља друге датотеке нетакнутим:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Налази текстуалне датотеке које имају ДОС преламање реда:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Задржава печат датума излазне датотеке истим као код улазне.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује лиценцу програма.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Додаје додатни нови ред.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Само ДОС преламања реда се мењају у два Јуникс преламања реда. У Мек режиму само Мек преламања реда се мењају у два Јуникс преламања реда.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Само Јуникс преламања реда се мењају у два ДОС преламања реда. У Мек режиму Јуникс преламања реда се мењају у два Мек преламања реда.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Пише Ознаку редоследа бајтова (BOM) у излазну датотеку. Подразумевано се записује УТФ-8 ОРБ.</p>
|
||||
|
||||
<p>Када је улазна датотека УТФ-16, и користи се опција „<code>-u</code>“, биће записана УТФ-16 ОРБ.</p>
|
||||
|
||||
<p>Никада не користите ову опцију када је излазно кодирање другачије од „UTF-8“, „UTF-16“, или „GB18030“. Видите такође одељак ЈУНИКОД.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-_-_"><b>-n, --newfile УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Нови режим датотеке. Претвара датотеку УЛ_ДАТОТЕКА и пише излаз у датотеку ИЗЛ_ДАТОТЕКА. Називи датотека морају бити дати у паровима и називи џокера се „<i>не</i>“ могу користити или „<i>ћете</i>“ изгубити своје датотеке.</p>
|
||||
|
||||
<p>Особа која започне претварање у режиму нове (упарене) датотеке биће власник претворене датотеке. Овлашћења за читање/писање нове датотеке биће овлашћење изворне датотеке мање „umask(1)“ особе која покреће претварање.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не дозвољава да се власништва датотеке промене у режиму старе датотеке.</p>
|
||||
|
||||
<p>Прекида претварање када власништво корисника и/или групе изворне датотеке не може бити очувано у старом режиму датотеке. Такође видите опције „<code>-o</code>“ и „<code>-n</code>“. Ова опција је доступна само ако „dos2unix“ има подршку за очување власништва корисника и група над датотекама.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не додаје прекид реда у последњи ред ако га нема (основно).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не враћа грешку ако је бинарна датотека прескочена (основно).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Пише на стандардни излаз, као Јуникс филтер. Користите опцију „-o“ да се вратите на режим старе датотеке (одмах).</p>
|
||||
|
||||
<p>Заједно са опцијом „-e“ датотеке се могу исправно надовезати. Нема стопљеног првог и последњег реда, и нема ознаке поретка Јуникод бајта по средини надовезане датотеке. Пример:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O дттка1.txt дттка2.txt > излаз.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile"><b>-o, --oldfile ДАТОТЕКА ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Режим старе датотеке. Претвара датотеку ДАТОТЕКА и преписује излаз у њу. Програм подразумевано ради у овом режиму. Џокери назива се могу користити.</p>
|
||||
|
||||
<p>У режиму старе датотеке (у месту) претворена датотека добија иста овлашћења власника, групе и читања/писања као и изворна датотека. Такође када датотеку претвори други корисник који има овлашћење писања над датотеком (нпр. корисник администратор). Претварање ће се прекинути када не буде било могуће очувати изворне вредности. Промена власника може значити да првобитни власник више не може да чита датотеку. Промена групе може представљати безбедносни ризик, датотека може постати читљива од стране особа којима није намењена. Очување овлашћења власника, групе и читања/писања подржано је само на Јуниксу.</p>
|
||||
|
||||
<p>Да проверите да ли „dos2unix“ има подршку очувања власништва корисника и групе над датотеком упишите „<code>dos2unix -V</code>“.</p>
|
||||
|
||||
<p>Претварање се увек врши путем привремене датотеке. Када се на пола претварања догоди грешка, привремена датотека се брише а изворна датотека остаје нетакнута. Када претварање успе, изворна датотека се замењује привременом датотеком. Можете имати дозволу за писање над изворном датотеком, али немате дозволу да ставите иста својстава овлашћења корисника и/или груп у привремену датотеку као што има и изворна датотека. То значи да нисте у могућности да сачувате власништво корисника и/или групе над изворном датотеком. У овом случају можете користити опцију „<code>--allow-chown</code>“ да наставите са претварањем:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Друга могућност је да користи режим нове датотеке:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Предност опције „<code>--allow-chown</code>“ је да можете користити џокере, а својства власништва биће очувана када је могуће.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Тихи режим. Потискује сва упозорења и поруке. Резултантна вредност је нула. Осим када се користе погрешне опције линије наредби.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Уклања Ознаку редоследа бајтова (BOM). Не пише ОРБ у излазну датотеку. Ово је основно понашање приликом претварања у Јуникс преламање реда. Видите такође опцију „<code>-b</code>“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Прескаче извршне датотеке (основно).</p>
|
||||
|
||||
<p>Прескакање бинарних датотека врши се како би се избегле случајне грешке. Имајте на уму да откривање бинарних датотека није 100% поуздано. У улазним датотекама се траже бинарни симболи који се обично не налазе у текстуалним датотекама. Могуће је да бинарна датотека садржи само обичне текстуалне знакове. Таква бинарна датотека ће се погрешно сматрати текстуалном датотеком.</p>
|
||||
|
||||
<p>По основи, никаква грешка се не враћа када је бинарна датотека прескочена. Када се користи опција <code>--error-binary</code>, враћа се грешка.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Подразумева да је формат улазне датотеке „UTF-16LE“.</p>
|
||||
|
||||
<p>Када постоји Ознака редоследа бајтова у улазној датотеци ОРБ има предност над овом опцијом.</p>
|
||||
|
||||
<p>Када сте погрешно претпоставили (улазна датотека није била у УТФ-16ЛЕ формату) а претварање је успело, добићете УТФ-8 излазну датотеку са погрешним текстом. Погрешно претварање можете да опозовете помоћу „iconv(1)“ претварањем УТФ-8 излазне датотеке назад у УТФ-16ЛЕ. Ово ће вратити изворну датотеку.</p>
|
||||
|
||||
<p>Претпоставка УТФ-16ЛЕ ради као „<i>conversion mode</i>“. Пребацивањем на основни „<i>ascii</i>“ режим УТФ-16ЛЕ претпоставка се искључује.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Подразумева да је формат улазне датотеке „UTF-16BE“.</p>
|
||||
|
||||
<p>Ова опција ради исто као и опција „<code>-ul</code>“.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује опширне поруке. Додатне информације се приказују о Ознаци редоследа бајтова и количини претворених преламања реда.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Прати симболичке везе и претвара циљеве.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Замењује симболичке везе претвореним датотекама (изворне циљне датотеке остају непромењене).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Задржава неизмењеним симболичке везе и циљеве (основно).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Приказује податке о издању и излази.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod5">МЕК РЕЖИМ</h1>
|
||||
|
||||
<p>По основи преламања реда се претварају из DOS-а у Unix и обратно. Mac-ова преламања реда се не претварају.</p>
|
||||
|
||||
<p>У Мек режиму преламања реда се претварју из Мек-а у Јуникс и обратно. ДОС преламања реда се не мењају.</p>
|
||||
|
||||
<p>Да покренете у Мек режиму користите опцију „<code>-c mac</code>“ или користите наредбе „<code>mac2unix</code>“ или „<code>unix2mac</code>“.</p>
|
||||
|
||||
<h1 id="pod6">РЕЖИМИ ПРЕТВАРАЊА</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ово је основни режим претварања. Овај режим је за претварање ASCII и ASCII-сагласних кодираних датотека, као UTF-8. Укључивање <b>ascii</b> режима искључује <b>7bit</b> и <b>iso</b>.</p>
|
||||
|
||||
<p>Ако dos2unix има UTF-16 подршку, UTF-16 кодиране датотеке се претварају у кодирање знакова текућег језика на POSIX системима и у UTF-8 на Виндоузу. Укључивањем <b>ascii</b> режима искључује се опција за задржавање UTF-16 кодирања (<code>-u</code>) и опције за прихват UTF-16 улаза (<code>-ul</code> и <code>-ub</code>). Да видите да ли dos2unix има UTF-16 подршку укуцајте <code>dos2unix -V</code>. Видите такође одељак UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>У овом режиму сви 8 битни не-АСКРИ знаци (са вредностима од 128 до 255) се претварају у 7 битне размаке.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Знакови се претварају између ДОС скупа знакова (кодна страница) и ИСО скупа знакова ИСО-8859-1 (Latin-1) на Јуниксу. ДОС знакови без ИСО-8859-1 еквивалента, за које претварање није могуће, претварају се у тачку. Исто се рачуна и за ИСО-8859-1 знакове без ДОС-а.</p>
|
||||
|
||||
<p>Када се користи само опција „<code>-iso</code>“, „dos2unix“ ће покушати да одреди активну кодну страницу. Када то није могуће, „dos2unix“ ће користити подразумевану кодну страницу ЦП437, која се углавном користи у САД-у. Да бисте приморали одређену кодну страницу, користите опције „<code>-437</code>“ (САД), „<code>-850</code>“ (западноевропски), „<code>-860</code>“ (португалски), „<code>-863</code>“ (француски канадски) или „<code>-865</code>“ (нордијски). Виндоуз кодна страница ЦП1252 (западноевропски) је такође подржана опцијом „<code>-1252</code>“. За остале кодне странице користите „dos2unix“ у комбинацији са „iconv(1)“. Иконв може да претвара између дугог списка кодирања знакова.</p>
|
||||
|
||||
<p>Никада не користите ИСО претварање над Јуникод текстуалним датотекама. Оштетиће УТФ-8 кодиране датотеке.</p>
|
||||
|
||||
<p>Неки примери:</p>
|
||||
|
||||
<p>Претворите из ДОС основне кодне странице у Јуникс Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из ДОС CP850 у Јуникс Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Виндоуз CP1252 у Јуникс Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Виндоуз CP1252 у Јуникс УТФ-8 (Јуникод):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 улаз.txt | dos2unix > излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс Latin-1 у ДОС основну кодну страницу:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс Latin-1 у ДОС CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс Latin-1 у Вондоуз CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс УТФ-8 (Јуникод) у Вондоуз CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < улаз.txt | iconv -f UTF-8 -t CP1252 > излаз.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod7">УНИКОД</h1>
|
||||
|
||||
<h2 id="pod8">Кодирања</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="pod9">Претварање</h2>
|
||||
|
||||
<p>Јуникод текстуалне датотеке могу имати DOS, Unix или Mac преломе реда, као ASCII текстуалне датотеке.</p>
|
||||
|
||||
<p>Сва издања „dos2unix“-а и „unix2do“-а могу претворити УТФ-8 кодиране датотеке, јер је УТФ-8 дизајниран за повратну сагласност са АСКРИ-ијем.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>На Јуниксу/Линуксу УТФ-16 кодиране датотеке се претварају у локално кодирање знакова. Користите наредбу „locale(1)“ да сазнате које је кодирање знакова локализације. Када претварање није могуће, десиће се грешка претварања а датотека ће бити прескочена.</p>
|
||||
|
||||
<p>На Виндоузу УТФ-16 датотеке се подразумевано претварају у УТФ-8. УТФ-8 форматиране текстуалне датотеке су добро подржане и на Виндоузу и на Јуникс/Линуксу.</p>
|
||||
|
||||
<p>УТФ-16 и УТФ-8 кодирања су у потпуности сагласна, у претварању се неће изгубити никакав текст. Када се догоди грешка претварања УТФ-16 у УТФ-8, на пример када улазна УТФ-16 датотека садржи грешку, датотека ће бити прескочена.</p>
|
||||
|
||||
<p>Када се користи опција „<code>-u</code>“, излазна датотека ће бити записана у истом УТФ-16 кодирању као и улазна датотека. Опција „<code>-u</code>“ спречава претварање у УТФ-8.</p>
|
||||
|
||||
<p>„dos2unix“ и „unix2dos“ немају могућности да претворе УТФ-8 датотеке у УТФ-16.</p>
|
||||
|
||||
<p>ИСО и 7-битни режим претварања не ради на УТФ-16 датотекама.</p>
|
||||
|
||||
<h2 id="pod10">Ознака редоследа бајтова</h2>
|
||||
|
||||
<p>На Виндоузу Јуникод текстуалне датотеке обично имају Ознаку редоследа бајтова (BOM), јер многи Виндоуз програми (укључујући Бележницу) подразумевано додају ОРБ. Видите такође <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>На Јуниксу Јуникод датотеке обично немају ОРБ. Претпоставља се да су текстуалне датотеке кодиране у језичком кодирању знака.</p>
|
||||
|
||||
<p>„dos2unix“ може открити само да ли је датотека у УТФ-16 формату и да ли датотека има ОРБ. Када УТФ-16 датотека нема ОРБ, „dos2unix“ ће видети датотеку као бинарну.</p>
|
||||
|
||||
<p>Користите опцију „<code>-ul</code>“ или „<code>-ub</code>“ да претворите УТФ-16 датотеку без ОРБ-а.</p>
|
||||
|
||||
<p>„dos2unix“ подразумевано не записује ОРБ у излазну датотеку. Са опцијом „<code>-b</code>“ „dos2unix записује ОРБ када улазна датотека има ОРБ.</p>
|
||||
|
||||
<p>„unix2dos“ подразумевано записује ОРБ у излазну датотеку када улазна датотека има ОРБ. Користите опцију „<code>-r</code>“ да уклоните ОРБ.</p>
|
||||
|
||||
<p>„dos2unix“ и „unix2dos“ увек записује ОРБ када се користи „<code>-m</code>“ опција.</p>
|
||||
|
||||
<h2 id="pod11">Јуникод називи датотека на Виндоузу</h2>
|
||||
|
||||
<p>„dos2unix“ има изборну подршку за читање и писање Јуникод назива датотека у Виндоуз командној линији. То значи да „dos2unix“ може отворити датотеке које у називу имају знакове који нису део подразумеване системске АНСИ кодне странице. Да бисте видели да ли је „dos2unix“ за Виндоуз изграђен са подршком Јуникод назива датотеке упишите „<code>dos2unix -V</code>“.</p>
|
||||
|
||||
<p>Постоје проблеми са приказом Јуникод назива датотека у Виндоуз конзоли. Видите опцију „<code>-D</code>“, „<code>--display-enc</code>“. Називи датотека могу бити погрешно приказани у конзоли, али ће датотеке бити записане под тачним називом.</p>
|
||||
|
||||
<h2 id="pod12">Примери Уникода</h2>
|
||||
|
||||
<p>Претвара из Виндоуз УТФ-16 (са ОРБ-ом) у Јуникс УТФ-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претвара из Виндоуз УТФ-16ЛЕ (без ОРБ-а) у Јуникс УТФ-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс УТФ-8 у Вондоуз УТФ-8 са ОРБ-ом:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n улаз.txt излаз.txt</code></pre>
|
||||
|
||||
<p>Претворите из Јуникс УТФ-8 у Вондоуз УТФ-16:</p>
|
||||
|
||||
<pre><code>unix2dos < улаз.txt | iconv -f UTF-8 -t UTF-16 > излаз.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 је стандард кинеске владе. Обавезни подскуп GB18030 стандарда се званично захтева за све софтверске производе продате у Кини. Видите такође <a href="http://en.wikipedia.org/wiki/GB_18030">http://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>„GB18030“ је у потпуности сагласан са Јуникод-ом, и може се сматрати Јуникод форматом преображаја. Као УТФ-8, „GB18030“ је сагласан са АСКРИ. „GB18030“ је такође сагласан са Виндоуз кодном страницом 936, познатом и као ГБК.</p>
|
||||
|
||||
<p>На Јуниксу/Линуксу УТФ-16 датотеке се претварају у „GB18030“ када је језичко кодирање постављено на „GB18030“. Знајте да ће ово радити само ако је језик подржан системом. Користите наредбу „<code>locale -a</code>“ да добавите списак подржаних језика.</p>
|
||||
|
||||
<p>На Виндоузу треба да користите опцију „<code>-gb</code>“ да преведете УТФ-16 датотеке у „GB18030“.</p>
|
||||
|
||||
<p>„GB18030“ кодиране датотеке могу имати Ознаку редоследа бајтова, као Јуникод датотеке.</p>
|
||||
|
||||
<h1 id="pod13">ПРИМЕРИ</h1>
|
||||
|
||||
<p>Чита улаз са „стнд_улаза“ и пише излаз на „стнд_излаз“:</p>
|
||||
|
||||
<pre><code>dos2unix < а.txt
|
||||
cat а.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Претвара и замењује „а.txt“. Претвара и замењује „б.txt“:</p>
|
||||
|
||||
<pre><code>dos2unix а.txt б.txt
|
||||
dos2unix -o а.txt б.txt</code></pre>
|
||||
|
||||
<p>Претвара и замењује „а.txt“ у аскри режиму претварања:</p>
|
||||
|
||||
<pre><code>dos2unix а.txt</code></pre>
|
||||
|
||||
<p>Претвара и замењује „а.txt“ у аскри режиму претварања, Претвара и замењује „б.txt“ у 7битном режиму претварања:</p>
|
||||
|
||||
<pre><code>dos2unix а.txt -c 7bit б.txt
|
||||
dos2unix -c ascii а.txt -c 7bit б.txt
|
||||
dos2unix -ascii а.txt -7 б.txt</code></pre>
|
||||
|
||||
<p>Претвара „а.txt“ из Мек у Јуникс формат:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac а.txt
|
||||
mac2unix а.txt</code></pre>
|
||||
|
||||
<p>Претвара „а.txt“ из Јуникс у Мек формат:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac а.txt
|
||||
unix2mac а.txt</code></pre>
|
||||
|
||||
<p>Претвара и замењује „а.txt“ док задржава изворни печат датума:</p>
|
||||
|
||||
<pre><code>dos2unix -k а.txt
|
||||
dos2unix -k -o а.txt</code></pre>
|
||||
|
||||
<p>Претвара „а.txt“ и пише на „е.txt“:</p>
|
||||
|
||||
<pre><code>dos2unix -n а.txt е.txt</code></pre>
|
||||
|
||||
<p>Претвара „а.txt“ и пише на „е.txt“, задржава печат датума „е.txt“-а истим као „а.txt“:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n а.txt е.txt</code></pre>
|
||||
|
||||
<p>Претвара и замењује „а.txt“, претвара „б.txt“ и пише на „.txt“:</p>
|
||||
|
||||
<pre><code>dos2unix а.txt -n б.txt е.txt
|
||||
dos2unix -o а.txt -n б.txt е.txt</code></pre>
|
||||
|
||||
<p>Претвара „ц.txt“ и пише на „е.txt“, претвара и замењује„а.txt“, претвара и замењује „б.txt“, претвара „д.txt“ и пише у „ф.txt“:</p>
|
||||
|
||||
<pre><code>dos2unix -n ц.txt е.txt -o а.txt б.txt -n д.txt ф.txt</code></pre>
|
||||
|
||||
<h1 id="pod14">ДУБИНСКО ПРЕТВАРАЊЕ</h1>
|
||||
|
||||
<p>У Јуникс шкољци наредбе „find(1)“ и „xargs(1)“ се могу користити за покретање „dos2unix“-а дубински преко свих текстуалних датотека у стаблу директоријума. На пример за претварање свих „.txt“ датотека у стаблу директоријума под текућим директоријумом упишите:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>„find(1)“-ова опција „<code>-print0</code>“ и одговарајућа „xargs(1)“-ова опција „<code>-0</code>“ су потребне када постоје датотеке са размацима и наводницима у називима. У супротном се ове опције могу изоставити. Друга могућност је да користите „find(1)“ са „<code>-exec</code>“ опцијом:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>У Виндоуз командном упиту следеће наредбе се могу користити:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>Корисници „PowerShell“-а могу користити следеће наредбе у Виндоуз „PowerShell“-у:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="pod15">ЈЕЗИЧЕЊЕ</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod16"><b>ЈЕЗ</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Примарни језик се бира променљивом окружења „LANG“. Променљива „LANG“ се састоји из неколико делова. Први део је малим словима језички код. Други је необавезан и представља код државе великим словима, којем претходи доња црта. Ту је и изборни трећи део: кодирање знакова, којем претходи тачка. Неколико примера за врсте шкољки ПОСИКС стандарда:</p>
|
||||
|
||||
<pre><code>export LANG=nl Холандски
|
||||
export LANG=nl_NL Холандски, Низоземска
|
||||
export LANG=nl_BE Холандски, Белгија
|
||||
export LANG=es_ES Шпански, Шпанија
|
||||
export LANG=es_MX Шпански, Мексико
|
||||
export LANG=en_US.iso88591 Енглески, САД, Latin-1 кодирање
|
||||
export LANG=en_GB.UTF-8 Енглески, УК, УТФ-8 кодирање</code></pre>
|
||||
|
||||
<p>За потпун списак језика и шифара држава видите приручник геттекста: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>На Јуникс системима можете користити наредбу „locale(1)“ да видите особене податке језика.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod17"><b>ЈЕЗИК</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Са променљивом окружења ЈЕЗИК можете навести списак хитности језика, раздвојених двотачком. „dos2unix“ даје предност за ЈЕЗИК над ЈЕЗ. На пример, прво холандски а затим немачки: <code>LANGUAGE=nl:de</code>. Прво треба да омогућите преводе, постављајући „LANG“ (или LC_ALL) на вредност другачију од „C“, пре него ли будете могли да користите списак хитности језика променљивом „LANGUAGE“. Видите такође приручник геттекста: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Ако изаберете језик који није доступан добићете стандардне поруке на енглеском.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Са променљивом окружења „DOS2UNIX_LOCALEDIR“ „LOCALEDIR“ поставка у време компилације се може поништити. „LOCALEDIR“ се користи за налажење датотека језика. ГНУ-ова основна вредност је „<code>/usr/local/share/locale</code>“. Опција „<b>--version</b>“ ће приказати „LOCALEDIR“ који се користи.</p>
|
||||
|
||||
<p>Пример (ПОСИКС љуска):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod18">РЕЗУЛТНА ВРЕДНОСТ</h1>
|
||||
|
||||
<p>На успех, резултат је нула. Када има системских грешака резултат је последња грешка система. За друге грешке резултат је 1.</p>
|
||||
|
||||
<p>Вредност резултата је увек нула у тихом режиму, изузев када се користе погрешне опције линије наредби.</p>
|
||||
|
||||
<h1 id="pod19">СТАНДАРДИ</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="pod20">АУТОРИ</h1>
|
||||
|
||||
<p>Бенџамин Лин – <blin@socs.uts.edu.au>, Бернд Јоханес Вебен (mac2unix) – <wuebben@kde.org>, Кристијан Вирл (додаје додатни нови ред) – <wurll@ira.uka.de>, Ервин Вотерландер – <waterlan@xs4all.nl> (одржавалац)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Страница Ковнице извора: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="pod21">ВИДИТЕ ТАКОЂЕ</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
828
Agent-Windows/OGP64/usr/share/doc/dos2unix/sr/dos2unix.txt
Normal file
828
Agent-Windows/OGP64/usr/share/doc/dos2unix/sr/dos2unix.txt
Normal file
|
|
@ -0,0 +1,828 @@
|
|||
НАЗИВ
|
||||
dos2unix – претварач формата текстуалних датотека из ДОС/Мек-а у Јуникс
|
||||
и обратно
|
||||
|
||||
УВОД
|
||||
dos2unix [опције] [ДАТОТЕКА ...] [-n УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...]
|
||||
unix2dos [опције] [ДАТОТЕКА ...] [-n УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...]
|
||||
|
||||
ОПИС
|
||||
“dos2unix“ пакет укључује помагала „"dos2unix"“ и „"unix2dos"“ за
|
||||
претварање обичне текстуалне датотеке у ДОС или Мек формат у Јуникс
|
||||
формат и обратно.
|
||||
|
||||
У ДОС/Виндоуз текстуалним датотекама преламање реда, такође познато и
|
||||
као нови ред, је комбинација два знака: „Carriage Return“ (CR) за којим
|
||||
следи „Line Feed“ (LF). У Јуникс текстуалним датотекама преламање реда
|
||||
је један знак: „Line Feed“ (LF). У Мек текстуалним датотекама, пре Мек
|
||||
ОС Икс-а, преламање реда беше један знак „Carriage Return“ (CR). Данас
|
||||
Мек ОС користи преламање реда у Јуникс стилу (LF).
|
||||
|
||||
Поред преламања реда „dos2unix“ такође може претворити кодирање
|
||||
датотека. Неколико ДОС кодних страница се може претворити у Јуникс
|
||||
Latin-1. А Виндоуз Јуникод (UTF-16) датотеке се могу претворити у Јуникс
|
||||
Јуникод (UTF-8) датотеке.
|
||||
|
||||
Бинарне датотеке се аутоматски прескачу, осим ако претварање није
|
||||
приморано.
|
||||
|
||||
Нередовне датотеке, као што су директоријуму и ПУПИ, се аутоматски
|
||||
прескачу.
|
||||
|
||||
Симболичке везе и њихови циљеви се подразумевано не дирају. Симболичке
|
||||
везе се по жељи могу заменити, или се излаз може записати на мету
|
||||
симболичке везе. Писање на мету симболичке везе није подржано на
|
||||
Виндоузу.
|
||||
|
||||
„dos2unix“ је направљен по узору на „dos2unix“ под СанОС/Соларисом.
|
||||
Постоји једна важна разлика са изворним СанОС/Соларис издањем. Ово
|
||||
издање подразумевано врши претварање у месту (стари режим датотеке), док
|
||||
изворно СанОС/Соларис издање подржава само упарено претварање (нови
|
||||
режим датотеке). Такође погледајте опције „"-o"“ и „"-n"“. Друга разлика
|
||||
је у томе што издање СанОС/Солариса подразумевано користи режим „*iso*“
|
||||
претварања док ово издање подразумевано користи режим „*ascii*“
|
||||
претварања.
|
||||
|
||||
ОПЦИЈЕ
|
||||
-- Сматра све следеће опције као називе датотека. Користите ову опцију
|
||||
ако желите да претворите датотеке чији називи почињу цртицом. На
|
||||
пример да претворите датотеку под називом „-foo“, можете користити
|
||||
ову наредбу:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Или у режим нове датотеке:
|
||||
|
||||
dos2unix -n -- -foo излаз.txt
|
||||
|
||||
--allow-chown
|
||||
Сва власништва датотеке се мењају у режим старе датотеке.
|
||||
|
||||
Када се користи ова опција, претварање се неће прекинути када се
|
||||
власништво корисника и/или групе изворне датотеке не може сачувати у
|
||||
старом режиму датотеке. Претварање ће се наставити и претворена
|
||||
датотека ће добити исто ново власништво као да је претворена у
|
||||
режиму нове датотеке. Такође погледајте опције „"-o"“ и „"-n"“. Ова
|
||||
опција је доступна само ако „dos2unix“ има подршку за очување
|
||||
власништва корисника и групе над датотекама.
|
||||
|
||||
-ascii
|
||||
Основни режим претварања. Видите такође одељак РЕЖИМИ ПРЕТВАРАЊА.
|
||||
|
||||
-iso
|
||||
Претварање између ДОС и ИСО-8859-1 скупа знакова. Видите такође
|
||||
одељак РЕЖИМИ ПРЕТВАРАЊА.
|
||||
|
||||
-1252
|
||||
Користи Виндоуз кодну страницу 1252 (западноевропски).
|
||||
|
||||
-437
|
||||
Користи ДОС кодну страницу 437 (Сједињене Државе). Ово је основна
|
||||
кодна страница коришћена за ИСО претварање.
|
||||
|
||||
-850
|
||||
Користи ДОС кодну страницу 850 (западноевропски).
|
||||
|
||||
-860
|
||||
Користи ДОС кодну страницу 860 (португалски).
|
||||
|
||||
-863
|
||||
Користи ДОС кодну страницу 863 (француски канадски).
|
||||
|
||||
-865
|
||||
Користи ДОС кодну страницу 865 (нордијски).
|
||||
|
||||
-7 Претвара 8 битне знакове у 7 битне размаке.
|
||||
|
||||
-b, --keep-bom
|
||||
Задржава Ознаку редоследа бајта (BOM). Када улазна датотека има ОРБ,
|
||||
пише ОРБ у излазну датотеку. Ово је основно понашање приликом
|
||||
претварања у ДОС преламање реда. Видите такође опцију „"-r"“.
|
||||
|
||||
-c, --convmode РЕЖИМ_ПРЕТВАРАЊА
|
||||
Поставља режим претварања. Где је РЕЖИМ_ПРЕТВАРАЊА један од:
|
||||
*ascii*, *7bit*, *iso*, *mac* где је „ascii“ основни.
|
||||
|
||||
-D, --display-enc КОДИРАЊЕ
|
||||
Поставља кодирање приказаног текста. Где је КОДИРАЊЕ једно од:
|
||||
*ansi*, *unicode*, *unicodebom*, *utf8*, *utf8bom* где је „ansi“
|
||||
основно.
|
||||
|
||||
Ова опција је доступна само у „dos2unix“ за Виндоуз са подршком за
|
||||
Јуникод назив датотеке. Ова опција нема утицаја на стварно читање и
|
||||
писање назива датотека, већ само на начин на који се приказују.
|
||||
|
||||
Постоји неколико метода за приказивање текста у Виндоуз конзоли на
|
||||
основу кодирања текста. Сви они имају своје предности и недостатке.
|
||||
|
||||
ansi
|
||||
Подразумевани метод „dos2unix“-а је да се користи АНСИ кодиран
|
||||
текст. Предност је у томе што је повратно сагласан. Ради са
|
||||
растерским и „TrueType“ словима. У неким регионима ћете можда
|
||||
морати да промените активну ДОС ОЕМ кодну страницу у АНСИ кодну
|
||||
страницу Виндоуз система помоћу наредбе „"chcp"“, јер „dos2unix“
|
||||
користи кодну страницу Виндоуз система.
|
||||
|
||||
Недостатак анси-ја је што се међународни називи датотека са
|
||||
знаковима који нису унутар системски подразумеване кодне
|
||||
странице не приказују правилно. Уместо тога видећете знак
|
||||
питања, или погрешан симбол. Када не радите са страним називима
|
||||
датотека, овај метод је у реду.
|
||||
|
||||
unicode, unicodebom
|
||||
Предност јуникод кодирања (Виндоуз назив за УТФ-16) је у томе
|
||||
што се текст обично правилно приказује. Нема потребе за променом
|
||||
активне кодне странице. Можда ћете морати да поставите слова
|
||||
конзоле на „TrueType“ да би се међународни знаци правилно
|
||||
приказивали. Када знак није укључен у „TrueType“ слова обично
|
||||
видите мали квадрат, понекад са знаком питања у њему.
|
||||
|
||||
Када користите „ConEmu“ конзолу сав текст се исправно приказује,
|
||||
јер „ConEmu“ аутоматски бира добра слова.
|
||||
|
||||
Недостатак јуникод-а је што није сагласан са АСКРИ-јем. Излазом
|
||||
није лако руковати када га преусмерите на други програм.
|
||||
|
||||
Када се користи „"unicodebom"“ метод Јуникод тексту ће
|
||||
претходити ОРБ (Ознака редоследа вбајтоа). ОРБ је потребан за
|
||||
правилно преусмеравање или преспајање у „PowerShell“-у.
|
||||
|
||||
utf8, utf8bom
|
||||
Предност утф8 је у томе што је сагласан са АСКРИ-јем. Слова
|
||||
конзоле треба да поставити на „TrueType“ слова. Са „TrueType“
|
||||
словима текст се приказује слично као и са „"unicode"“
|
||||
кодирањем.
|
||||
|
||||
Недостатак је што се приликом коришћења подразумеваних
|
||||
растерских слова сви не-АСКРИ знакови се погрешно приказују. Не
|
||||
само да Јуникод називи датотека, већ и преведене поруке постају
|
||||
нечитљиве. У Виндоузу подешеном за регију Источне Азије, можда
|
||||
ћете видети пуно треперења конзоле приликом приказивања порука.
|
||||
|
||||
У „ConEmu“ конзоли утф8 метода кодирања ради лепо.
|
||||
|
||||
Када се користи „"utf8bom"“ метод УТФ-8 тексту ће претходити ОРБ
|
||||
(Ознака редоследа вбајтоа). ОРБ је потребна за правилно
|
||||
преусмеравање или преспајање у „PowerShell“-у.
|
||||
|
||||
Подразумевано кодирање можете изменити променљивом окружења
|
||||
„DOS2UNIX_DISPLAY_ENC“ тако што ћете је поставити на „"unicode"“,
|
||||
„"unicodebom"“, „"utf8"“, или „"utf8bom"“.
|
||||
|
||||
-e, --add-eol
|
||||
Додаје прекид реда у последњи ред ако га нема. Ово ради за сва
|
||||
претварања.
|
||||
|
||||
Датотеци претвореној из ДОС у Јуникс формат може да недостаје прекид
|
||||
реда у последњем реду. Постоје уређивачи текста који пишу текстуалне
|
||||
датотеке без прекида реда у последњем реду. Неки Јуникс програми
|
||||
имају проблема са обрадом тих датотека, јер POSIX стандард одређује
|
||||
да сваки ред у текстуалној датотеци мора да се завршава крајњим
|
||||
знаком новог реда. Јер надовезане датотеке неће давати очекивани
|
||||
резултат.
|
||||
|
||||
--error-binary
|
||||
Враћа грешку ако је бинарна датотека прескочена.
|
||||
|
||||
-f, --force
|
||||
Присиљава претварање бинарних датотека.
|
||||
|
||||
-gb, --gb18030
|
||||
У Виндоузу УТФ-16 датотеке се подразумевано претварају у УТФ-8, без
|
||||
обзира на поставке језика. Користите ову опцију за претварање УТФ-16
|
||||
датотека у „GB18030“. Ова опција је доступна само у Виндоузу. Такође
|
||||
погледајте одељак „GB18030“.
|
||||
|
||||
-h, --help
|
||||
Приказује помоћ и излази.
|
||||
|
||||
-i[ЗАСТАВИЦЕ], --info[=ЗАСТАВИЦЕ] ДАТОТЕКА ...
|
||||
Приказује податке о датотеци. Претварање се не ради.
|
||||
|
||||
Следеће информације се исписују, овим редом: број ДОС прелома реда,
|
||||
број Јуникс прелома реда, број Мек прелома реда, ознака редоследа
|
||||
бајтова, текст или бинарна, назив датотеке.
|
||||
|
||||
Пример излаза:
|
||||
|
||||
6 0 0 no_bom текст dos.txt
|
||||
0 6 0 no_bom текст unix.txt
|
||||
0 0 6 no_bom текст mac.txt
|
||||
6 6 6 no_bom текст mixed.txt
|
||||
50 0 0 UTF-16LE текст utf16le.txt
|
||||
0 50 0 no_bom текст utf8unix.txt
|
||||
50 0 0 UTF-8 текст utf8dos.txt
|
||||
2 418 219 no_bom бинарна dos2unix.exe
|
||||
|
||||
Знајте да понекад бинарна датотека може грешком бити узета за
|
||||
текстуалну датотеку. Видите такође опцију „"-s"“.
|
||||
|
||||
Ако се у додатној опцији користи "-e" или "--add-eol" такође се
|
||||
исписује и врста прекида реда последњег реда, или "noeol" ако нема
|
||||
ничега.
|
||||
|
||||
Пример излаза:
|
||||
|
||||
6 0 0 no_bom текст dos dos.txt
|
||||
0 6 0 no_bom текст unix unix.txt
|
||||
0 0 6 no_bom текст mac mac.txt
|
||||
1 0 0 no_bom текст noeol noeol_dos.txt
|
||||
|
||||
Изборне додатне заставице се могу поставити да измене излаз. Могу се
|
||||
додати једна или више заставица.
|
||||
|
||||
0 Исписује редове информација о датотеци за којима следи нулти
|
||||
знак уместо знака новог реда. Ово омогућава тачно тумачење
|
||||
назива датотека с размацима или наводницима када се користи
|
||||
заставица „c“. Користите ову заставицу у комбинацији са
|
||||
„xargs(1)“ опцијом „-0“ или „"--null"“.
|
||||
|
||||
d Исписује број ДОС преламања реда.
|
||||
|
||||
u Исписује број Јуникс преламања реда.
|
||||
|
||||
m Исписује број Мек преламања реда.
|
||||
|
||||
b Исписује ознаку редоследа бајтова.
|
||||
|
||||
t Исписује да ли је датотека текстуална или бинарна.
|
||||
|
||||
e Исписује врсту прекида реда последњег реда, или "noeol" ако га
|
||||
нема.
|
||||
|
||||
c Исписује само датотеке које ће бити претворене.
|
||||
|
||||
Са заставицом „"c"“ „dos2unix“ ће исписати само датотеке које
|
||||
садрже ДОС преламања реда, „unix2dos“ ће исписат само називе
|
||||
датотека које имају Јуникс преламања реда.
|
||||
|
||||
Ако се у додатној опцији користи "-e" или "--add-eol" такође се
|
||||
исписују и датотеке којима недостаје прекид реда у последњем
|
||||
реду.
|
||||
|
||||
h Исписује заглавље.
|
||||
|
||||
p Приказује називе датотека без путање.
|
||||
|
||||
Примери:
|
||||
|
||||
Приказује податке за све „*.txt“ датотеке:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Приказује само број ДОС преламања реда и број Јуникс преламања реда:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Приказује само ознаку редоследа бајтова:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Исписује датотеке које имају ДОС преламање реда:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Исписује датотеке које имају Јуникс преламање реда:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Исписује датотеке које имају ДОС преламања реда или им недостаје
|
||||
прекид реда у последњем реду:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Претвара само датотеке које имају ДОС преламање реда и оставља друге
|
||||
датотеке нетакнутим:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Налази текстуалне датотеке које имају ДОС преламање реда:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Задржава печат датума излазне датотеке истим као код улазне.
|
||||
|
||||
-L, --license
|
||||
Приказује лиценцу програма.
|
||||
|
||||
-l, --newline
|
||||
Додаје додатни нови ред.
|
||||
|
||||
dos2unix: Само ДОС преламања реда се мењају у два Јуникс преламања
|
||||
реда. У Мек режиму само Мек преламања реда се мењају у два Јуникс
|
||||
преламања реда.
|
||||
|
||||
unix2dos: Само Јуникс преламања реда се мењају у два ДОС преламања
|
||||
реда. У Мек режиму Јуникс преламања реда се мењају у два Мек
|
||||
преламања реда.
|
||||
|
||||
-m, --add-bom
|
||||
Пише Ознаку редоследа бајтова (BOM) у излазну датотеку.
|
||||
Подразумевано се записује УТФ-8 ОРБ.
|
||||
|
||||
Када је улазна датотека УТФ-16, и користи се опција „"-u"“, биће
|
||||
записана УТФ-16 ОРБ.
|
||||
|
||||
Никада не користите ову опцију када је излазно кодирање другачије од
|
||||
„UTF-8“, „UTF-16“, или „GB18030“. Видите такође одељак ЈУНИКОД.
|
||||
|
||||
-n, --newfile УЛАЗНА_ДАТОТЕКА ИЗЛАЗНА_ДАТОТЕКА ...
|
||||
Нови режим датотеке. Претвара датотеку УЛ_ДАТОТЕКА и пише излаз у
|
||||
датотеку ИЗЛ_ДАТОТЕКА. Називи датотека морају бити дати у паровима и
|
||||
називи џокера се „*не*“ могу користити или „*ћете*“ изгубити своје
|
||||
датотеке.
|
||||
|
||||
Особа која започне претварање у режиму нове (упарене) датотеке биће
|
||||
власник претворене датотеке. Овлашћења за читање/писање нове
|
||||
датотеке биће овлашћење изворне датотеке мање „umask(1)“ особе која
|
||||
покреће претварање.
|
||||
|
||||
--no-allow-chown
|
||||
Не дозвољава да се власништва датотеке промене у режиму старе
|
||||
датотеке.
|
||||
|
||||
Прекида претварање када власништво корисника и/или групе изворне
|
||||
датотеке не може бити очувано у старом режиму датотеке. Такође
|
||||
видите опције „"-o"“ и „"-n"“. Ова опција је доступна само ако
|
||||
„dos2unix“ има подршку за очување власништва корисника и група над
|
||||
датотекама.
|
||||
|
||||
--no-add-eol
|
||||
Не додаје прекид реда у последњи ред ако га нема (основно).
|
||||
|
||||
--no-error-binary
|
||||
Не враћа грешку ако је бинарна датотека прескочена (основно).
|
||||
|
||||
-O, --to-stdout
|
||||
Пише на стандардни излаз, као Јуникс филтер. Користите опцију „-o“
|
||||
да се вратите на режим старе датотеке (одмах).
|
||||
|
||||
Заједно са опцијом „-e“ датотеке се могу исправно надовезати. Нема
|
||||
стопљеног првог и последњег реда, и нема ознаке поретка Јуникод
|
||||
бајта по средини надовезане датотеке. Пример:
|
||||
|
||||
dos2unix -e -O дттка1.txt дттка2.txt > излаз.txt
|
||||
|
||||
-o, --oldfile ДАТОТЕКА ...
|
||||
Режим старе датотеке. Претвара датотеку ДАТОТЕКА и преписује излаз у
|
||||
њу. Програм подразумевано ради у овом режиму. Џокери назива се могу
|
||||
користити.
|
||||
|
||||
У режиму старе датотеке (у месту) претворена датотека добија иста
|
||||
овлашћења власника, групе и читања/писања као и изворна датотека.
|
||||
Такође када датотеку претвори други корисник који има овлашћење
|
||||
писања над датотеком (нпр. корисник администратор). Претварање ће се
|
||||
прекинути када не буде било могуће очувати изворне вредности.
|
||||
Промена власника може значити да првобитни власник више не може да
|
||||
чита датотеку. Промена групе може представљати безбедносни ризик,
|
||||
датотека може постати читљива од стране особа којима није намењена.
|
||||
Очување овлашћења власника, групе и читања/писања подржано је само
|
||||
на Јуниксу.
|
||||
|
||||
Да проверите да ли „dos2unix“ има подршку очувања власништва
|
||||
корисника и групе над датотеком упишите „"dos2unix -V"“.
|
||||
|
||||
Претварање се увек врши путем привремене датотеке. Када се на пола
|
||||
претварања догоди грешка, привремена датотека се брише а изворна
|
||||
датотека остаје нетакнута. Када претварање успе, изворна датотека се
|
||||
замењује привременом датотеком. Можете имати дозволу за писање над
|
||||
изворном датотеком, али немате дозволу да ставите иста својстава
|
||||
овлашћења корисника и/или груп у привремену датотеку као што има и
|
||||
изворна датотека. То значи да нисте у могућности да сачувате
|
||||
власништво корисника и/или групе над изворном датотеком. У овом
|
||||
случају можете користити опцију „"--allow-chown"“ да наставите са
|
||||
претварањем:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Друга могућност је да користи режим нове датотеке:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Предност опције „"--allow-chown"“ је да можете користити џокере, а
|
||||
својства власништва биће очувана када је могуће.
|
||||
|
||||
-q, --quiet
|
||||
Тихи режим. Потискује сва упозорења и поруке. Резултантна вредност
|
||||
је нула. Осим када се користе погрешне опције линије наредби.
|
||||
|
||||
-r, --remove-bom
|
||||
Уклања Ознаку редоследа бајтова (BOM). Не пише ОРБ у излазну
|
||||
датотеку. Ово је основно понашање приликом претварања у Јуникс
|
||||
преламање реда. Видите такође опцију „"-b"“.
|
||||
|
||||
-s, --safe
|
||||
Прескаче извршне датотеке (основно).
|
||||
|
||||
Прескакање бинарних датотека врши се како би се избегле случајне
|
||||
грешке. Имајте на уму да откривање бинарних датотека није 100%
|
||||
поуздано. У улазним датотекама се траже бинарни симболи који се
|
||||
обично не налазе у текстуалним датотекама. Могуће је да бинарна
|
||||
датотека садржи само обичне текстуалне знакове. Таква бинарна
|
||||
датотека ће се погрешно сматрати текстуалном датотеком.
|
||||
|
||||
По основи, никаква грешка се не враћа када је бинарна датотека
|
||||
прескочена. Када се користи опција "--error-binary", враћа се
|
||||
грешка.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Подразумева да је формат улазне датотеке „UTF-16LE“.
|
||||
|
||||
Када постоји Ознака редоследа бајтова у улазној датотеци ОРБ има
|
||||
предност над овом опцијом.
|
||||
|
||||
Када сте погрешно претпоставили (улазна датотека није била у
|
||||
УТФ-16ЛЕ формату) а претварање је успело, добићете УТФ-8 излазну
|
||||
датотеку са погрешним текстом. Погрешно претварање можете да
|
||||
опозовете помоћу „iconv(1)“ претварањем УТФ-8 излазне датотеке назад
|
||||
у УТФ-16ЛЕ. Ово ће вратити изворну датотеку.
|
||||
|
||||
Претпоставка УТФ-16ЛЕ ради као „*conversion mode*“. Пребацивањем на
|
||||
основни „*ascii*“ режим УТФ-16ЛЕ претпоставка се искључује.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Подразумева да је формат улазне датотеке „UTF-16BE“.
|
||||
|
||||
Ова опција ради исто као и опција „"-ul"“.
|
||||
|
||||
-v, --verbose
|
||||
Приказује опширне поруке. Додатне информације се приказују о Ознаци
|
||||
редоследа бајтова и количини претворених преламања реда.
|
||||
|
||||
-F, --follow-symlink
|
||||
Прати симболичке везе и претвара циљеве.
|
||||
|
||||
-R, --replace-symlink
|
||||
Замењује симболичке везе претвореним датотекама (изворне циљне
|
||||
датотеке остају непромењене).
|
||||
|
||||
-S, --skip-symlink
|
||||
Задржава неизмењеним симболичке везе и циљеве (основно).
|
||||
|
||||
-V, --version
|
||||
Приказује податке о издању и излази.
|
||||
|
||||
МЕК РЕЖИМ
|
||||
По основи преламања реда се претварају из DOS-а у Unix и обратно.
|
||||
Mac-ова преламања реда се не претварају.
|
||||
|
||||
У Мек режиму преламања реда се претварју из Мек-а у Јуникс и обратно.
|
||||
ДОС преламања реда се не мењају.
|
||||
|
||||
Да покренете у Мек режиму користите опцију „"-c mac"“ или користите
|
||||
наредбе „"mac2unix"“ или „"unix2mac"“.
|
||||
|
||||
РЕЖИМИ ПРЕТВАРАЊА
|
||||
ascii
|
||||
Ово је основни режим претварања. Овај режим је за претварање ASCII и
|
||||
ASCII-сагласних кодираних датотека, као UTF-8. Укључивање ascii
|
||||
режима искључује 7bit и iso.
|
||||
|
||||
Ако dos2unix има UTF-16 подршку, UTF-16 кодиране датотеке се
|
||||
претварају у кодирање знакова текућег језика на POSIX системима и у
|
||||
UTF-8 на Виндоузу. Укључивањем ascii режима искључује се опција за
|
||||
задржавање UTF-16 кодирања ("-u") и опције за прихват UTF-16 улаза
|
||||
("-ul" и "-ub"). Да видите да ли dos2unix има UTF-16 подршку
|
||||
укуцајте "dos2unix -V". Видите такође одељак UNICODE.
|
||||
|
||||
7bit
|
||||
У овом режиму сви 8 битни не-АСКРИ знаци (са вредностима од 128 до
|
||||
255) се претварају у 7 битне размаке.
|
||||
|
||||
iso Знакови се претварају између ДОС скупа знакова (кодна страница) и
|
||||
ИСО скупа знакова ИСО-8859-1 (Latin-1) на Јуниксу. ДОС знакови без
|
||||
ИСО-8859-1 еквивалента, за које претварање није могуће, претварају
|
||||
се у тачку. Исто се рачуна и за ИСО-8859-1 знакове без ДОС-а.
|
||||
|
||||
Када се користи само опција „"-iso"“, „dos2unix“ ће покушати да
|
||||
одреди активну кодну страницу. Када то није могуће, „dos2unix“ ће
|
||||
користити подразумевану кодну страницу ЦП437, која се углавном
|
||||
користи у САД-у. Да бисте приморали одређену кодну страницу,
|
||||
користите опције „-437“ (САД), „-850“ (западноевропски), „-860“
|
||||
(португалски), „-863“ (француски канадски) или „-865“ (нордијски).
|
||||
Виндоуз кодна страница ЦП1252 (западноевропски) је такође подржана
|
||||
опцијом „-1252“. За остале кодне странице користите „dos2unix“ у
|
||||
комбинацији са „iconv(1)“. Иконв може да претвара између дугог
|
||||
списка кодирања знакова.
|
||||
|
||||
Никада не користите ИСО претварање над Јуникод текстуалним
|
||||
датотекама. Оштетиће УТФ-8 кодиране датотеке.
|
||||
|
||||
Неки примери:
|
||||
|
||||
Претворите из ДОС основне кодне странице у Јуникс Latin-1:
|
||||
|
||||
dos2unix -iso -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из ДОС CP850 у Јуникс Latin-1:
|
||||
|
||||
dos2unix -850 -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Виндоуз CP1252 у Јуникс Latin-1:
|
||||
|
||||
dos2unix -1252 -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Виндоуз CP1252 у Јуникс УТФ-8 (Јуникод):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 улаз.txt | dos2unix > излаз.txt
|
||||
|
||||
Претворите из Јуникс Latin-1 у ДОС основну кодну страницу:
|
||||
|
||||
unix2dos -iso -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Јуникс Latin-1 у ДОС CP850:
|
||||
|
||||
unix2dos -850 -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Јуникс Latin-1 у Вондоуз CP1252:
|
||||
|
||||
unix2dos -1252 -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Јуникс УТФ-8 (Јуникод) у Вондоуз CP1252:
|
||||
|
||||
unix2dos < улаз.txt | iconv -f UTF-8 -t CP1252 > излаз.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
УНИКОД
|
||||
Кодирања
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Претварање
|
||||
Јуникод текстуалне датотеке могу имати DOS, Unix или Mac преломе реда,
|
||||
као ASCII текстуалне датотеке.
|
||||
|
||||
Сва издања „dos2unix“-а и „unix2do“-а могу претворити УТФ-8 кодиране
|
||||
датотеке, јер је УТФ-8 дизајниран за повратну сагласност са АСКРИ-ијем.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
На Јуниксу/Линуксу УТФ-16 кодиране датотеке се претварају у локално
|
||||
кодирање знакова. Користите наредбу „locale(1)“ да сазнате које је
|
||||
кодирање знакова локализације. Када претварање није могуће, десиће се
|
||||
грешка претварања а датотека ће бити прескочена.
|
||||
|
||||
На Виндоузу УТФ-16 датотеке се подразумевано претварају у УТФ-8. УТФ-8
|
||||
форматиране текстуалне датотеке су добро подржане и на Виндоузу и на
|
||||
Јуникс/Линуксу.
|
||||
|
||||
УТФ-16 и УТФ-8 кодирања су у потпуности сагласна, у претварању се неће
|
||||
изгубити никакав текст. Када се догоди грешка претварања УТФ-16 у УТФ-8,
|
||||
на пример када улазна УТФ-16 датотека садржи грешку, датотека ће бити
|
||||
прескочена.
|
||||
|
||||
Када се користи опција „"-u"“, излазна датотека ће бити записана у истом
|
||||
УТФ-16 кодирању као и улазна датотека. Опција „"-u"“ спречава претварање
|
||||
у УТФ-8.
|
||||
|
||||
„dos2unix“ и „unix2dos“ немају могућности да претворе УТФ-8 датотеке у
|
||||
УТФ-16.
|
||||
|
||||
ИСО и 7-битни режим претварања не ради на УТФ-16 датотекама.
|
||||
|
||||
Ознака редоследа бајтова
|
||||
На Виндоузу Јуникод текстуалне датотеке обично имају Ознаку редоследа
|
||||
бајтова (BOM), јер многи Виндоуз програми (укључујући Бележницу)
|
||||
подразумевано додају ОРБ. Видите такође
|
||||
<https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
На Јуниксу Јуникод датотеке обично немају ОРБ. Претпоставља се да су
|
||||
текстуалне датотеке кодиране у језичком кодирању знака.
|
||||
|
||||
„dos2unix“ може открити само да ли је датотека у УТФ-16 формату и да ли
|
||||
датотека има ОРБ. Када УТФ-16 датотека нема ОРБ, „dos2unix“ ће видети
|
||||
датотеку као бинарну.
|
||||
|
||||
Користите опцију „"-ul"“ или „"-ub"“ да претворите УТФ-16 датотеку без
|
||||
ОРБ-а.
|
||||
|
||||
„dos2unix“ подразумевано не записује ОРБ у излазну датотеку. Са опцијом
|
||||
„"-b"“ „dos2unix записује ОРБ када улазна датотека има ОРБ.
|
||||
|
||||
„unix2dos“ подразумевано записује ОРБ у излазну датотеку када улазна
|
||||
датотека има ОРБ. Користите опцију „"-r"“ да уклоните ОРБ.
|
||||
|
||||
„dos2unix“ и „unix2dos“ увек записује ОРБ када се користи „"-m"“ опција.
|
||||
|
||||
Јуникод називи датотека на Виндоузу
|
||||
„dos2unix“ има изборну подршку за читање и писање Јуникод назива
|
||||
датотека у Виндоуз командној линији. То значи да „dos2unix“ може
|
||||
отворити датотеке које у називу имају знакове који нису део
|
||||
подразумеване системске АНСИ кодне странице. Да бисте видели да ли је
|
||||
„dos2unix“ за Виндоуз изграђен са подршком Јуникод назива датотеке
|
||||
упишите „"dos2unix -V"“.
|
||||
|
||||
Постоје проблеми са приказом Јуникод назива датотека у Виндоуз конзоли.
|
||||
Видите опцију „"-D"“, „"--display-enc"“. Називи датотека могу бити
|
||||
погрешно приказани у конзоли, али ће датотеке бити записане под тачним
|
||||
називом.
|
||||
|
||||
Примери Уникода
|
||||
Претвара из Виндоуз УТФ-16 (са ОРБ-ом) у Јуникс УТФ-8:
|
||||
|
||||
dos2unix -n улаз.txt излаз.txt
|
||||
|
||||
Претвара из Виндоуз УТФ-16ЛЕ (без ОРБ-а) у Јуникс УТФ-8:
|
||||
|
||||
dos2unix -ul -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Јуникс УТФ-8 у Вондоуз УТФ-8 са ОРБ-ом:
|
||||
|
||||
unix2dos -m -n улаз.txt излаз.txt
|
||||
|
||||
Претворите из Јуникс УТФ-8 у Вондоуз УТФ-16:
|
||||
|
||||
unix2dos < улаз.txt | iconv -f UTF-8 -t UTF-16 > излаз.txt
|
||||
|
||||
GB18030
|
||||
GB18030 је стандард кинеске владе. Обавезни подскуп GB18030 стандарда се
|
||||
званично захтева за све софтверске производе продате у Кини. Видите
|
||||
такође <http://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
„GB18030“ је у потпуности сагласан са Јуникод-ом, и може се сматрати
|
||||
Јуникод форматом преображаја. Као УТФ-8, „GB18030“ је сагласан са АСКРИ.
|
||||
„GB18030“ је такође сагласан са Виндоуз кодном страницом 936, познатом и
|
||||
као ГБК.
|
||||
|
||||
На Јуниксу/Линуксу УТФ-16 датотеке се претварају у „GB18030“ када је
|
||||
језичко кодирање постављено на „GB18030“. Знајте да ће ово радити само
|
||||
ако је језик подржан системом. Користите наредбу „"locale -a"“ да
|
||||
добавите списак подржаних језика.
|
||||
|
||||
На Виндоузу треба да користите опцију „"-gb"“ да преведете УТФ-16
|
||||
датотеке у „GB18030“.
|
||||
|
||||
„GB18030“ кодиране датотеке могу имати Ознаку редоследа бајтова, као
|
||||
Јуникод датотеке.
|
||||
|
||||
ПРИМЕРИ
|
||||
Чита улаз са „стнд_улаза“ и пише излаз на „стнд_излаз“:
|
||||
|
||||
dos2unix < а.txt
|
||||
cat а.txt | dos2unix
|
||||
|
||||
Претвара и замењује „а.txt“. Претвара и замењује „б.txt“:
|
||||
|
||||
dos2unix а.txt б.txt
|
||||
dos2unix -o а.txt б.txt
|
||||
|
||||
Претвара и замењује „а.txt“ у аскри режиму претварања:
|
||||
|
||||
dos2unix а.txt
|
||||
|
||||
Претвара и замењује „а.txt“ у аскри режиму претварања, Претвара и
|
||||
замењује „б.txt“ у 7битном режиму претварања:
|
||||
|
||||
dos2unix а.txt -c 7bit б.txt
|
||||
dos2unix -c ascii а.txt -c 7bit б.txt
|
||||
dos2unix -ascii а.txt -7 б.txt
|
||||
|
||||
Претвара „а.txt“ из Мек у Јуникс формат:
|
||||
|
||||
dos2unix -c mac а.txt
|
||||
mac2unix а.txt
|
||||
|
||||
Претвара „а.txt“ из Јуникс у Мек формат:
|
||||
|
||||
unix2dos -c mac а.txt
|
||||
unix2mac а.txt
|
||||
|
||||
Претвара и замењује „а.txt“ док задржава изворни печат датума:
|
||||
|
||||
dos2unix -k а.txt
|
||||
dos2unix -k -o а.txt
|
||||
|
||||
Претвара „а.txt“ и пише на „е.txt“:
|
||||
|
||||
dos2unix -n а.txt е.txt
|
||||
|
||||
Претвара „а.txt“ и пише на „е.txt“, задржава печат датума „е.txt“-а
|
||||
истим као „а.txt“:
|
||||
|
||||
dos2unix -k -n а.txt е.txt
|
||||
|
||||
Претвара и замењује „а.txt“, претвара „б.txt“ и пише на „.txt“:
|
||||
|
||||
dos2unix а.txt -n б.txt е.txt
|
||||
dos2unix -o а.txt -n б.txt е.txt
|
||||
|
||||
Претвара „ц.txt“ и пише на „е.txt“, претвара и замењује„а.txt“, претвара
|
||||
и замењује „б.txt“, претвара „д.txt“ и пише у „ф.txt“:
|
||||
|
||||
dos2unix -n ц.txt е.txt -o а.txt б.txt -n д.txt ф.txt
|
||||
|
||||
ДУБИНСКО ПРЕТВАРАЊЕ
|
||||
У Јуникс шкољци наредбе „find(1)“ и „xargs(1)“ се могу користити за
|
||||
покретање „dos2unix“-а дубински преко свих текстуалних датотека у стаблу
|
||||
директоријума. На пример за претварање свих „.txt“ датотека у стаблу
|
||||
директоријума под текућим директоријумом упишите:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
„find(1)“-ова опција „"-print0"“ и одговарајућа „xargs(1)“-ова опција
|
||||
„-0“ су потребне када постоје датотеке са размацима и наводницима у
|
||||
називима. У супротном се ове опције могу изоставити. Друга могућност је
|
||||
да користите „find(1)“ са „"-exec"“ опцијом:
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
У Виндоуз командном упиту следеће наредбе се могу користити:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
Корисници „PowerShell“-а могу користити следеће наредбе у Виндоуз
|
||||
„PowerShell“-у:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
ЈЕЗИЧЕЊЕ
|
||||
ЈЕЗ Примарни језик се бира променљивом окружења „LANG“. Променљива
|
||||
„LANG“ се састоји из неколико делова. Први део је малим словима
|
||||
језички код. Други је необавезан и представља код државе великим
|
||||
словима, којем претходи доња црта. Ту је и изборни трећи део:
|
||||
кодирање знакова, којем претходи тачка. Неколико примера за врсте
|
||||
шкољки ПОСИКС стандарда:
|
||||
|
||||
export LANG=nl Холандски
|
||||
export LANG=nl_NL Холандски, Низоземска
|
||||
export LANG=nl_BE Холандски, Белгија
|
||||
export LANG=es_ES Шпански, Шпанија
|
||||
export LANG=es_MX Шпански, Мексико
|
||||
export LANG=en_US.iso88591 Енглески, САД, Latin-1 кодирање
|
||||
export LANG=en_GB.UTF-8 Енглески, УК, УТФ-8 кодирање
|
||||
|
||||
За потпун списак језика и шифара држава видите приручник геттекста:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
На Јуникс системима можете користити наредбу „locale(1)“ да видите
|
||||
особене податке језика.
|
||||
|
||||
ЈЕЗИК
|
||||
Са променљивом окружења ЈЕЗИК можете навести списак хитности језика,
|
||||
раздвојених двотачком. „dos2unix“ даје предност за ЈЕЗИК над ЈЕЗ. На
|
||||
пример, прво холандски а затим немачки: "LANGUAGE=nl:de". Прво треба
|
||||
да омогућите преводе, постављајући „LANG“ (или LC_ALL) на вредност
|
||||
другачију од „C“, пре него ли будете могли да користите списак
|
||||
хитности језика променљивом „LANGUAGE“. Видите такође приручник
|
||||
геттекста:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Ако изаберете језик који није доступан добићете стандардне поруке на
|
||||
енглеском.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Са променљивом окружења „DOS2UNIX_LOCALEDIR“ „LOCALEDIR“ поставка у
|
||||
време компилације се може поништити. „LOCALEDIR“ се користи за
|
||||
налажење датотека језика. ГНУ-ова основна вредност је
|
||||
„"/usr/local/share/locale"“. Опција „--version“ ће приказати
|
||||
„LOCALEDIR“ који се користи.
|
||||
|
||||
Пример (ПОСИКС љуска):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
РЕЗУЛТНА ВРЕДНОСТ
|
||||
На успех, резултат је нула. Када има системских грешака резултат је
|
||||
последња грешка система. За друге грешке резултат је 1.
|
||||
|
||||
Вредност резултата је увек нула у тихом режиму, изузев када се користе
|
||||
погрешне опције линије наредби.
|
||||
|
||||
СТАНДАРДИ
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
АУТОРИ
|
||||
Бенџамин Лин – <blin@socs.uts.edu.au>, Бернд Јоханес Вебен (mac2unix) –
|
||||
<wuebben@kde.org>, Кристијан Вирл (додаје додатни нови ред) –
|
||||
<wurll@ira.uka.de>, Ервин Вотерландер – <waterlan@xs4all.nl>
|
||||
(одржавалац)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Страница Ковнице извора: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
ВИДИТЕ ТАКОЂЕ
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/sv/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/sv/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - textfilsformatskonverterare från DOS/Mac till Unix och vice versa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#NAMN">NAMN</a></li>
|
||||
<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
|
||||
<li><a href="#BESKRIVNING">BESKRIVNING</a></li>
|
||||
<li><a href="#FLAGGOR">FLAGGOR</a></li>
|
||||
<li><a href="#MAC-L-GE">MAC-LÄGE</a></li>
|
||||
<li><a href="#KONVERTERINGSL-GEN">KONVERTERINGSLÄGEN</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#Kodningar">Kodningar</a></li>
|
||||
<li><a href="#Konvertering">Konvertering</a></li>
|
||||
<li><a href="#Byteordningsmarkering-Byte-Order-Mark">Byteordningsmarkering (Byte Order Mark)</a></li>
|
||||
<li><a href="#Unicode-filnamn-under-Windows">Unicode-filnamn under Windows</a></li>
|
||||
<li><a href="#Unicode-exempel">Unicode-exempel</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#EXEMPEL">EXEMPEL</a></li>
|
||||
<li><a href="#REKURSIV-KONVERTERING">REKURSIV KONVERTERING</a></li>
|
||||
<li><a href="#LOKALISERING">LOKALISERING</a></li>
|
||||
<li><a href="#RETURV-RDE">RETURVÄRDE</a></li>
|
||||
<li><a href="#STANDARDER">STANDARDER</a></li>
|
||||
<li><a href="#F-RFATTARE">FÖRFATTARE</a></li>
|
||||
<li><a href="#SE-VEN">SE ÄVEN</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="NAMN">NAMN</h1>
|
||||
|
||||
<p>dos2unix - konverterare för textfilsformat från DOS/Mac till Unix och vice versa</p>
|
||||
|
||||
<h1 id="SYNOPSIS">SYNOPSIS</h1>
|
||||
|
||||
<pre><code>dos2unix [flaggor] [FIL …] [-n INFIL UTFIL …]
|
||||
unix2dos [flaggor] [FIL …] [-n INFIL UTFIL …]</code></pre>
|
||||
|
||||
<h1 id="BESKRIVNING">BESKRIVNING</h1>
|
||||
|
||||
<p>Paketet dos2unix inkluderar verktygen <code>dos2unix</code> och <code>unix2dos</code> som konverterar oformaterade textfiler i DOS- eller Mac-format till Unix-format och vice versa.</p>
|
||||
|
||||
<p>Textfiler i DOS/Windows har en radbrytning, också känd som nyrad, som är en kombination av två tecken: vagnretur (Carriage Return, CR) åtföljt av radmatning (Line Feed, LF). Textfiler i Unix har en radbrytning som är ett enda tecken: radmatning (Line Feed, LF). Textfiler för Mac, innan Mac OS X, hade en radbrytning som var en enda vagnretur (Carriage Return, CR). Numera använder Mac OS radbrytning i Unix-stil (LF).</p>
|
||||
|
||||
<p>Förutom radbrytningar så kan dos2unix också konvertera filers kodning. Några DOS-teckentabeller kan konverteras till Unix Latin-1. Och filer som använder Windows Unicode (UTF-16) kan konverteras till Unix Unicode (UTF-8).</p>
|
||||
|
||||
<p>Binära filer hoppas över automatiskt, om inte konvertering tvingas.</p>
|
||||
|
||||
<p>Kataloger och FIFOs och andra filer som inte är vanliga filer hoppas över automatiskt.</p>
|
||||
|
||||
<p>Symboliska länkar och deras mål förblir oförändrade som standard. Symboliska länkar kan valfritt bli ersatta eller så kan utmatningen skrivas till målet för den symboliska länken. På Windows saknas stöd för att skriva till målet för en symbolisk länk.</p>
|
||||
|
||||
<p>dos2unix modellerades efter dos2unix från SunOS/Solaris. Det finns en viktig skillnad gentemot originalversionen för SunOS/Solaris. Denna versionen gör som standard konverteringen på plats (gammalfilsläge), medan originalversionen från SunOS/Solaris bara hade stöd för parad konvertering (nyfilsläge). Se vidare flaggorna <code>-o</code> och <code>-n</code>. En annan skillnad är att SunOS/Solaris-versionen som standard använder <i>iso</i>-lägeskonvertering medan denna version som standard använder <i>ascii</i>-lägeskonvertering.</p>
|
||||
|
||||
<h1 id="FLAGGOR">FLAGGOR</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Behandla alla efterföljande flaggor som filnamn. Använd denna flagga om du vill konvertera filer vars namn börjar med bindestreck. För att till exempel konvertera en fil med namnet “-foo“ kan du använda detta kommando:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Eller i nyfilsläge:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tillåt ändring av ägarskap för fil i gammalt filläge.</p>
|
||||
|
||||
<p>När denna flagga används, kommer konverteringen inte att avbrytas när användar- och/eller gruppägarskap för originalfilen inte kan bevaras i gammalt filläget. Konverteringen kommer att fortsätta och den konverterade filen kommer att få samma nya ägarskap som om den konverterades i nyfilsläge. Se också flaggorna <code>-o</code> och <code>-n</code>. Denna flagga är endast tillgänglig om dos2unix har stöd för att bevara användar- och gruppägarskap för filer.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Standardkonverteringsläge. Se vidare stycket KONVERTERINGSLÄGEN.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Konvertering mellan DOS- och ISO-8859-1-teckentabeller. Se vidare stycket KONVERTERINGSLÄGEN.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd Windows-teckentabell 1252 (Västeuropeisk).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd DOS-teckentabell 437 (USA). Detta är standardteckentabellen som används för ISO-konvertering.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd DOS-teckentabell 850 (Västeuropeisk).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd DOS-teckentabell 860 (Portugisisk).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd DOS-teckentabell 863 (Fransk-kanadensisk).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Använd DOS-teckentabell 865 (Nordisk).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Konvertera 8-bitars tecken till 7-bitars blanksteg.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Behåll byteordningsmarkering (Byte Order Mark, BOM). Om infilen har en BOM, skriv en BOM i utfilen. Detta är standardbeteendet vid konvertering av DOS-radbrytningar. Se vidare flaggan <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode-KONVERTERINGSL-GE"><b>-c, --convmode KONVERTERINGSLÄGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ställer in konverteringsläge. Där KONVERTERINGSLÄGE är en av: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i> där ascii är standard.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-KODNING"><b>-D, --display-enc KODNING</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ställ in kodning för visad text. Där KODNING är en av: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i> där ansi är standardvalet.</p>
|
||||
|
||||
<p>Denna flagga finns bara tillgänglig i dos2unix för Windows med stöd för Unicode-filnamn. Denna flagga har ingen effekt på själva filnamnen som läses och skrivs, bara på hur de visas.</p>
|
||||
|
||||
<p>Det finns flera metoder för att visa text i en Windows-konsol baserad på vilken kodning texten har. De har alla för- och nackdelar.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix standardmetod är att använda ANSI-kodad text. Fördelen är att den är bakåtkompatibel. Det fungerar med raster- och TrueType-teckensnitt. I vissa regioner kan du behöva ändra den aktiva DOS OEM-teckentabellen till Windows-systemets ANSI-teckentabell genom att använda kommandot <code>chcp</code>, eftersom dos2unix använder Windows-systemets teckentabell.</p>
|
||||
|
||||
<p>Nackdelen med ansi är att internationella filnamn med tecken som inte finns i systemets standardteckentabell inte visas korrekt. Du kommer att se frågetecken, eller en felaktig symbol istället. När du inte arbetar med utländska filnamn är denna metoden OK.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Fördelen med unicode-kodning (Windows-namnet för UTF-16) är att text vanligtvis visas korrekt. Det finns inget behov av att ändra den aktiva teckentabellen. Du kan behöva ställa in konsolens teckensnitt till ett TrueType-teckensnitt för att få internationella tecken att visas korrekt. När ett tecken inte finns inkluderat i TrueType-teckensnittet kommer du vanligtvis att se en liten ruta, ibland med ett frågetecken inuti.</p>
|
||||
|
||||
<p>När du använder ConEmu-konsolen kommer all text att visas korrekt eftersom ConEmu automatiskt väljer ett bra teckensnitt.</p>
|
||||
|
||||
<p>Nackdelen med unicode är att den inte är kompatibel med ASCII. Utmatningen är inte lätt att hantera när du omdirigerar den till ett annat program eller en fil.</p>
|
||||
|
||||
<p>När metod <code>unicodebom</code> används kommer Unicode-texten att föregås av en BOM (byteordningsmarkering, Byte Order Mark). En BOM krävs för korrekt omdirigering eller rörledning i PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Fördelen med utf8 är att den är kompatibel med ASCII. Du måste ställa in konsolens teckensnitt till ett TrueType-teckensnitt. Med ett TrueType-teckensnitt kommer text att visas på liknande sätt som med <code>unicode</code>-kodningen.</p>
|
||||
|
||||
<p>Nackdelen är att när du använder standardrasterteckensnittet kommer alla icke-ASCII tecken att visas fel. Inte enbart unicode-filnamn, utan också översatta meddelanden kommer att bli oläsbara. Under Windows som konfigurerats för Östasien kan man komma att se många blinkningar i konsolen när meddelanden visas.</p>
|
||||
|
||||
<p>I ConEmu-konsolen fungerar utf8-kodningsmetoden väl.</p>
|
||||
|
||||
<p>När metod <code>utf8bom</code> används kommer UTF-8-texten att föregås av en BOM (byteordningsmarkering, Byte Order Mark). En BOM krävs för korrekt omdirigering eller rörledning i PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Standardkodningen kan ändras via miljövariabeln DOS2UNIX_DISPLAY_ENC genom att sätta den till <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> or <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Lägg till en radbrytning på sista raden om det inte finns någon. Detta fungerar för alla konverteringar.</p>
|
||||
|
||||
<p>En fil konverterad från DOS- till Unix-format kan sakna en radbrytning på sista raden. Det finns textredigerare som skriver textfiler utan en radbrytning på den sista raden. Vissa Unix-program har problem med att behandla dessa filer, då POSIX-standarden definierar det som att varje rad i en textfil måste har ett avslutande nyradstecken. Att konkatenera filer kan till exempel ge oväntat resultat.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Return an error if a binary file is skipped.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tvinga konvertering av binära filer.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Under Windows konverteras UTF-16-filer som standard till UTF-8, oavsett vilken lokalinställning som är gjord. Använd denna flagga för att konvertera UTF-16-filer till GB18030. Denna flagga finns bara tillgänglig i Windows. Se vidare i avsnittet GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa hjälptext och avsluta.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i-FLAGGOR---info-FLAGGOR-FIL"><b>-i[FLAGGOR], --info[=FLAGGOR] FIL ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa filinformation. Ingen konvertering görs.</p>
|
||||
|
||||
<p>Följande information skrivs ut, i denna ordningen: antal DOS-radbrytningar, antal Unix-radbrytningar, antal Mac-radbrytningar, byteordningsmarkeringen, text eller binär, filnamn.</p>
|
||||
|
||||
<p>Exempelutmatning:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binär dos2unix.exe</code></pre>
|
||||
|
||||
<p>Notera att en binärfil ibland kan misstas för en textfil. Se vidare flaggan <code>-s</code>.</p>
|
||||
|
||||
<p>Om dessutom flaggan <code>-e</code> eller <code>--add-eol</code> används så kommer även den radbrytning som används på sista raden att skrivas ut, eller <code>noeol</code> om det inte finns någon.</p>
|
||||
|
||||
<p>Exempelutmatning:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Extra flaggor kan användas valfritt för att ändra utmatningen. En eller fler flaggor kan läggas till.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut filinformationsraderna följt av ett null-tecken istället för ett nyradstecken. Detta möjliggör korrekt tolkning av filnamn med blanksteg eller citationstecken när c-flaggan används. Använd denna flagga i kombination med xargs(1):s flagga <code>-0</code> eller <code>--null</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut antal DOS-radbrytningar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut antal Unix-radbrytningar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut antal Mac-radbrytningar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut byteordningsmarkeringen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut om filen är text eller binär.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut radbrytningstypen på sista raden, eller <code>noeol</code> om det inte finns någon.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv bara ut filerna som skulle ha konverterats.</p>
|
||||
|
||||
<p>Med <code>c</code>-flaggan kommer dos2unix att skriva ut filerna som innehåller DOS-radbrytningar, unix2dos kommer bara att skriva ut filnamn som har Unix-radbrytningar.</p>
|
||||
|
||||
<p>Om dessutom flaggan <code>-e</code> eller <code>--add-eol</code> används så kommer även filer som saknar en radbrytning på sista raden att skrivas ut.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv ut rubrik.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa filnamn utan sökväg.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Exempel:</p>
|
||||
|
||||
<p>Visa information för alla *.txt-filer:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Visa bara antalet DOS-radbrytningar och Unix-radbrytningar:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Visa bara byteordningsmarkeringen:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Lista filerna som har DOS-radbrytningar:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Lista filerna som har Unix-radbrytningar:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Lista filerna som har DOS-radbrytningar eller saknar en radbrytning på sista raden:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Konvertera endast filer som har DOS-radbrytningar och lämna övriga filer orörda:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Hitta textfiler som har DOS-radbrytningar:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Behåll infilens datumstämpel för utfilen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa programmets licens.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Lägg till ytterligare nyrad.</p>
|
||||
|
||||
<p><b>dos2unix</b>: Endast DOS-radbrytningar ändras till två Unix-radbrytningar. I Mac-läge ändras endast Mac-radbrytningar till två Unix-radbrytningar.</p>
|
||||
|
||||
<p><b>unix2dos</b>: Endast Unix-radbrytningar ändras till två DOS-radbrytningar. I Mac-läge ändras Unix-radbrytningar till två Mac-radbrytningar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv en byteordningsmarkering (Byte Order Mark, BOM) i utfilen. Som standard skrivs en UTF-8 BOM.</p>
|
||||
|
||||
<p>När infilen är UTF-16, och flaggan <code>-u</code> används, kommer en UTF-16 BOM att skrivas.</p>
|
||||
|
||||
<p>Använd aldrig denna flagga när kodningen för utmatning är något annat än UTF-8, UTF-16 eller GB18030. Se vidare i avsnittet UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-INFIL-UTFIL"><b>-n, --newfile INFIL UTFIL …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Nyfilsläge. Konvertera filen INFIL och skriv utfilen UTFIL. Filnamnen måste ange i par och jokertecken i namnen ska <i>inte</i> användas annars <i>kommer</i> du att förlora filer.</p>
|
||||
|
||||
<p>Användaren som påbörjar konverteringen i nyfilsläge (parat läge) kommer att bli ägaren till den konverterade filen. Läs-/skrivbehörigheter för den nya filen kommer att vara samma behörigheter som för originalfilen minus umask(1) för användaren som kör konverteringen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tillåt inte ändring av ägarskap i gammalt filläge (standard)</p>
|
||||
|
||||
<p>Avbryt konvertering när användar- och/eller gruppägarskap för originalfilen inte kan bevaras i gammalt filläge. Se också flaggorna <code>-o</code> och <code>-n</code>. Denna flagga är endast tillgänglig om dos2unix har stöd för att bevara användar- och gruppägarskap för filer.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not add a line break to the last line if there isn't one (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not return an error if a binary file is skipped (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Skriv till standard ut som ett Unix-filter. Använd flaggan <code>-o</code> för att återgå till det gamla (på-plats) filläget.</p>
|
||||
|
||||
<p>Kombinerat med flaggan <code>-e</code> kan filer konkateneras korrekt. Inga sammanfogade sista och första rader, och inga Unicode byteordningsmarkeringar i mitten på den konkatenerade filen. Exempel:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O fil1.txt fil2.txt > ut.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile-FIL"><b>-o, --oldfile FIL …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Gammalfilsläge. Konvertera filen FIL och skriv över den med utmatningen. Programmet kör i detta läge som standard. Jokertecken i filnamn får användas.</p>
|
||||
|
||||
<p>I gammalfilsläge (på-plats läge) kommer den konverterade filen att få samma ägare, grupp samt läs-/skrivbehörigheter som originalfilen. Även då filen konverteras av en annan användare som har skrivbehörighet för filen (t.ex. användaren root). Konverteringen kommer att avbrytas när det inte är möjligt att bevara originalvärdena. Byte av ägare skulle kunna innebära att originalägaren inte längre kan läsa filen. Byte av grupp skulle kunna vara en säkerhetsrisk, filen skulle kunna bli läsbar för användare som den inte är avsedd för. Stöd för bevarande av ägare, grupp och läs-/skrivbehörigheter finns bara i Unix.</p>
|
||||
|
||||
<p>För att kontrollera om dos2unix har stöd för att bevara användar- och gruppägarskap för filer skriv <code>dosunix -V</code>.</p>
|
||||
|
||||
<p>Konvertering görs alltid via en temporärfil. När ett fel inträffar halvvägs i konverteringen tas den temporära filen bort och originalfilen finns kvar intakt. Om konverteringen är framgångsrik kommer originalfilen att ersättas med temporärfilen. Du kanske har skrivrättigheter till originalfilen men inte rättigheter att ställa in samma användar- och/eller grupprättighetsegenskaper på temporärfilen som originalfilen har. Detta innebär att du inte kan bevara användar- och/eller gruppägarskapet för originalfilen. I detta fall kan du använda flaggan <code>--allow-chown</code> för att fortsätta konverteringen:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>Ett annat alternativ är att använda nyfilsläge:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>Fördelen med flaggan <code>--allow-chown</code> är att du kan använda jokertecken och att ägarskapsegenskaper om möjligt kommer att bevaras.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tyst drift. Undertryck alla varningar och meddelanden. Returvärdet är noll. Utom när felaktiga kommandoradsflaggor används.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ta bort byteordningsmarkering (Byte Order Mark, BOM). Skriv inte en BOM i utfilen. Detta är standardbeteende vid konvertering av Unix-radbrytningar. Se vidare flaggan <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Hoppa över binära filer (standard).</p>
|
||||
|
||||
<p>Binärfiler hoppas över för att undvika oavsiktliga misstag. Var medveten om att detektering av binärfiler inte är 100% säker. Infiler genomsöks efter binära symboler som typiskt inte återfinns i textfiler. Det är möjligt att en binärfil enbart innehåller texttecken. En sådan binärfil kommer oavsiktligt att ses som en textfil.</p>
|
||||
|
||||
<p>By default, no error is returned when a binary file is skipped. When the <code>--error-binary</code> option is used, an error is returned.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Antag att infilsformatet är UTF-16LE.</p>
|
||||
|
||||
<p>När det finns en byteordningsmarkering (Byte Order Mark) i infilen så har BOM:en högre prioritet än denna flagga.</p>
|
||||
|
||||
<p>När du har gjort fel antagande (infilen var inte i UTF-16LE-format) och konverteringens lyckas, kommer du att få en UTF-8 utfil med felaktig text. Du kan göra denna konvertering ogjord med iconv(1) genom att konvertera UTF-8 utfilen tillbaka till UTF-16LE. Detta kommer att återskapa originalfilen.</p>
|
||||
|
||||
<p>Antagandet om UTF-16LE fungerar som ett <i>konverteringsläge</i>. Genom att växla till standard <i>ascii</i>-läget kommer UTF-16LE antagandet att stängas av.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Antag att infilsformatet är UTF-16BE.</p>
|
||||
|
||||
<p>Denna flagga fungerar på samma sätt som flaggan <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa utförliga meddelanden. Extra information visas om byteordningsmarkeringar och antalet konverterade radbrytningar.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Följ symboliska länkar och konvertera målen.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Ersätt symboliska länkar med konverterade filer (originalmålfilerna förblir oförändrade).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Behåll symboliska länkar och mål oförändrade (standard).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Visa versionsinformation och avsluta.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MAC-L-GE">MAC-LÄGE</h1>
|
||||
|
||||
<p>Som standard konverteras radbrytningar från DOS till Unix och vice versa. Mac-radbrytningar konverteras inte.</p>
|
||||
|
||||
<p>I Mac-läge konverteras radbrytningar från Mac till Unix och vice versa. DOS-radbrytningar ändras ej.</p>
|
||||
|
||||
<p>För att köra i Mac-läge använd kommandoradsflaggan <code>-c mac</code> eller använd kommandona <code>mac2unix</code> eller <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="KONVERTERINGSL-GEN">KONVERTERINGSLÄGEN</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Detta är standardkonverteringsläget. Detta läge används för att konvertera ASCII och ASCII-kompatibla kodade filer, så som UTF-8. Att aktiveras <b>ascii</b>-läge inaktiverar <b>7bit</b>- och <b>iso</b>-läge.</p>
|
||||
|
||||
<p>Om dos2unix har UTF-16 stöd kommer UTF-16-kodade filer att konverteras till kodningen för den aktuella lokalen på POSIX-sytstem och till UTF-8 på Windows. Aktivering av <b>ascii</b>-läget inaktiverar flaggan för att behålla UTF-16-kodning (<code>-u</code>) och flaggorna för att anta UTF-16 indata (<code>-ul</code> och <code>-ub</code>). För att se om dos2unix har UTF-16-stöd skriv <code>dox2unix -V</code>, se också avsnittet UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>I detta läge konverteras alla 8-bitars icke-ASCII tecken (med värden från 128 till 255) till ett 7-bitars blanksteg.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Tecken konverteras mellan DOS teckenuppsättning (teckentabell) och ISO teckenuppsättning ISO-8859-1 (Latin-1) på Unix. DOS tecken utan motsvarande ISO-8859-1 tecken, för vilka konvertering är omöjligt, kommer att ersättas med en punkt. Detsamma gäller för ISO-8859-1 tecken utan motsvarighet i DOS.</p>
|
||||
|
||||
<p>När enbart flaggan <code>-iso</code> används kommer dos2unix att försöka avgöra den aktiva teckentabellen. När detta inte är möjligt kommer dos2unix att använda standardteckentabellen CP437, vilken huvudsakligen används i USA. För att tvinga en specifik teckentabell använd flaggorna <code>-437</code> (USA), <code>-850</code> (Västeuropeisk), <code>-860</code> (Portugisisk), <code>-863</code> (Fransk-kanadensisk) eller <code>-865</code> (Nordisk). Det finns också stöd för Windows-teckentabell CP-1252 (Västeuropeisk) via flaggan <code>-1252</code>. För andra teckentabeller använd dos2unix i kombination med iconv(1). iconv kan konvertera mellan en lång lista av teckenkodningar.</p>
|
||||
|
||||
<p>Använd aldrig ISO-konvertering på Unicode-textfiler. Det kommer att korrumpera UTF-8-kodade filer.</p>
|
||||
|
||||
<p>Några exempel:</p>
|
||||
|
||||
<p>Konvertera från DOS standardteckentabell till Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från DOS CP850 till Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Windows CP1252 till Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Windows CP1252 till Unix UTF-8 (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix Latin-1 till DOS-standardteckentabell:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix Latin-1 till DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix Latin-1 till Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix UTF-8 (Unicode) till Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > ut.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="Kodningar">Kodningar</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="Konvertering">Konvertering</h2>
|
||||
|
||||
<p>Unicode-textfiler kan ha DOS, Unix eller Mac-radbrytningar precis som ASCII-textfiler.</p>
|
||||
|
||||
<p>Alla versioner av dos2unix och unix2dos kan konvertera UTF-8-kodade filer, eftersom UTF-8 designades för bakåtkompatibilitet med ASCII.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Under Unix/Linux kommer UTF-16-kodade filer att konverteras till lokalens teckenkodning. Använd kommandot locale(1) för att ta reda på vilken lokalens teckenkodning är. När konvertering inte är möjlig kommer ett konverteringsfel att inträffa och filen kommer att hoppas över.</p>
|
||||
|
||||
<p>Under Windows konverteras UTF-16-filer som standard till UTF-8. UTF-8-formaterade textfiler har bra stöd både under Windows och Unix/Linux.</p>
|
||||
|
||||
<p>UTF-16- och UTF-8-kodning är fullt kompatibla, ingen text kommer att gå förlorad i konverteringen. När ett UTF-16 till UTF-8-konverteringsfel uppstår, till exempel när infilen i UTF-16-format innehåller ett fel, kommer att filen att hoppas över.</p>
|
||||
|
||||
<p>När flaggan <code>-u</code> används kommer utfilen att skrivas med samma UTF-16-kodning som infilen. Flaggan <code>-u</code> förhindrar konvertering till UTF-8.</p>
|
||||
|
||||
<p>dos2unix och unix2dos har ingen flagga för att konvertera UTF-8-filer till UTF-16.</p>
|
||||
|
||||
<p>ISO- och 7-bitarslägeskonvertering fungerar inte på UTF-16-filer.</p>
|
||||
|
||||
<h2 id="Byteordningsmarkering-Byte-Order-Mark">Byteordningsmarkering (Byte Order Mark)</h2>
|
||||
|
||||
<p>I Windows har Unicode-textfiler typiskt en byteordningsmarkering (Byte Order Mark, BOM) eftersom många Windows-program (inklusive Notepad) lägger till BOM:ar som standard. Se även <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>I Unix har Unicode-textfiler typiskt ingen BOM. Filer antas vara kodade i den lokala teckenuppsättningen.</p>
|
||||
|
||||
<p>dos2unix kan bara detektera om en fil är i UTF-16-format om filen har en BOM. När en UTF-16-fil inte har en BOM så kommer dos2unix att de filen som en binärfil.</p>
|
||||
|
||||
<p>Använd flaggan <code>-ul</code> eller <code>-ub</code> för att konvertera en UTF-16-fil utan BOM.</p>
|
||||
|
||||
<p>dos2unix skriver som standard ingen BOM i utfilen. Med flaggan <code>-b</code> kommer dos2unix att skriva en BOM när infilen har en BOM.</p>
|
||||
|
||||
<p>unix2dos skriver som standard en BOM i utfilen när infilen har en BOM. Använd flaggan <code>-r</code> för att ta bort BOM:en.</p>
|
||||
|
||||
<p>dos2unix och unix2dos skriver alltid en BOM när flaggan <code>-m</code> används.</p>
|
||||
|
||||
<h2 id="Unicode-filnamn-under-Windows">Unicode-filnamn under Windows</h2>
|
||||
|
||||
<p>dos2unix har valfritt stöd för läsning och skrivning av Unicode-filnamn i Windows kommandoprompt. Detta innebär att dos2unix kan öppna filer som har tecken i sina namn som inte är en del av systemets standard ANSI-teckentabell. För att se om dos2unix för Windows byggdes med stöd för Unicode-filnamn skriv <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Det finns en del problem med att visa Unicode-filnamn i en Windows-konsol. Se vidare flaggan <code>-D</code>, <code>--display-enc</code>. Filnamnen kan visas felaktigt i konsolen, men filerna som skrivs kommer att ha de korrekta namnen.</p>
|
||||
|
||||
<h2 id="Unicode-exempel">Unicode-exempel</h2>
|
||||
|
||||
<p>Konvertera från Windows UTF-16 (med BOM) till Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Windows UTF-16LE (utan BOM) till Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix UTF-8 till Windows UTF-8 med BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt ut.txt</code></pre>
|
||||
|
||||
<p>Konvertera från Unix UTF-8 till Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > ut.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 är en standard från Kinesiska regeringen. En obligatorisk delmängd av standarden GB18030 krävs officiellt för alla programvaruprodukter som säljs i Kina. Se vidare <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>GB18030 är fullständigt kompatibel med Unicode och kan anses vara ett överföringsformat för unicode. Precis som UTF-8 är GB18030 kompatibel med ASCII. GB18030 är också kompatibel med Windows-teckentabell 936, också känd som GBK.</p>
|
||||
|
||||
<p>Under Unix/Linux kommer UTF-16-filer att konverteras till GB18030 när lokalens teckenkodning är inställd på GB18030. Notera att detta endast kommer att fungera om lokalen har stöd i systemet. Använd kommandot <code>locale -a</code> för att få en lista över de lokaler som stöds.</p>
|
||||
|
||||
<p>Under Windows måste du använda flaggan <code>-gb</code> för att konvertera UTF-16-filer till GB18030.</p>
|
||||
|
||||
<p>GB18030-kodade filer kan ha en byteordningsmarkering, precis som Unicode-filer.</p>
|
||||
|
||||
<h1 id="EXEMPEL">EXEMPEL</h1>
|
||||
|
||||
<p>Läsa inmatning från “stdin“ och skriv utmatning till “stdout“:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Konvertera och ersätta a.txt. Konvertera och ersätt b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Konvertera och ersätt a.txt i ascii-konverteringsläge:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Konvertera och ersätt a.txt i ascii-konverteringsläge, konvertera och ersätt b.txt i 7bit-konverteringsläge:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Konvertera a.txt från Mac- till Unix-format:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Konvertera a.txt från Unix- till Mac-format:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Konvertera och ersätt a.txt medan originalet tidsstämpel behålls:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Konvertera a.txt och skriv till e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Konvertera a.txt och skriv till e.txt, låt e.txt behålla tidsstämpeln från a.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Konvertera och ersätt a.txt, konvertera b.txt och skriv till e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Konvertera c.txt och skriv till e.txt, konvertera och ersätt a.txt, konvertera och ersätt b.txt, konvertera d.txt och skriv till f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="REKURSIV-KONVERTERING">REKURSIV KONVERTERING</h1>
|
||||
|
||||
<p>I ett Unix-skal kan kommandona find(1) och xargs(1) användas för att köra dos2unix rekursivt över alla textfiler i ett katalogträd. För att till exempel konvertera alla .txt-filer i katalogträdet under den aktuella katalogen skriv:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Flaggan <code>-print0</code> till find(1) och motsvarande flagga <code>-0</code> till xargs(1) behövs när det finns filer med mellanslag eller citationstecken i namnet. Annars kan dessa flaggor utelämnas. Ett annat alternativ är att användas find(1) med flaggan <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>I en Windows-kommandoprompt kan följande kommando användas:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>PowerShell-användare kan använda följande kommando i Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="LOKALISERING">LOKALISERING</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Det primära språket väljs med miljövariabeln LANG. LANG-variabeln består av flera delas. Den första delen är språkkoden i gemener. Den andra delen är valfri och utgör landskoden i versaler, föregången av ett understreck. Det finns också en valfri tredje del: teckenkodning, föregången av en punkt. Ett par exempel för skal av POSIX-standard-typ:</p>
|
||||
|
||||
<pre><code>export LANG=nl Nederländska
|
||||
export LANG=nl_NL Nederländska, Nederländerna
|
||||
export LANG=nl_BE Nederländska, Belgien
|
||||
export LANG=es_ES Spanska, Spanien
|
||||
export LANG=es_MX Spanska, Mexiko
|
||||
export LANG=en_US.iso88591 Engelska, USA, Latin-1-kodning
|
||||
export LANG=en_GB.UTF-8 Engelska, UK, UTF-8-kodning</code></pre>
|
||||
|
||||
<p>För en fullständig lista över språk och landskoder se vidare i gettext-manualen: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>På Unix-system kan du använda kommando locale(1) för att få lokal-specifik information.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Med miljövariabeln LANGUAGE kan du ange en prioritetslista över språk, separerade med kolon. dos2unix kommer att ge företräde till LANGAUGE över LANG. Exempelvis först nederländska och sedan tyska: <code>LANGUAGE=nl:de</code>. Du måste först ha aktiverat lokalisering, genom att sätta LANG (eller LC_ALL) till ett värde annat än “C“, innan du kan använda en prioritetslista för språk via LANGUAGE-variabeln. Se vidare i gettext-manualen: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Om du väljer ett språk som inte är tillgänglig kommer du att få engelska meddelanden som standard.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Med miljövariabeln DOS2UNIX_LOCALEDIR kan LOCALEDIR som ställts in vid kompilering åsidosättas. LOCALEDIR används för att hitta språkfiler. Standardvärdet för GNU-program är <code>/usr/local/share/locale</code>. Flaggan <b>--version</b> kommer att visa vilken LOCALEDIR som används.</p>
|
||||
|
||||
<p>Exempel (POSIX-skal):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="RETURV-RDE">RETURVÄRDE</h1>
|
||||
|
||||
<p>Om allt går bra kommer noll att returneras. När ett systemfel uppstår kommer det senaste systemfelet att returneras. För andra fel kommer 1 att returneras.</p>
|
||||
|
||||
<p>Returvärdet är alltid noll i tyst läge, utom när felaktiga kommandoradsflaggor används.</p>
|
||||
|
||||
<h1 id="STANDARDER">STANDARDER</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="F-RFATTARE">FÖRFATTARE</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (mac2unix-läge) - <wuebben@kde.org>, Christian Wurll (lägg till en extra radbrytning) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (upphovsman)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge-sida: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="SE-VEN">SE ÄVEN</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
833
Agent-Windows/OGP64/usr/share/doc/dos2unix/sv/dos2unix.txt
Normal file
833
Agent-Windows/OGP64/usr/share/doc/dos2unix/sv/dos2unix.txt
Normal file
|
|
@ -0,0 +1,833 @@
|
|||
NAMN
|
||||
dos2unix - konverterare för textfilsformat från DOS/Mac till Unix och
|
||||
vice versa
|
||||
|
||||
SYNOPSIS
|
||||
dos2unix [flaggor] [FIL …] [-n INFIL UTFIL …]
|
||||
unix2dos [flaggor] [FIL …] [-n INFIL UTFIL …]
|
||||
|
||||
BESKRIVNING
|
||||
Paketet dos2unix inkluderar verktygen "dos2unix" och "unix2dos" som
|
||||
konverterar oformaterade textfiler i DOS- eller Mac-format till
|
||||
Unix-format och vice versa.
|
||||
|
||||
Textfiler i DOS/Windows har en radbrytning, också känd som nyrad, som är
|
||||
en kombination av två tecken: vagnretur (Carriage Return, CR) åtföljt av
|
||||
radmatning (Line Feed, LF). Textfiler i Unix har en radbrytning som är
|
||||
ett enda tecken: radmatning (Line Feed, LF). Textfiler för Mac, innan
|
||||
Mac OS X, hade en radbrytning som var en enda vagnretur (Carriage
|
||||
Return, CR). Numera använder Mac OS radbrytning i Unix-stil (LF).
|
||||
|
||||
Förutom radbrytningar så kan dos2unix också konvertera filers kodning.
|
||||
Några DOS-teckentabeller kan konverteras till Unix Latin-1. Och filer
|
||||
som använder Windows Unicode (UTF-16) kan konverteras till Unix Unicode
|
||||
(UTF-8).
|
||||
|
||||
Binära filer hoppas över automatiskt, om inte konvertering tvingas.
|
||||
|
||||
Kataloger och FIFOs och andra filer som inte är vanliga filer hoppas
|
||||
över automatiskt.
|
||||
|
||||
Symboliska länkar och deras mål förblir oförändrade som standard.
|
||||
Symboliska länkar kan valfritt bli ersatta eller så kan utmatningen
|
||||
skrivas till målet för den symboliska länken. På Windows saknas stöd för
|
||||
att skriva till målet för en symbolisk länk.
|
||||
|
||||
dos2unix modellerades efter dos2unix från SunOS/Solaris. Det finns en
|
||||
viktig skillnad gentemot originalversionen för SunOS/Solaris. Denna
|
||||
versionen gör som standard konverteringen på plats (gammalfilsläge),
|
||||
medan originalversionen från SunOS/Solaris bara hade stöd för parad
|
||||
konvertering (nyfilsläge). Se vidare flaggorna "-o" och "-n". En annan
|
||||
skillnad är att SunOS/Solaris-versionen som standard använder
|
||||
*iso*-lägeskonvertering medan denna version som standard använder
|
||||
*ascii*-lägeskonvertering.
|
||||
|
||||
FLAGGOR
|
||||
-- Behandla alla efterföljande flaggor som filnamn. Använd denna flagga
|
||||
om du vill konvertera filer vars namn börjar med bindestreck. För
|
||||
att till exempel konvertera en fil med namnet “-foo“ kan du använda
|
||||
detta kommando:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Eller i nyfilsläge:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
Tillåt ändring av ägarskap för fil i gammalt filläge.
|
||||
|
||||
När denna flagga används, kommer konverteringen inte att avbrytas
|
||||
när användar- och/eller gruppägarskap för originalfilen inte kan
|
||||
bevaras i gammalt filläget. Konverteringen kommer att fortsätta och
|
||||
den konverterade filen kommer att få samma nya ägarskap som om den
|
||||
konverterades i nyfilsläge. Se också flaggorna "-o" och "-n". Denna
|
||||
flagga är endast tillgänglig om dos2unix har stöd för att bevara
|
||||
användar- och gruppägarskap för filer.
|
||||
|
||||
-ascii
|
||||
Standardkonverteringsläge. Se vidare stycket KONVERTERINGSLÄGEN.
|
||||
|
||||
-iso
|
||||
Konvertering mellan DOS- och ISO-8859-1-teckentabeller. Se vidare
|
||||
stycket KONVERTERINGSLÄGEN.
|
||||
|
||||
-1252
|
||||
Använd Windows-teckentabell 1252 (Västeuropeisk).
|
||||
|
||||
-437
|
||||
Använd DOS-teckentabell 437 (USA). Detta är standardteckentabellen
|
||||
som används för ISO-konvertering.
|
||||
|
||||
-850
|
||||
Använd DOS-teckentabell 850 (Västeuropeisk).
|
||||
|
||||
-860
|
||||
Använd DOS-teckentabell 860 (Portugisisk).
|
||||
|
||||
-863
|
||||
Använd DOS-teckentabell 863 (Fransk-kanadensisk).
|
||||
|
||||
-865
|
||||
Använd DOS-teckentabell 865 (Nordisk).
|
||||
|
||||
-7 Konvertera 8-bitars tecken till 7-bitars blanksteg.
|
||||
|
||||
-b, --keep-bom
|
||||
Behåll byteordningsmarkering (Byte Order Mark, BOM). Om infilen har
|
||||
en BOM, skriv en BOM i utfilen. Detta är standardbeteendet vid
|
||||
konvertering av DOS-radbrytningar. Se vidare flaggan "-r".
|
||||
|
||||
-c, --convmode KONVERTERINGSLÄGE
|
||||
Ställer in konverteringsläge. Där KONVERTERINGSLÄGE är en av:
|
||||
*ascii*, *7bit*, *iso*, *mac* där ascii är standard.
|
||||
|
||||
-D, --display-enc KODNING
|
||||
Ställ in kodning för visad text. Där KODNING är en av: *ansi*,
|
||||
*unicode*, *unicodebom*, *utf8*, *utf8bom* där ansi är
|
||||
standardvalet.
|
||||
|
||||
Denna flagga finns bara tillgänglig i dos2unix för Windows med stöd
|
||||
för Unicode-filnamn. Denna flagga har ingen effekt på själva
|
||||
filnamnen som läses och skrivs, bara på hur de visas.
|
||||
|
||||
Det finns flera metoder för att visa text i en Windows-konsol
|
||||
baserad på vilken kodning texten har. De har alla för- och
|
||||
nackdelar.
|
||||
|
||||
ansi
|
||||
dos2unix standardmetod är att använda ANSI-kodad text. Fördelen
|
||||
är att den är bakåtkompatibel. Det fungerar med raster- och
|
||||
TrueType-teckensnitt. I vissa regioner kan du behöva ändra den
|
||||
aktiva DOS OEM-teckentabellen till Windows-systemets
|
||||
ANSI-teckentabell genom att använda kommandot "chcp", eftersom
|
||||
dos2unix använder Windows-systemets teckentabell.
|
||||
|
||||
Nackdelen med ansi är att internationella filnamn med tecken som
|
||||
inte finns i systemets standardteckentabell inte visas korrekt.
|
||||
Du kommer att se frågetecken, eller en felaktig symbol istället.
|
||||
När du inte arbetar med utländska filnamn är denna metoden OK.
|
||||
|
||||
unicode, unicodebom
|
||||
Fördelen med unicode-kodning (Windows-namnet för UTF-16) är att
|
||||
text vanligtvis visas korrekt. Det finns inget behov av att
|
||||
ändra den aktiva teckentabellen. Du kan behöva ställa in
|
||||
konsolens teckensnitt till ett TrueType-teckensnitt för att få
|
||||
internationella tecken att visas korrekt. När ett tecken inte
|
||||
finns inkluderat i TrueType-teckensnittet kommer du vanligtvis
|
||||
att se en liten ruta, ibland med ett frågetecken inuti.
|
||||
|
||||
När du använder ConEmu-konsolen kommer all text att visas
|
||||
korrekt eftersom ConEmu automatiskt väljer ett bra teckensnitt.
|
||||
|
||||
Nackdelen med unicode är att den inte är kompatibel med ASCII.
|
||||
Utmatningen är inte lätt att hantera när du omdirigerar den till
|
||||
ett annat program eller en fil.
|
||||
|
||||
När metod "unicodebom" används kommer Unicode-texten att föregås
|
||||
av en BOM (byteordningsmarkering, Byte Order Mark). En BOM krävs
|
||||
för korrekt omdirigering eller rörledning i PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
Fördelen med utf8 är att den är kompatibel med ASCII. Du måste
|
||||
ställa in konsolens teckensnitt till ett TrueType-teckensnitt.
|
||||
Med ett TrueType-teckensnitt kommer text att visas på liknande
|
||||
sätt som med "unicode"-kodningen.
|
||||
|
||||
Nackdelen är att när du använder standardrasterteckensnittet
|
||||
kommer alla icke-ASCII tecken att visas fel. Inte enbart
|
||||
unicode-filnamn, utan också översatta meddelanden kommer att bli
|
||||
oläsbara. Under Windows som konfigurerats för Östasien kan man
|
||||
komma att se många blinkningar i konsolen när meddelanden visas.
|
||||
|
||||
I ConEmu-konsolen fungerar utf8-kodningsmetoden väl.
|
||||
|
||||
När metod "utf8bom" används kommer UTF-8-texten att föregås av
|
||||
en BOM (byteordningsmarkering, Byte Order Mark). En BOM krävs
|
||||
för korrekt omdirigering eller rörledning i PowerShell.
|
||||
|
||||
Standardkodningen kan ändras via miljövariabeln DOS2UNIX_DISPLAY_ENC
|
||||
genom att sätta den till "unicode", "unicodebom", "utf8" or
|
||||
"utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Lägg till en radbrytning på sista raden om det inte finns någon.
|
||||
Detta fungerar för alla konverteringar.
|
||||
|
||||
En fil konverterad från DOS- till Unix-format kan sakna en
|
||||
radbrytning på sista raden. Det finns textredigerare som skriver
|
||||
textfiler utan en radbrytning på den sista raden. Vissa Unix-program
|
||||
har problem med att behandla dessa filer, då POSIX-standarden
|
||||
definierar det som att varje rad i en textfil måste har ett
|
||||
avslutande nyradstecken. Att konkatenera filer kan till exempel ge
|
||||
oväntat resultat.
|
||||
|
||||
--error-binary
|
||||
Return an error if a binary file is skipped.
|
||||
|
||||
-f, --force
|
||||
Tvinga konvertering av binära filer.
|
||||
|
||||
-gb, --gb18030
|
||||
Under Windows konverteras UTF-16-filer som standard till UTF-8,
|
||||
oavsett vilken lokalinställning som är gjord. Använd denna flagga
|
||||
för att konvertera UTF-16-filer till GB18030. Denna flagga finns
|
||||
bara tillgänglig i Windows. Se vidare i avsnittet GB18030.
|
||||
|
||||
-h, --help
|
||||
Visa hjälptext och avsluta.
|
||||
|
||||
-i[FLAGGOR], --info[=FLAGGOR] FIL ...
|
||||
Visa filinformation. Ingen konvertering görs.
|
||||
|
||||
Följande information skrivs ut, i denna ordningen: antal
|
||||
DOS-radbrytningar, antal Unix-radbrytningar, antal
|
||||
Mac-radbrytningar, byteordningsmarkeringen, text eller binär,
|
||||
filnamn.
|
||||
|
||||
Exempelutmatning:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binär dos2unix.exe
|
||||
|
||||
Notera att en binärfil ibland kan misstas för en textfil. Se vidare
|
||||
flaggan "-s".
|
||||
|
||||
Om dessutom flaggan "-e" eller "--add-eol" används så kommer även
|
||||
den radbrytning som används på sista raden att skrivas ut, eller
|
||||
"noeol" om det inte finns någon.
|
||||
|
||||
Exempelutmatning:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Extra flaggor kan användas valfritt för att ändra utmatningen. En
|
||||
eller fler flaggor kan läggas till.
|
||||
|
||||
0 Skriv ut filinformationsraderna följt av ett null-tecken
|
||||
istället för ett nyradstecken. Detta möjliggör korrekt tolkning
|
||||
av filnamn med blanksteg eller citationstecken när c-flaggan
|
||||
används. Använd denna flagga i kombination med xargs(1):s flagga
|
||||
-0 eller "--null".
|
||||
|
||||
d Skriv ut antal DOS-radbrytningar.
|
||||
|
||||
u Skriv ut antal Unix-radbrytningar.
|
||||
|
||||
m Skriv ut antal Mac-radbrytningar.
|
||||
|
||||
b Skriv ut byteordningsmarkeringen.
|
||||
|
||||
t Skriv ut om filen är text eller binär.
|
||||
|
||||
e Skriv ut radbrytningstypen på sista raden, eller "noeol" om det
|
||||
inte finns någon.
|
||||
|
||||
c Skriv bara ut filerna som skulle ha konverterats.
|
||||
|
||||
Med "c"-flaggan kommer dos2unix att skriva ut filerna som
|
||||
innehåller DOS-radbrytningar, unix2dos kommer bara att skriva ut
|
||||
filnamn som har Unix-radbrytningar.
|
||||
|
||||
Om dessutom flaggan "-e" eller "--add-eol" används så kommer
|
||||
även filer som saknar en radbrytning på sista raden att skrivas
|
||||
ut.
|
||||
|
||||
h Skriv ut rubrik.
|
||||
|
||||
p Visa filnamn utan sökväg.
|
||||
|
||||
Exempel:
|
||||
|
||||
Visa information för alla *.txt-filer:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Visa bara antalet DOS-radbrytningar och Unix-radbrytningar:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Visa bara byteordningsmarkeringen:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Lista filerna som har DOS-radbrytningar:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Lista filerna som har Unix-radbrytningar:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Lista filerna som har DOS-radbrytningar eller saknar en radbrytning
|
||||
på sista raden:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Konvertera endast filer som har DOS-radbrytningar och lämna övriga
|
||||
filer orörda:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Hitta textfiler som har DOS-radbrytningar:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Behåll infilens datumstämpel för utfilen.
|
||||
|
||||
-L, --license
|
||||
Visa programmets licens.
|
||||
|
||||
-l, --newline
|
||||
Lägg till ytterligare nyrad.
|
||||
|
||||
dos2unix: Endast DOS-radbrytningar ändras till två
|
||||
Unix-radbrytningar. I Mac-läge ändras endast Mac-radbrytningar till
|
||||
två Unix-radbrytningar.
|
||||
|
||||
unix2dos: Endast Unix-radbrytningar ändras till två
|
||||
DOS-radbrytningar. I Mac-läge ändras Unix-radbrytningar till två
|
||||
Mac-radbrytningar.
|
||||
|
||||
-m, --add-bom
|
||||
Skriv en byteordningsmarkering (Byte Order Mark, BOM) i utfilen. Som
|
||||
standard skrivs en UTF-8 BOM.
|
||||
|
||||
När infilen är UTF-16, och flaggan "-u" används, kommer en UTF-16
|
||||
BOM att skrivas.
|
||||
|
||||
Använd aldrig denna flagga när kodningen för utmatning är något
|
||||
annat än UTF-8, UTF-16 eller GB18030. Se vidare i avsnittet UNICODE.
|
||||
|
||||
-n, --newfile INFIL UTFIL …
|
||||
Nyfilsläge. Konvertera filen INFIL och skriv utfilen UTFIL.
|
||||
Filnamnen måste ange i par och jokertecken i namnen ska *inte*
|
||||
användas annars *kommer* du att förlora filer.
|
||||
|
||||
Användaren som påbörjar konverteringen i nyfilsläge (parat läge)
|
||||
kommer att bli ägaren till den konverterade filen.
|
||||
Läs-/skrivbehörigheter för den nya filen kommer att vara samma
|
||||
behörigheter som för originalfilen minus umask(1) för användaren som
|
||||
kör konverteringen.
|
||||
|
||||
--no-allow-chown
|
||||
Tillåt inte ändring av ägarskap i gammalt filläge (standard)
|
||||
|
||||
Avbryt konvertering när användar- och/eller gruppägarskap för
|
||||
originalfilen inte kan bevaras i gammalt filläge. Se också flaggorna
|
||||
"-o" och "-n". Denna flagga är endast tillgänglig om dos2unix har
|
||||
stöd för att bevara användar- och gruppägarskap för filer.
|
||||
|
||||
--no-add-eol
|
||||
Do not add a line break to the last line if there isn't one
|
||||
(default).
|
||||
|
||||
--no-error-binary
|
||||
Do not return an error if a binary file is skipped (default).
|
||||
|
||||
-O, --to-stdout
|
||||
Skriv till standard ut som ett Unix-filter. Använd flaggan "-o" för
|
||||
att återgå till det gamla (på-plats) filläget.
|
||||
|
||||
Kombinerat med flaggan "-e" kan filer konkateneras korrekt. Inga
|
||||
sammanfogade sista och första rader, och inga Unicode
|
||||
byteordningsmarkeringar i mitten på den konkatenerade filen.
|
||||
Exempel:
|
||||
|
||||
dos2unix -e -O fil1.txt fil2.txt > ut.txt
|
||||
|
||||
-o, --oldfile FIL …
|
||||
Gammalfilsläge. Konvertera filen FIL och skriv över den med
|
||||
utmatningen. Programmet kör i detta läge som standard. Jokertecken i
|
||||
filnamn får användas.
|
||||
|
||||
I gammalfilsläge (på-plats läge) kommer den konverterade filen att
|
||||
få samma ägare, grupp samt läs-/skrivbehörigheter som originalfilen.
|
||||
Även då filen konverteras av en annan användare som har
|
||||
skrivbehörighet för filen (t.ex. användaren root). Konverteringen
|
||||
kommer att avbrytas när det inte är möjligt att bevara
|
||||
originalvärdena. Byte av ägare skulle kunna innebära att
|
||||
originalägaren inte längre kan läsa filen. Byte av grupp skulle
|
||||
kunna vara en säkerhetsrisk, filen skulle kunna bli läsbar för
|
||||
användare som den inte är avsedd för. Stöd för bevarande av ägare,
|
||||
grupp och läs-/skrivbehörigheter finns bara i Unix.
|
||||
|
||||
För att kontrollera om dos2unix har stöd för att bevara användar-
|
||||
och gruppägarskap för filer skriv "dosunix -V".
|
||||
|
||||
Konvertering görs alltid via en temporärfil. När ett fel inträffar
|
||||
halvvägs i konverteringen tas den temporära filen bort och
|
||||
originalfilen finns kvar intakt. Om konverteringen är framgångsrik
|
||||
kommer originalfilen att ersättas med temporärfilen. Du kanske har
|
||||
skrivrättigheter till originalfilen men inte rättigheter att ställa
|
||||
in samma användar- och/eller grupprättighetsegenskaper på
|
||||
temporärfilen som originalfilen har. Detta innebär att du inte kan
|
||||
bevara användar- och/eller gruppägarskapet för originalfilen. I
|
||||
detta fall kan du använda flaggan "--allow-chown" för att fortsätta
|
||||
konverteringen:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
Ett annat alternativ är att använda nyfilsläge:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
Fördelen med flaggan "--allow-chown" är att du kan använda
|
||||
jokertecken och att ägarskapsegenskaper om möjligt kommer att
|
||||
bevaras.
|
||||
|
||||
-q, --quiet
|
||||
Tyst drift. Undertryck alla varningar och meddelanden. Returvärdet
|
||||
är noll. Utom när felaktiga kommandoradsflaggor används.
|
||||
|
||||
-r, --remove-bom
|
||||
Ta bort byteordningsmarkering (Byte Order Mark, BOM). Skriv inte en
|
||||
BOM i utfilen. Detta är standardbeteende vid konvertering av
|
||||
Unix-radbrytningar. Se vidare flaggan "-b".
|
||||
|
||||
-s, --safe
|
||||
Hoppa över binära filer (standard).
|
||||
|
||||
Binärfiler hoppas över för att undvika oavsiktliga misstag. Var
|
||||
medveten om att detektering av binärfiler inte är 100% säker.
|
||||
Infiler genomsöks efter binära symboler som typiskt inte återfinns i
|
||||
textfiler. Det är möjligt att en binärfil enbart innehåller
|
||||
texttecken. En sådan binärfil kommer oavsiktligt att ses som en
|
||||
textfil.
|
||||
|
||||
By default, no error is returned when a binary file is skipped. When
|
||||
the "--error-binary" option is used, an error is returned.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Antag att infilsformatet är UTF-16LE.
|
||||
|
||||
När det finns en byteordningsmarkering (Byte Order Mark) i infilen
|
||||
så har BOM:en högre prioritet än denna flagga.
|
||||
|
||||
När du har gjort fel antagande (infilen var inte i UTF-16LE-format)
|
||||
och konverteringens lyckas, kommer du att få en UTF-8 utfil med
|
||||
felaktig text. Du kan göra denna konvertering ogjord med iconv(1)
|
||||
genom att konvertera UTF-8 utfilen tillbaka till UTF-16LE. Detta
|
||||
kommer att återskapa originalfilen.
|
||||
|
||||
Antagandet om UTF-16LE fungerar som ett *konverteringsläge*. Genom
|
||||
att växla till standard *ascii*-läget kommer UTF-16LE antagandet att
|
||||
stängas av.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Antag att infilsformatet är UTF-16BE.
|
||||
|
||||
Denna flagga fungerar på samma sätt som flaggan "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Visa utförliga meddelanden. Extra information visas om
|
||||
byteordningsmarkeringar och antalet konverterade radbrytningar.
|
||||
|
||||
-F, --follow-symlink
|
||||
Följ symboliska länkar och konvertera målen.
|
||||
|
||||
-R, --replace-symlink
|
||||
Ersätt symboliska länkar med konverterade filer (originalmålfilerna
|
||||
förblir oförändrade).
|
||||
|
||||
-S, --skip-symlink
|
||||
Behåll symboliska länkar och mål oförändrade (standard).
|
||||
|
||||
-V, --version
|
||||
Visa versionsinformation och avsluta.
|
||||
|
||||
MAC-LÄGE
|
||||
Som standard konverteras radbrytningar från DOS till Unix och vice
|
||||
versa. Mac-radbrytningar konverteras inte.
|
||||
|
||||
I Mac-läge konverteras radbrytningar från Mac till Unix och vice versa.
|
||||
DOS-radbrytningar ändras ej.
|
||||
|
||||
För att köra i Mac-läge använd kommandoradsflaggan "-c mac" eller använd
|
||||
kommandona "mac2unix" eller "unix2mac".
|
||||
|
||||
KONVERTERINGSLÄGEN
|
||||
ascii
|
||||
Detta är standardkonverteringsläget. Detta läge används för att
|
||||
konvertera ASCII och ASCII-kompatibla kodade filer, så som UTF-8.
|
||||
Att aktiveras ascii-läge inaktiverar 7bit- och iso-läge.
|
||||
|
||||
Om dos2unix har UTF-16 stöd kommer UTF-16-kodade filer att
|
||||
konverteras till kodningen för den aktuella lokalen på POSIX-sytstem
|
||||
och till UTF-8 på Windows. Aktivering av ascii-läget inaktiverar
|
||||
flaggan för att behålla UTF-16-kodning ("-u") och flaggorna för att
|
||||
anta UTF-16 indata ("-ul" och "-ub"). För att se om dos2unix har
|
||||
UTF-16-stöd skriv "dox2unix -V", se också avsnittet UNICODE.
|
||||
|
||||
7bit
|
||||
I detta läge konverteras alla 8-bitars icke-ASCII tecken (med värden
|
||||
från 128 till 255) till ett 7-bitars blanksteg.
|
||||
|
||||
iso Tecken konverteras mellan DOS teckenuppsättning (teckentabell) och
|
||||
ISO teckenuppsättning ISO-8859-1 (Latin-1) på Unix. DOS tecken utan
|
||||
motsvarande ISO-8859-1 tecken, för vilka konvertering är omöjligt,
|
||||
kommer att ersättas med en punkt. Detsamma gäller för ISO-8859-1
|
||||
tecken utan motsvarighet i DOS.
|
||||
|
||||
När enbart flaggan "-iso" används kommer dos2unix att försöka avgöra
|
||||
den aktiva teckentabellen. När detta inte är möjligt kommer dos2unix
|
||||
att använda standardteckentabellen CP437, vilken huvudsakligen
|
||||
används i USA. För att tvinga en specifik teckentabell använd
|
||||
flaggorna -437 (USA), -850 (Västeuropeisk), -860 (Portugisisk), -863
|
||||
(Fransk-kanadensisk) eller -865 (Nordisk). Det finns också stöd för
|
||||
Windows-teckentabell CP-1252 (Västeuropeisk) via flaggan -1252. För
|
||||
andra teckentabeller använd dos2unix i kombination med iconv(1).
|
||||
iconv kan konvertera mellan en lång lista av teckenkodningar.
|
||||
|
||||
Använd aldrig ISO-konvertering på Unicode-textfiler. Det kommer att
|
||||
korrumpera UTF-8-kodade filer.
|
||||
|
||||
Några exempel:
|
||||
|
||||
Konvertera från DOS standardteckentabell till Unix Latin-1:
|
||||
|
||||
dos2unix -iso -n in.txt ut.txt
|
||||
|
||||
Konvertera från DOS CP850 till Unix Latin-1:
|
||||
|
||||
dos2unix -850 -n in.txt ut.txt
|
||||
|
||||
Konvertera från Windows CP1252 till Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n in.txt ut.txt
|
||||
|
||||
Konvertera från Windows CP1252 till Unix UTF-8 (Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > ut.txt
|
||||
|
||||
Konvertera från Unix Latin-1 till DOS-standardteckentabell:
|
||||
|
||||
unix2dos -iso -n in.txt ut.txt
|
||||
|
||||
Konvertera från Unix Latin-1 till DOS CP850:
|
||||
|
||||
unix2dos -850 -n in.txt ut.txt
|
||||
|
||||
Konvertera från Unix Latin-1 till Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n in.txt ut.txt
|
||||
|
||||
Konvertera från Unix UTF-8 (Unicode) till Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > ut.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Kodningar
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Konvertering
|
||||
Unicode-textfiler kan ha DOS, Unix eller Mac-radbrytningar precis som
|
||||
ASCII-textfiler.
|
||||
|
||||
Alla versioner av dos2unix och unix2dos kan konvertera UTF-8-kodade
|
||||
filer, eftersom UTF-8 designades för bakåtkompatibilitet med ASCII.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
Under Unix/Linux kommer UTF-16-kodade filer att konverteras till
|
||||
lokalens teckenkodning. Använd kommandot locale(1) för att ta reda på
|
||||
vilken lokalens teckenkodning är. När konvertering inte är möjlig kommer
|
||||
ett konverteringsfel att inträffa och filen kommer att hoppas över.
|
||||
|
||||
Under Windows konverteras UTF-16-filer som standard till UTF-8.
|
||||
UTF-8-formaterade textfiler har bra stöd både under Windows och
|
||||
Unix/Linux.
|
||||
|
||||
UTF-16- och UTF-8-kodning är fullt kompatibla, ingen text kommer att gå
|
||||
förlorad i konverteringen. När ett UTF-16 till UTF-8-konverteringsfel
|
||||
uppstår, till exempel när infilen i UTF-16-format innehåller ett fel,
|
||||
kommer att filen att hoppas över.
|
||||
|
||||
När flaggan "-u" används kommer utfilen att skrivas med samma
|
||||
UTF-16-kodning som infilen. Flaggan "-u" förhindrar konvertering till
|
||||
UTF-8.
|
||||
|
||||
dos2unix och unix2dos har ingen flagga för att konvertera UTF-8-filer
|
||||
till UTF-16.
|
||||
|
||||
ISO- och 7-bitarslägeskonvertering fungerar inte på UTF-16-filer.
|
||||
|
||||
Byteordningsmarkering (Byte Order Mark)
|
||||
I Windows har Unicode-textfiler typiskt en byteordningsmarkering (Byte
|
||||
Order Mark, BOM) eftersom många Windows-program (inklusive Notepad)
|
||||
lägger till BOM:ar som standard. Se även
|
||||
<https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
I Unix har Unicode-textfiler typiskt ingen BOM. Filer antas vara kodade
|
||||
i den lokala teckenuppsättningen.
|
||||
|
||||
dos2unix kan bara detektera om en fil är i UTF-16-format om filen har en
|
||||
BOM. När en UTF-16-fil inte har en BOM så kommer dos2unix att de filen
|
||||
som en binärfil.
|
||||
|
||||
Använd flaggan "-ul" eller "-ub" för att konvertera en UTF-16-fil utan
|
||||
BOM.
|
||||
|
||||
dos2unix skriver som standard ingen BOM i utfilen. Med flaggan "-b"
|
||||
kommer dos2unix att skriva en BOM när infilen har en BOM.
|
||||
|
||||
unix2dos skriver som standard en BOM i utfilen när infilen har en BOM.
|
||||
Använd flaggan "-r" för att ta bort BOM:en.
|
||||
|
||||
dos2unix och unix2dos skriver alltid en BOM när flaggan "-m" används.
|
||||
|
||||
Unicode-filnamn under Windows
|
||||
dos2unix har valfritt stöd för läsning och skrivning av Unicode-filnamn
|
||||
i Windows kommandoprompt. Detta innebär att dos2unix kan öppna filer som
|
||||
har tecken i sina namn som inte är en del av systemets standard
|
||||
ANSI-teckentabell. För att se om dos2unix för Windows byggdes med stöd
|
||||
för Unicode-filnamn skriv "dos2unix -V".
|
||||
|
||||
Det finns en del problem med att visa Unicode-filnamn i en
|
||||
Windows-konsol. Se vidare flaggan "-D", "--display-enc". Filnamnen kan
|
||||
visas felaktigt i konsolen, men filerna som skrivs kommer att ha de
|
||||
korrekta namnen.
|
||||
|
||||
Unicode-exempel
|
||||
Konvertera från Windows UTF-16 (med BOM) till Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt ut.txt
|
||||
|
||||
Konvertera från Windows UTF-16LE (utan BOM) till Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n in.txt ut.txt
|
||||
|
||||
Konvertera från Unix UTF-8 till Windows UTF-8 med BOM:
|
||||
|
||||
unix2dos -m -n in.txt ut.txt
|
||||
|
||||
Konvertera från Unix UTF-8 till Windows UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > ut.txt
|
||||
|
||||
GB18030
|
||||
GB18030 är en standard från Kinesiska regeringen. En obligatorisk
|
||||
delmängd av standarden GB18030 krävs officiellt för alla
|
||||
programvaruprodukter som säljs i Kina. Se vidare
|
||||
<https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
GB18030 är fullständigt kompatibel med Unicode och kan anses vara ett
|
||||
överföringsformat för unicode. Precis som UTF-8 är GB18030 kompatibel
|
||||
med ASCII. GB18030 är också kompatibel med Windows-teckentabell 936,
|
||||
också känd som GBK.
|
||||
|
||||
Under Unix/Linux kommer UTF-16-filer att konverteras till GB18030 när
|
||||
lokalens teckenkodning är inställd på GB18030. Notera att detta endast
|
||||
kommer att fungera om lokalen har stöd i systemet. Använd kommandot
|
||||
"locale -a" för att få en lista över de lokaler som stöds.
|
||||
|
||||
Under Windows måste du använda flaggan "-gb" för att konvertera
|
||||
UTF-16-filer till GB18030.
|
||||
|
||||
GB18030-kodade filer kan ha en byteordningsmarkering, precis som
|
||||
Unicode-filer.
|
||||
|
||||
EXEMPEL
|
||||
Läsa inmatning från “stdin“ och skriv utmatning till “stdout“:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Konvertera och ersätta a.txt. Konvertera och ersätt b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Konvertera och ersätt a.txt i ascii-konverteringsläge:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Konvertera och ersätt a.txt i ascii-konverteringsläge, konvertera och
|
||||
ersätt b.txt i 7bit-konverteringsläge:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Konvertera a.txt från Mac- till Unix-format:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Konvertera a.txt från Unix- till Mac-format:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Konvertera och ersätt a.txt medan originalet tidsstämpel behålls:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Konvertera a.txt och skriv till e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Konvertera a.txt och skriv till e.txt, låt e.txt behålla tidsstämpeln
|
||||
från a.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Konvertera och ersätt a.txt, konvertera b.txt och skriv till e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Konvertera c.txt och skriv till e.txt, konvertera och ersätt a.txt,
|
||||
konvertera och ersätt b.txt, konvertera d.txt och skriv till f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
REKURSIV KONVERTERING
|
||||
I ett Unix-skal kan kommandona find(1) och xargs(1) användas för att
|
||||
köra dos2unix rekursivt över alla textfiler i ett katalogträd. För att
|
||||
till exempel konvertera alla .txt-filer i katalogträdet under den
|
||||
aktuella katalogen skriv:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
Flaggan "-print0" till find(1) och motsvarande flagga -0 till xargs(1)
|
||||
behövs när det finns filer med mellanslag eller citationstecken i
|
||||
namnet. Annars kan dessa flaggor utelämnas. Ett annat alternativ är att
|
||||
användas find(1) med flaggan "-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
I en Windows-kommandoprompt kan följande kommando användas:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
PowerShell-användare kan använda följande kommando i Windows PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
LOKALISERING
|
||||
LANG
|
||||
Det primära språket väljs med miljövariabeln LANG. LANG-variabeln
|
||||
består av flera delas. Den första delen är språkkoden i gemener. Den
|
||||
andra delen är valfri och utgör landskoden i versaler, föregången av
|
||||
ett understreck. Det finns också en valfri tredje del:
|
||||
teckenkodning, föregången av en punkt. Ett par exempel för skal av
|
||||
POSIX-standard-typ:
|
||||
|
||||
export LANG=nl Nederländska
|
||||
export LANG=nl_NL Nederländska, Nederländerna
|
||||
export LANG=nl_BE Nederländska, Belgien
|
||||
export LANG=es_ES Spanska, Spanien
|
||||
export LANG=es_MX Spanska, Mexiko
|
||||
export LANG=en_US.iso88591 Engelska, USA, Latin-1-kodning
|
||||
export LANG=en_GB.UTF-8 Engelska, UK, UTF-8-kodning
|
||||
|
||||
För en fullständig lista över språk och landskoder se vidare i
|
||||
gettext-manualen:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
På Unix-system kan du använda kommando locale(1) för att få
|
||||
lokal-specifik information.
|
||||
|
||||
LANGUAGE
|
||||
Med miljövariabeln LANGUAGE kan du ange en prioritetslista över
|
||||
språk, separerade med kolon. dos2unix kommer att ge företräde till
|
||||
LANGAUGE över LANG. Exempelvis först nederländska och sedan tyska:
|
||||
"LANGUAGE=nl:de". Du måste först ha aktiverat lokalisering, genom
|
||||
att sätta LANG (eller LC_ALL) till ett värde annat än “C“, innan du
|
||||
kan använda en prioritetslista för språk via LANGUAGE-variabeln. Se
|
||||
vidare i gettext-manualen:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Om du väljer ett språk som inte är tillgänglig kommer du att få
|
||||
engelska meddelanden som standard.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Med miljövariabeln DOS2UNIX_LOCALEDIR kan LOCALEDIR som ställts in
|
||||
vid kompilering åsidosättas. LOCALEDIR används för att hitta
|
||||
språkfiler. Standardvärdet för GNU-program är
|
||||
"/usr/local/share/locale". Flaggan --version kommer att visa vilken
|
||||
LOCALEDIR som används.
|
||||
|
||||
Exempel (POSIX-skal):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
RETURVÄRDE
|
||||
Om allt går bra kommer noll att returneras. När ett systemfel uppstår
|
||||
kommer det senaste systemfelet att returneras. För andra fel kommer 1
|
||||
att returneras.
|
||||
|
||||
Returvärdet är alltid noll i tyst läge, utom när felaktiga
|
||||
kommandoradsflaggor används.
|
||||
|
||||
STANDARDER
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
FÖRFATTARE
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben
|
||||
(mac2unix-läge) - <wuebben@kde.org>, Christian Wurll (lägg till en extra
|
||||
radbrytning) - <wurll@ira.uka.de>, Erwin Waterlander -
|
||||
<waterlan@xs4all.nl> (upphovsman)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge-sida: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
SE ÄVEN
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/uk/dos2unix.htm
Normal file
838
Agent-Windows/OGP64/usr/share/doc/dos2unix/uk/dos2unix.htm
Normal file
|
|
@ -0,0 +1,838 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - програма для перетворення даних у текстовому форматі DOS/Mac у формат Unix, і навпаки</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#pod">НАЗВА</a></li>
|
||||
<li><a href="#pod1">КОРОТКИЙ ОПИС</a></li>
|
||||
<li><a href="#pod2">ОПИС</a></li>
|
||||
<li><a href="#pod3">ПАРАМЕТРИ</a></li>
|
||||
<li><a href="#MAC">РЕЖИМ MAC</a></li>
|
||||
<li><a href="#pod5">РЕЖИМИ ПЕРЕТВОРЕННЯ</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#pod6">Кодування</a></li>
|
||||
<li><a href="#pod7">Перетворення</a></li>
|
||||
<li><a href="#pod8">Позначка порядку байтів</a></li>
|
||||
<li><a href="#Unicode-Windows">Назви файлів у Unicode у Windows</a></li>
|
||||
<li><a href="#Unicode">Приклади для Unicode</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#pod9">ПРИКЛАДИ</a></li>
|
||||
<li><a href="#pod10">РЕКУРСИВНЕ ПЕРЕТВОРЕННЯ</a></li>
|
||||
<li><a href="#pod11">ЛОКАЛІЗАЦІЯ</a></li>
|
||||
<li><a href="#pod12">ПОВЕРНУТЕ ЗНАЧЕННЯ</a></li>
|
||||
<li><a href="#pod13">СТАНДАРТИ</a></li>
|
||||
<li><a href="#pod14">АВТОРИ</a></li>
|
||||
<li><a href="#pod15">ТАКОЖ ПЕРЕГЛЯНЬТЕ</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="pod">НАЗВА</h1>
|
||||
|
||||
<p>dos2unix - програма для перетворення даних у текстовому форматі DOS/Mac у формат Unix, і навпаки</p>
|
||||
|
||||
<h1 id="pod1">КОРОТКИЙ ОПИС</h1>
|
||||
|
||||
<pre><code>dos2unix [параметри] [ФАЙЛ ...] [-n ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...]
|
||||
unix2dos [параметри] [ФАЙЛ ...] [-n ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...]</code></pre>
|
||||
|
||||
<h1 id="pod2">ОПИС</h1>
|
||||
|
||||
<p>До складу пакунка dos2unix включено програми <code>dos2unix</code> та <code>unix2dos</code>, призначені для перетворення звичайних текстових даних у форматі DOS або Mac на дані у форматі Unix, і навпаки.</p>
|
||||
|
||||
<p>У текстових файлах DOS/Windows розрив рядка або перехід на новий рядок здійснюється за допомогою комбінації двох символів: повернення каретки (CR) і переведення рядка (LF). У текстових файлах Unix за перехід на новий рядок відповідає один символ: переведення рядка (LF). У текстових файлах Mac, до Mac OS X, за розрив рядка відповідав один символ: повернення каретки (CR). У сучасних версіях Mac OS використовується типовий для Unix розрив рядка (LF).</p>
|
||||
|
||||
<p>Окрім символів розриву рядка, програма dos2unix здатна виконувати перетворення кодування файлів. Можна перетворити дані у декількох кодуваннях DOS на файли у кодуванні Latin-1 Unix. Також можна перетворити дані у файлах Windows Unicode (UTF-16) на дані у кодуванні Unix Unicode (UTF-8).</p>
|
||||
|
||||
<p>Під час перетворення програма пропускатиме двійкові файли, якщо ви не накажете їй виконати перетворення таких файлів безпосередньо.</p>
|
||||
|
||||
<p>Програма автоматично пропускатиме файли, які не є звичайними файлами, зокрема каталоги та канали FIFO.</p>
|
||||
|
||||
<p>Типово, програма не вноситиме змін до символічних посилань та об’єктів посилань. Якщо потрібно, програма може замінити символічні посилання або записати перетворені дані до файла-призначення символічного посилання. У Windows запису до об’єкта символічного посилання не передбачено.</p>
|
||||
|
||||
<p>Програму dos2unix було створено за зразком програми dos2unix для SunOS/Solaris. Втім, існує одна важлива відмінність від оригінальної версії для SunOS/Solaris. Ця версія типово виконує заміну файлів під час перетворення (старий режим обробки файлів), а у оригінальній версії для SunOS/Solaris передбачено підтримку лише парного перетворення (новий режим обробки файлів). Див. також параметри <code>-o</code> та <code>-n</code>. Ще однією відмінністю є те, що у версії для SunOS/Solaris типово використовувався режим перетворення <i>iso</i>, а у цій версії типовим є режим перетворення <i>ascii</i>.</p>
|
||||
|
||||
<h1 id="pod3">ПАРАМЕТРИ</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod4"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вважати усі наступні параметри назвами файлів. Цим параметром слід користуватися, якщо вам потрібно виконати перетворення файлів, чиї назви містять дефіси. Наприклад, щоб виконати перетворення файла «-foo», скористайтеся такою командою:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>Або у новому режимі файлів:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Дозволити зміну власника файла у старому режимі файлів.</p>
|
||||
|
||||
<p>Якщо використано цей параметр, перетворення не перериватиметься, якщо у старому режимі файлів не вдасться зберегти параметри належності файла до певного користувача і/або групи. Перетворення продовжуватиметься, а перетворений файл матиме нові параметри власника, такі, наче його перетворено у новому режимі файлів. Див. також параметри <code>-o</code> і <code>-n</code>. Цим параметром можна скористатися, лише якщо у dos2unix передбачено підтримку збереження параметрів належності файлів певним користувачам і групам.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Типовий режим перетворення. Див. також розділ щодо режимів перетворення.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Виконати перетворення з кодування DOS на кодування ISO-8859-1. Див. розділ щодо режимів перетворення.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використати кодову таблицю 1252 Windows (західноєвропейські мови).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використовувати кодову сторінку DOS 437 (США). Це типова кодова сторінка для перетворення ISO.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використовувати кодову сторінку DOS 850 (західноєвропейські мови).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використовувати сторінку DOS 860 (португальська).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використовувати сторінку DOS 863 (канадська французька).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Використовувати сторінку DOS 865 (скандинавські мови).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Перетворювати 8-бітові символи на 7-бітові.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Зберегти позначку порядку байтів (BOM). Якщо у файлі вхідних даних є BOM, записати BOM до файла результатів. Це типова поведінка під час перетворення у формат із символами розриву рядків DOS. Див. також параметр <code>-r</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode"><b>-c, --convmode РЕЖИМ</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Встановити режим перетворення. Значенням аргументу РЕЖИМ може бути один з таких рядків: <i>ascii</i>, <i>7bit</i>, <i>iso</i>, <i>mac</i>. Типовим є режим ascii.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc"><b>-D, --display-enc КОДУВАННЯ</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Встановити кодування показаного тексту. Можливі варіанти значень параметра КОДУВАННЯ: <i>ansi</i>, <i>unicode</i>, <i>unicodebom</i>, <i>utf8</i>, <i>utf8bom</i>, типовим є ansi.</p>
|
||||
|
||||
<p>Цей параметр доступний лише у dos2unix для Windows з підтримкою назв файлів у Unicode. Цей параметр не впливає на справжнє читання та запис назв файлів, лише на те, як буде показано ці назви.</p>
|
||||
|
||||
<p>Існує декілька способів показу тексту у консолі Windows, заснованих на кодуванні тексту. Усі ці способи мають свої переваги і недоліки.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Типовим способом для dos2unix є кодування тексту у форматі ANSI. Перевагою є зворотна сумісність. Цей варіант працює з растровими шрифтами та шрифтами TrueType. У деяких регіонах, ймовірно, вам доведеться змінити активну кодову сторінку DOS OEM на системну кодову сторінку ANSI Windows за допомогою команди <code>chcp</code>, оскільки dos2unix використовує системну кодову сторінку Windows.</p>
|
||||
|
||||
<p>Недоліком ansi є те, що назви файлів із символами, яких немає у типовому системному кодуванні, буде показано неправильно. Замість цих символів ви побачите знак питання або не той символ. Якщо у вашій системі немає файлів із назвами, які містять нетипові символи, можна скористатися цим варіантом.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode, unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Перевагою кодування unicode (назва у Windows кодування UTF-16) є те, що зазвичай текст буде показано правильно. Змінювати активну кодову сторінку не потрібно. Ймовірно, вам потрібно встановити шрифт консолі TrueType для належного показу нестандартних символів. Якщо символ не передбачено у шрифті TrueType, зазвичай ви побачите невеличкий квадратик замість символу, іноді із знаком питання у ньому.</p>
|
||||
|
||||
<p>Якщо ви користуєтеся консоллю ConEmu, весь текст буде показано належним чином, оскільки ConEmu автоматично вибирає належний шрифт.</p>
|
||||
|
||||
<p>Недоліком unicode є те, що це кодування несумісне з ASCII. Обробка виведених даних є непростою, якщо ви передаватимете ці дані до іншої програми або файла.</p>
|
||||
|
||||
<p>Якщо використовується метод <code>unicodebom</code>, текст у кодуванні Unicode буде оброблено з урахуванням BOM (позначки порядку байтів). BOM потрібна для правильного переспрямовування або тунелювання даних у PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8, utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Перевагою utf8 є те, що це кодування сумісне з ASCII. Вам слід встановити шрифт консолі TrueType. Якщо використано шрифт TrueType, текст буде показано подібно до того, як його показано, якщо визначено кодування <code>unicode</code>.</p>
|
||||
|
||||
<p>Недоліком є те, що якщо ви скористаєтеся типовим растровим шрифтом, усі символи поза ASCII буде показано неправильно. Не лише назви файлів у unicode, а й перекладені повідомлення стануть непридатними до читання. У Windows, налаштованому на роботі у східно-азійському регіоні, ви можете помітити значне блимання під час показу повідомлень.</p>
|
||||
|
||||
<p>У консолі ConEmu добре працює спосіб кодування utf8.</p>
|
||||
|
||||
<p>Якщо використовується метод <code>utf8bom</code>, текст у кодуванні UTF-8 буде оброблено з урахуванням BOM (позначки порядку байтів). BOM потрібна для правильного переспрямовування або тунелювання даних у PowerShell.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Типове кодування можна змінити за допомогою змінної середовища DOS2UNIX_DISPLAY_ENC встановленням для неї значення <code>unicode</code>, <code>unicodebom</code>, <code>utf8</code> або <code>utf8bom</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Додати розрив рядка до останнього рядка, якщо його там немає. Працює для будь-яких перетворень.</p>
|
||||
|
||||
<p>У файлі, який перетворено з формату DOS до формату Unix може не вистачати розриву рядка в останньому рядку. Існують текстові редактори, які записують текстові файли без розриву рядка в останньому рядку. Деякі програми Unix мають проблеми з обробкою таких файлів, оскільки за стандартом POSIX кожен рядок текстового файла має завершуватися символом розриву рядка. Наприклад, об'єднання файлів може дати не зовсім очікуваний результат.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Повернути помилку, якщо пропущено двійковий файл.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Примусове перетворення двійкових файлів.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>У Windows файли в UTF-16 типово перетворюються на файли в UTF-8, незалежно від встановленої локалі. За допомогою цього параметра ви можете наказати програмі перетворювати файли в UTF-16 на файли у GB18030. Цим параметром можна скористатися лише у Windows. Див. також розділ, присвячений GB18030.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Показати довідкові дані і завершити роботу.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i---info"><b>-i[ПРАПОРЦІ], --info[=ПРАПОРЦІ] ФАЙЛ ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести дані щодо файла. Не виконувати перетворення.</p>
|
||||
|
||||
<p>Буде виведено такі дані, у вказаному порядку: кількість розривів рядків у форматі DOS, кількість розривів рядків у форматі Unix, кількість розривів рядків у форматі Mac, позначка порядку байтів, текстовим чи бінарним є файл та назву файла.</p>
|
||||
|
||||
<p>Приклад результатів:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>Зауважте, що іноді бінарні файли помилково розпізнаються як текстові. Див. також параметр <code>-s</code>.</p>
|
||||
|
||||
<p>Якщо використано додатковий параметр <code>-e</code> або <code>--add-eol</code>, буде також виведено дані щодо типу розриву рядків для останнього рядка або <code>noeol</code>, якщо такого немає.</p>
|
||||
|
||||
<p>Приклад результатів:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>Крім того, можна вказати додаткові прапорці для внесення змін у виведені дані. Можна використовувати один або декілька таких прапорців.</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Виводити рядки даних щодо файла із завершенням на нульовий символ, а не символ розриву рядка. Це уможливлює правильну інтерпретацію назв файлів, що містять пробіли або символи лапок, якщо використано прапорець «c». Скористайтеся цим прапорцем у поєднанні із параметром <code>-0</code> або <code>--null</code> xargs(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести кількість символів розривів рядка DOS.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести кількість символів розривів рядка Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести кількість символів розривів рядка Mac.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести позначку порядку байтів.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести дані щодо того, є файл текстовим чи бінарним.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести тип розриву рядка в останньому рядку або <code>noeol</code>, якщо останній рядок не містить розриву рядка.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести дані лише тих файлів, які було б перетворено.</p>
|
||||
|
||||
<p>Із прапорцем <code>c</code> dos2unix виведе лише назви файлів, у яких містяться розриви рядків DOS. unix2dos виведе лише назви файлів, у яких містяться розриви рядків Unix.</p>
|
||||
|
||||
<p>Якщо використано додатковий параметр <code>-e</code> або <code>--add-eol</code>, буде також виведено список файлів, які не містять символу розриву рядка в останньому рядку.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести заголовок.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Показувати назви файлів без шляхів.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>Приклади:</p>
|
||||
|
||||
<p>Вивести дані щодо усіх файлів *.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>Вивести кількість розривів рядків у форматі DOS і розривів рядків у форматі Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>Вивести лише позначку порядку байтів:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>Вивести список файлів, у яких є символи розриву рядків DOS:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>Вивести список файлів, у яких використано символи розриву рядків Unix:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>Вивести список файлів, у яких є символи розриву рядків DOS або якы не містять символу розриву рядка в останньому рядку:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>Перетворити лише файли із розривами рядків DOS і не чіпати інших файлів:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Знайти текстові файли і розривами рядків DOS:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Зберегти часову позначку файла вхідних даних у файлі результатів перетворення.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести умови ліцензування програми.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вставити додатковий символ розриву рядка.</p>
|
||||
|
||||
<p><b>dos2unix</b>: перетворення на два символи розриву рядків Unix відбуватиметься лише для комбінацій розриву рядків DOS. У режимі Mac виконуватиметься перетворення на два розриви рядків Unix лише символів розриву рядків Mac.</p>
|
||||
|
||||
<p><b>unix2dos</b>: перетворення на дві комбінації розриву рядків DOS відбуватиметься лише для символів розриву рядків DOS. У режимі Mac виконуватиметься перетворення на два розриви рядків Mac лише символів розриву рядків Unix.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Записати до файла результатів позначку порядку байтів (BOM). Типово буде записано позначку порядку байтів UTF-8.</p>
|
||||
|
||||
<p>Якщо дані початкового файла закодовано у UTF-16 і використано параметр <code>-u</code>, буде дописано позначку порядку байтів UTF-16.</p>
|
||||
|
||||
<p>Не використовуйте цей параметр для кодувань результатів, відмінних від UTF-8, UTF-16 або GB18030. Див. також розділ щодо UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newfile-_-_"><b>-n, --newfile ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Новий режим обробки файлів. Перетворити дані з файла ВХІДНИЙ_ФАЙЛ і записати результати до файла ВИХІДНИЙ_ФАЙЛ. Назви файлів слід вказувати парами, <i>не слід</i> використовувати шаблони заміни, інакше вміст файлів <i>буде втрачено</i>.</p>
|
||||
|
||||
<p>Власником перетвореного файла буде призначено користувача, яким було розпочато перетворення у режимі нового файла (парному режимі). Права доступу на читання або запис нового файла буде визначено на основі прав доступу до початкового файла мінус umask(1) для користувача, яким було розпочато перетворення.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не дозволяти зміну власника файла у старому режимі файлів (типова поведінка).</p>
|
||||
|
||||
<p>Переривати перетворення, якщо у старому режимі файлів не вдасться зберегти параметри належності файла до певного користувача і/або групи. Див. також параметри <code>-o</code> і <code>-n</code>. Цим параметром можна скористатися, лише якщо у dos2unix передбачено підтримку збереження параметрів належності файлів певним користувачам і групам.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не додавати розрив рядка до останнього рядка, якщо його там немає (типова поведінка).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не повертати помилку, якщо пропущено двійковий файл (типова поведінка).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Записати дані до стандартного виведення, подібного до фільтра Unix. Скористайтеся параметром <code>-o</code>, щоб повернутися до старого режиму файла (на місці).</p>
|
||||
|
||||
<p>У поєднанні із параметром <code>-e</code> файли можна належним чином розрізати. Усередині об'єднаного файла не буде об'єднання останнього і першого рядків і позначок порядку байтів Unicode. Приклад:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O файл1.txt файл2.txt > результат.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile"><b>-o, --oldfile ФАЙЛ ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Застарілий режим обробки. Виконати перетворення файла ФАЙЛ і перезаписати його вміст. Типово, програма працює у цьому режимі. Можна використовувати шаблони заміни.</p>
|
||||
|
||||
<p>У застарілому режимі (режимі заміщення) перетворений файл належатиме тому самому власнику і групі і матиме ті самі права доступу на читання або запис, що і початковий файл. Крім того, якщо перетворення файла виконується іншим користувачем, який має права доступу на запис до файла (наприклад користувачем root), перетворення буде перервано, якщо зберегти початкові значення не вдасться. Зміна власника може означати неможливість читання файла для його початкового власника. Зміна групи може призвести до проблем із безпекою, оскільки файл може стати доступним для читання користувачам, які не повинні мати такі права доступу. Можливість збереження прав власності та прав доступу до файла передбачено лише у Unix.</p>
|
||||
|
||||
<p>Щоб перевірити, чи передбачено у dos2unix підтримку збереження параметрів власника і групи файлів, віддайте команду <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Перетворення завжди виконується з використанням тимчасового файла. Якщо під час перетворення станеться помилка, тимчасовий файл буде вилучено, а початковий файл залишиться незмінним. Якщо перетворення буде виконано успішно, початковий файл буде замінено на тимчасовий файл. Може так статися, що у вас будуть права на перезапис початкового файла, але не буде прав для встановлення тих самих параметрів власника для тимчасового файла, який замінить собою початковий файл. Це означає, що ви не зможете зберегти параметри належності файла певному користувачу і/або групі. У цьому випадку ви можете скористатися параметром <code>--allow-chown</code>, щоб програма могла продовжити обробку даних:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown якийсь.txt</code></pre>
|
||||
|
||||
<p>Іншим варіантом дій є використання нового режиму файлів:</p>
|
||||
|
||||
<pre><code>dos2unix -n якийсь.txt якийсь.txt</code></pre>
|
||||
|
||||
<p>Перевагою використання параметра <code>--allow-chown</code> є те, що ви можете користуватися символами-замінниками, а параметри власників буде збережено, якщо можливо.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Режим без виведення повідомлень. Програма не виводитиме жодних попереджень або повідомлень про помилки. Повернутим значенням завжди буде нуль, якщо вказано правильні параметри командного рядка.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вилучити позначку порядку байтів (BOM). Не записувати BOM до файла результатів. Це типова поведінка під час перетворення файлів з форматом розриву рядків Unix. Див. також параметр <code>-b</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Пропускати двійкові файли (типово).</p>
|
||||
|
||||
<p>Пропускання бінарних файлів реалізовано для того, щоб уникнути випадкових помилок. Майте на увазі, що визначення бінарних файлів не є 100% точним. Програма просто шукає у файлах бінарні символи, які типово не трапляються у текстових файлах. Може так статися, що у бінарному файлі містяться лише звичайні текстові символи. Такий бінарний файл буде помилково сприйнято програмою як текстовий.</p>
|
||||
|
||||
<p>Типово, програма не повертатиме помилки, якщо буде пропущено двійковий файл. Якщо використано параметр <code>--error-binary</code>, буде повернуто повідомлення про помилку.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Припускати, що кодуванням вхідних файлів є UTF-16LE.</p>
|
||||
|
||||
<p>Якщо у початковому файлі є позначка порядку байтів (BOM), її буде використано у файлі-результаті, незалежно від використання цього параметра.</p>
|
||||
|
||||
<p>Якщо вами було зроблено помилкове припущення щодо формату файла (файл вхідних даних насправді не є файлом у форматі UTF-16LE), і дані вдасться успішно перетворити, ви отримаєте файл у кодуванні UTF-8 з помилковим вмістом. Скасувати таке помилкове перетворення можна за допомогою зворотного перетворення iconv(1) з даних у форматі UTF-8 на дані у форматі UTF-16LE. Таким чином ви повернетеся до початкового кодування даних у файлі.</p>
|
||||
|
||||
<p>Припущення щодо форматування UTF-16LE працює як визначення <i>режиму перетворення</i>. Перемиканням на типовий режим <i>ascii</i> можна вимкнути припущення щодо форматування UTF-16LE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Припускати, що вхідним форматом є UTF-16BE.</p>
|
||||
|
||||
<p>Цей параметр працює у спосіб, тотожний до параметра <code>-ul</code>.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Виводити докладні повідомлення. Буде показано додаткові дані щодо позначок порядку байтів та кількості перетворених символів розриву рядків.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Переходити за символічними посиланням і перетворювати файли, на які вони вказують.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Замінити символічні посилання перетвореними файлами (початкові файли, на які вони вказують, змінено не буде).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Не змінювати символічні посилання та файли, на які вони посилаються (типово).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Вивести дані щодо версії і завершити роботу.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="MAC">РЕЖИМ MAC</h1>
|
||||
|
||||
<p>Типово, розриви рядків DOS перетворюються на розриви рядків Unix, і навпаки. Розриви рядків Mac перетворенню не підлягають.</p>
|
||||
|
||||
<p>У режимі Mac розриви рядків Mac перетворюються на розриви рядків Unix, і навпаки. Розриви рядків DOS перетворенню не підлягають.</p>
|
||||
|
||||
<p>Щоб запустити програму у режимі перетворення Mac, скористайтеся параметром командного рядка <code>-c mac</code> або програмами <code>mac2unix</code> та <code>unix2mac</code>.</p>
|
||||
|
||||
<h1 id="pod5">РЕЖИМИ ПЕРЕТВОРЕННЯ</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Це типовий режим перетворення. Цей режим призначено для перетворення файлів у кодуванні ASCII або сумісному з ASCII кодуванні, зокрема UTF-8. Вмикання режиму <b>ascii</b> вимикає режим <b>7bit</b> і <b>iso</b>.</p>
|
||||
|
||||
<p>Якщо у dos2unix передбачено підтримку UTF-16, файли у кодуванні UTF-16 буде перетворено до поточного кодування символів локалі у системах POSIX та до UTF-8 у Windows. Вмикання режиму <b>ascii</b> вимикає параметр збереження кодування UTF-16 (<code>-u</code>) і параметр, які надають змогу припускати, що вхідні дані закодовано в UTF-16 (<code>-ul</code> і <code>-ub</code>). Щоб визначити, чи передбачено у dos2unix підтримку UTF-16, введіть команду <code>dos2unix -V</code>. Див. також розділ UNICODE.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>У цьому режимі усі 8-бітові символи, які не є частиною ASCII, (з номерами від 128 до 255) буде перетворено на відповідні 7-бітові символи.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Перетворення символів буде виконано з кодування (кодової сторінки) DOS до кодування ISO-8859-1 (Latin-1) у Unix. Символи DOS, які не мають еквівалентів у ISO-8859-1 і перетворення яких неможливе, буде перетворено на символ крапки. Те саме стосується символів ISO-8859-1, які не мають еквівалентів у DOS.</p>
|
||||
|
||||
<p>Якщо буде використано лише параметр <code>-iso</code>, програма dos2unix спробує визначити активне кодування. Якщо це виявиться неможливим, dos2unix використає типове кодування CP437, яке здебільшого використовується у США. Щоб примусово визначити кодування, скористайтеся параметром <code>-437</code> (США), <code>-850</code> (західноєвропейські мови), <code>-860</code> (португальська), <code>-863</code> (канадська французька) або <code>-865</code> (скандинавські мови). Використати кодування Windows CP1252 (західноєвропейські мови) можна за допомогою параметра <code>-1252</code>. Для інших кодувань використовуйте поєднання dos2unix з iconv(1). Програма iconv здатна виконувати перетворення даних у доволі широкому спектрі кодувань символів.</p>
|
||||
|
||||
<p>Ніколи не користуйтеся перетворенням ISO для текстових файлів у форматі Unicode. Використання подібного перетворення призведе до ушкодження вмісту файлів у кодуванні UTF-8.</p>
|
||||
|
||||
<p>Декілька прикладів:</p>
|
||||
|
||||
<p>Перетворити дані у типовому кодуванні DOS на дані у кодуванні Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні DOS CP850 на дані у кодуванні Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні CP1252 Windows на дані у кодуванні Latin-1 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні CP252 Windows на дані у кодуванні UTF-8 Unix (Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні Latin-1 Unix на дані у типовому кодуванні DOS:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні Latin-1 Unix на дані у кодуванні DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні Latin-1 Unix на дані у кодуванні Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні UTF-8 Unix (Unicode) на дані у кодуванні Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="pod6">Кодування</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="pod7">Перетворення</h2>
|
||||
|
||||
<p>У текстових файлах Unicode, як і у текстових файлах ASCII, може бути використано розриви рядків DOS, Unix або Mac.</p>
|
||||
|
||||
<p>Усі версії dos2unix та unix2dos здатні виконувати перетворення у кодуванні UTF-8, оскільки UTF-8 було розроблено так, що зворотну сумісність з ASCII збережено.</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>У Unix/Linux файли у кодуванні UTF-16 перетворюються на файли у кодуванні локалі. Для визначення поточного кодування символів локалі скористайтеся командою locale(1). Якщо перетворення виявиться неможливим, програма повідомить про помилку перетворення і пропустить відповідний файл.</p>
|
||||
|
||||
<p>У Windows файли UTF-16 типово буде перетворено на файли UTF-8. Обидва типи систем, Windows та Unix/Linux, мають непогані можливості з підтримки файлів у форматуванні UTF-8.</p>
|
||||
|
||||
<p>Кодування UTF-16 та UTF-8 є повністю сумісними. Під час перетворення не буде втрачено жодної інформації. Якщо під час перетворення даних у кодуванні UTF-16 на дані у кодуванні UTF-8 трапиться помилка, наприклад, якщо у вхідному файлі UTF-16 міститиметься якась помилка, файл буде пропущено.</p>
|
||||
|
||||
<p>Якщо використано параметр <code>-u</code>, файл результатів буде записано у тому самому кодуванні UTF-16, що і початковий файл. Використання параметра Option <code>-u</code> запобігає перетворенню даних у кодування UTF-8.</p>
|
||||
|
||||
<p>У dos2unix та unix2dos не передбачено параметра для перетворення даних у кодуванні UTF-8 на дані у кодуванні UTF-16.</p>
|
||||
|
||||
<p>Режим перетворення ISO та 7-бітовий режим не працюють для файлів UTF-16.</p>
|
||||
|
||||
<h2 id="pod8">Позначка порядку байтів</h2>
|
||||
|
||||
<p>У Windows до текстових файлів у кодуванні Unicode типово дописується позначка порядку байтів (BOM), оскільки багато програм Windows (зокрема Notepad) додають таку позначку автоматично. Див. також <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>.</p>
|
||||
|
||||
<p>У Unix файли у кодуванні Unicode типово не містять позначки порядку байтів. Вважається, що кодуванням текстових файлів є те кодування, яке визначається поточною локаллю.</p>
|
||||
|
||||
<p>Програма dos2unix може визначити, чи є кодуванням файла UTF-16, лише якщо у файлі міститься позначка порядку байтів. Якщо у файлі, де використано кодування UTF-16, немає такої позначки, dos2unix вважатиме такий файл двійковим (бінарним).</p>
|
||||
|
||||
<p>Для перетворення файлів UTF-16 без позначки порядку байтів скористайтеся параметром <code>-ul</code> або <code>-ub</code>.</p>
|
||||
|
||||
<p>Типово dos2unix не записує до файлів результатів перетворення позначки порядку байтів (BOM). Якщо використано параметр <code>-b</code>, dos2unix запише до файла результатів BOM, якщо BOM була у файлі початкових даних.</p>
|
||||
|
||||
<p>Типово unix2dos записує позначку порядку байтів (BOM) до файла результатів, якщо BOM є у початковому файлі. Скористайтеся параметром <code>-r</code>, щоб вилучити BOM.</p>
|
||||
|
||||
<p>dos2unix та unix2dos завжди записують до файла результатів позначку порядку байтів (BOM), якщо використано параметр <code>-m</code>.</p>
|
||||
|
||||
<h2 id="Unicode-Windows">Назви файлів у Unicode у Windows</h2>
|
||||
|
||||
<p>У dos2unix передбачено підтримку читання і запису назв файлів Unicode у командному рядку Windows. Це означає, що dos2unix може відкривати файли, у назвах яких є символи, які не є частиною типової системної кодової сторінки ANSI. Щоб визначити, чи зібрано dos2unix для Windows з підтримкою назв файлів у кодуванні Unicode, скористайтеся командою <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>Із показом назв файлів у кодуванні Unicode у консолі Windows пов’язано декілька проблем. Див. параметр <code>-D</code>, <code>--display-enc</code>. Назви файлів може бути некоректно показано у консолі, але запис цих назв відбуватиметься належним чином.</p>
|
||||
|
||||
<h2 id="Unicode">Приклади для Unicode</h2>
|
||||
|
||||
<p>Перетворити дані з Windows UTF-16 (з позначкою порядку байтів (BOM)) у формат Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у форматі Windows UTF-16LE (без BOM) на дані у форматі UTF-8 Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні UTF-8 Unix на дані у кодуванні Windows UTF-8 без BOM:</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у кодуванні UTF-8 Unix на дані у кодуванні Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030 є китайським урядовим стандартом. Підтримка обов’язкової підмножини стандарту GB18030 є неодмінною вимогою до будь-яких програмних продуктів, які продаються у Китаї. Див. також <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>.</p>
|
||||
|
||||
<p>Кодування GB18030 є повністю сумісним із Unicode. Його можна розглядати як формат перетворення unicode. Подібно до UTF-8, GB18030 є сумісним із ASCII. GB18030 також є сумісним із кодовою сторінкою Windows 936, яку ще називають GBK.</p>
|
||||
|
||||
<p>У Unix/Linux файли UTF-16 буде перетворено до кодування GB18030, якщо кодуванням локалі є GB18030. Зауважте, що це спрацює, лише якщо підтримку локалі передбачено у системі. Щоб отримати список підтримуваних локалей, скористайтеся командою <code>locale -a</code>.</p>
|
||||
|
||||
<p>У Windows для перетворення файлів UTF-16 на файли GB18030 слід вказати параметр <code>-gb</code>.</p>
|
||||
|
||||
<p>У файлах у кодуванні GB18030 може міститися позначка порядку байтів, так само, як у файлах у кодуванні Unicode.</p>
|
||||
|
||||
<h1 id="pod9">ПРИКЛАДИ</h1>
|
||||
|
||||
<p>Прочитати вхідні дані зі стандартного джерела (stdin) і записати результат до стандартного виведення (stdout):</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>Перетворити дані у a.txt і замістити цей файл. Перетворити дані у b.txt і замістити цей файл:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у a.txt і замістити файл у режимі перетворення ascii:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у a.txt і замістити файл у режимі перетворення ascii. Перетворити дані у b.txt і замістити цей файл у режимі 7-бітового перетворення:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>Перетворити файл a.txt з формату Mac на формат Unix:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>Перетворити файл a.txt з формату Unix на формат Mac:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у a.txt, замістити цей файл і зберегти часову позначку початкового файла:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у файлі a.txt і записати результати до файла e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у файлі a.txt і записати результати до файла e.txt. Скопіювати часову позначку файла a.txt для файла e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у a.txt і замістити цей файл. Перетворити дані у b.txt і записати результат до e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>Перетворити дані у c.txt і записати результати до e.txt. Перетворити дані у a.txt і замістити ними цей файл. Перетворити дані у b.txt і замістити ними цей файл. Перетворити дані у d.txt і записати результати до f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="pod10">РЕКУРСИВНЕ ПЕРЕТВОРЕННЯ</h1>
|
||||
|
||||
<p>У оболонці UNIX можна скористатися командами find(1) і xargs(1) для запуску dos2unix рекурсивно для усіх текстових файлів у ієрархії каталогів. Наприклад, щоб виконати перетворення усіх файлів .txt у структурі підкаталогів поточного каталогу, віддайте таку команду:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -print0 |xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>Параметр find(1) <code>-print0</code> і відповідний параметр xargs(1) <code>-0</code> потрібні, якщо у назва файлів є пробіли або лапки. Інакше, ці параметри можна пропустити. Іншим варіантом дій є використання find(1) з параметром <code>-exec</code>:</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>У командному рядку Windows можна скористатися такою командою:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>Користувачі PowerShell можуть скористатися такою командою у Windows PowerShell:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="pod11">ЛОКАЛІЗАЦІЯ</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Основна мова визначається за допомогою змінної середовища LANG. Значення змінної LANG складається з декількох частин. Перша частина записується малими літерами і визначає код мови. Друга частина є необов’язковою, визначає код країни і записується прописними літерами, відокремлюється від першої частини символом підкреслювання. Передбачено також необов’язкову третю частину: кодування. Ця частина відокремлюється від другої частини крапкою. Ось декілька прикладів для командних оболонок стандартного типу POSIX:</p>
|
||||
|
||||
<pre><code>export LANG=uk українська
|
||||
export LANG=uk_UA українська, Україна
|
||||
export LANG=ru_UA російська, Україна
|
||||
export LANG=es_ES іспанська, Іспанія
|
||||
export LANG=es_MX іспанська, Мексика
|
||||
export LANG=en_US.iso88591 англійська, США, кодування Latin-1
|
||||
export LANG=en_GB.UTF-8 англійська, Великобританія, кодування UTF-8</code></pre>
|
||||
|
||||
<p>Повний список мов та кодів країн наведено у підручнику з gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>У системах Unix для отримання даних щодо локалі можна скористатися командою locale(1).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>За допомогою змінної середовища LANGUAGE ви можете вказати список пріоритетності мов. Записи у списку слід відокремлювати двокрапками. Програма dos2unix надає перевагу LANGUAGE над LANG. Наприклад, перша голландська, далі німецька: <code>LANGUAGE=nl:de</code>. Спочатку вам слід увімкнути локалізацію, встановивши для змінної LANG (або LC_ALL) значення, відмінне від «C». Далі ви зможете використовувати список пріоритетності мов за допомогою змінної LANGUAGE. Додаткові відомості можна знайти у підручнику з gettext: <a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>Якщо вами буде вибрано мову, перекладу якою немає, буде показано стандартні повідомлення англійською мовою.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Змінну LOCALEDIR, встановлену під час збирання програми, можна змінити за допомогою змінної середовища DOS2UNIX_LOCALEDIR. LOCALEDIR використовується для пошуку файлів перекладів. Типовим значенням у системах GNU є <code>/usr/local/share/locale</code>. Переглянути поточне значення змінної LOCALEDIR можна переглянути за допомогою параметра <b>--version</b>.</p>
|
||||
|
||||
<p>Приклад (командна оболонка POSIX):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod12">ПОВЕРНУТЕ ЗНАЧЕННЯ</h1>
|
||||
|
||||
<p>Якщо завдання вдасться успішно виконати, програма поверне нульовий код виходу. Якщо станеться системна помилка, буде повернуто код цієї помилки. Якщо станеться якась інша помилка, буде повернуто код 1.</p>
|
||||
|
||||
<p>У режимі без повідомлень повернутим значенням завжди буде нуль, якщо вказано правильні параметри командного рядка.</p>
|
||||
|
||||
<h1 id="pod13">СТАНДАРТИ</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://uk.wikipedia.org/wiki/Carriage_return">https://uk.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://uk.wikipedia.org/wiki/Newline">https://uk.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://uk.wikipedia.org/wiki/Unicode">https://uk.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="pod14">АВТОРИ</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (режим mac2unix) - <wuebben@kde.org>, Christian Wurll (додатковий новий рядок) - <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl> (супровідник)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>Сторінка на SourceForge: <a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="pod15">ТАКОЖ ПЕРЕГЛЯНЬТЕ</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
906
Agent-Windows/OGP64/usr/share/doc/dos2unix/uk/dos2unix.txt
Normal file
906
Agent-Windows/OGP64/usr/share/doc/dos2unix/uk/dos2unix.txt
Normal file
|
|
@ -0,0 +1,906 @@
|
|||
НАЗВА
|
||||
dos2unix - програма для перетворення даних у текстовому форматі DOS/Mac
|
||||
у формат Unix, і навпаки
|
||||
|
||||
КОРОТКИЙ ОПИС
|
||||
dos2unix [параметри] [ФАЙЛ ...] [-n ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...]
|
||||
unix2dos [параметри] [ФАЙЛ ...] [-n ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...]
|
||||
|
||||
ОПИС
|
||||
До складу пакунка dos2unix включено програми "dos2unix" та "unix2dos",
|
||||
призначені для перетворення звичайних текстових даних у форматі DOS або
|
||||
Mac на дані у форматі Unix, і навпаки.
|
||||
|
||||
У текстових файлах DOS/Windows розрив рядка або перехід на новий рядок
|
||||
здійснюється за допомогою комбінації двох символів: повернення каретки
|
||||
(CR) і переведення рядка (LF). У текстових файлах Unix за перехід на
|
||||
новий рядок відповідає один символ: переведення рядка (LF). У текстових
|
||||
файлах Mac, до Mac OS X, за розрив рядка відповідав один символ:
|
||||
повернення каретки (CR). У сучасних версіях Mac OS використовується
|
||||
типовий для Unix розрив рядка (LF).
|
||||
|
||||
Окрім символів розриву рядка, програма dos2unix здатна виконувати
|
||||
перетворення кодування файлів. Можна перетворити дані у декількох
|
||||
кодуваннях DOS на файли у кодуванні Latin-1 Unix. Також можна
|
||||
перетворити дані у файлах Windows Unicode (UTF-16) на дані у кодуванні
|
||||
Unix Unicode (UTF-8).
|
||||
|
||||
Під час перетворення програма пропускатиме двійкові файли, якщо ви не
|
||||
накажете їй виконати перетворення таких файлів безпосередньо.
|
||||
|
||||
Програма автоматично пропускатиме файли, які не є звичайними файлами,
|
||||
зокрема каталоги та канали FIFO.
|
||||
|
||||
Типово, програма не вноситиме змін до символічних посилань та об’єктів
|
||||
посилань. Якщо потрібно, програма може замінити символічні посилання або
|
||||
записати перетворені дані до файла-призначення символічного посилання. У
|
||||
Windows запису до об’єкта символічного посилання не передбачено.
|
||||
|
||||
Програму dos2unix було створено за зразком програми dos2unix для
|
||||
SunOS/Solaris. Втім, існує одна важлива відмінність від оригінальної
|
||||
версії для SunOS/Solaris. Ця версія типово виконує заміну файлів під час
|
||||
перетворення (старий режим обробки файлів), а у оригінальній версії для
|
||||
SunOS/Solaris передбачено підтримку лише парного перетворення (новий
|
||||
режим обробки файлів). Див. також параметри "-o" та "-n". Ще однією
|
||||
відмінністю є те, що у версії для SunOS/Solaris типово використовувався
|
||||
режим перетворення *iso*, а у цій версії типовим є режим перетворення
|
||||
*ascii*.
|
||||
|
||||
ПАРАМЕТРИ
|
||||
-- Вважати усі наступні параметри назвами файлів. Цим параметром слід
|
||||
користуватися, якщо вам потрібно виконати перетворення файлів, чиї
|
||||
назви містять дефіси. Наприклад, щоб виконати перетворення файла
|
||||
«-foo», скористайтеся такою командою:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
Або у новому режимі файлів:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
Дозволити зміну власника файла у старому режимі файлів.
|
||||
|
||||
Якщо використано цей параметр, перетворення не перериватиметься,
|
||||
якщо у старому режимі файлів не вдасться зберегти параметри
|
||||
належності файла до певного користувача і/або групи. Перетворення
|
||||
продовжуватиметься, а перетворений файл матиме нові параметри
|
||||
власника, такі, наче його перетворено у новому режимі файлів. Див.
|
||||
також параметри "-o" і "-n". Цим параметром можна скористатися, лише
|
||||
якщо у dos2unix передбачено підтримку збереження параметрів
|
||||
належності файлів певним користувачам і групам.
|
||||
|
||||
-ascii
|
||||
Типовий режим перетворення. Див. також розділ щодо режимів
|
||||
перетворення.
|
||||
|
||||
-iso
|
||||
Виконати перетворення з кодування DOS на кодування ISO-8859-1. Див.
|
||||
розділ щодо режимів перетворення.
|
||||
|
||||
-1252
|
||||
Використати кодову таблицю 1252 Windows (західноєвропейські мови).
|
||||
|
||||
-437
|
||||
Використовувати кодову сторінку DOS 437 (США). Це типова кодова
|
||||
сторінка для перетворення ISO.
|
||||
|
||||
-850
|
||||
Використовувати кодову сторінку DOS 850 (західноєвропейські мови).
|
||||
|
||||
-860
|
||||
Використовувати сторінку DOS 860 (португальська).
|
||||
|
||||
-863
|
||||
Використовувати сторінку DOS 863 (канадська французька).
|
||||
|
||||
-865
|
||||
Використовувати сторінку DOS 865 (скандинавські мови).
|
||||
|
||||
-7 Перетворювати 8-бітові символи на 7-бітові.
|
||||
|
||||
-b, --keep-bom
|
||||
Зберегти позначку порядку байтів (BOM). Якщо у файлі вхідних даних є
|
||||
BOM, записати BOM до файла результатів. Це типова поведінка під час
|
||||
перетворення у формат із символами розриву рядків DOS. Див. також
|
||||
параметр "-r".
|
||||
|
||||
-c, --convmode РЕЖИМ
|
||||
Встановити режим перетворення. Значенням аргументу РЕЖИМ може бути
|
||||
один з таких рядків: *ascii*, *7bit*, *iso*, *mac*. Типовим є режим
|
||||
ascii.
|
||||
|
||||
-D, --display-enc КОДУВАННЯ
|
||||
Встановити кодування показаного тексту. Можливі варіанти значень
|
||||
параметра КОДУВАННЯ: *ansi*, *unicode*, *unicodebom*, *utf8*,
|
||||
*utf8bom*, типовим є ansi.
|
||||
|
||||
Цей параметр доступний лише у dos2unix для Windows з підтримкою назв
|
||||
файлів у Unicode. Цей параметр не впливає на справжнє читання та
|
||||
запис назв файлів, лише на те, як буде показано ці назви.
|
||||
|
||||
Існує декілька способів показу тексту у консолі Windows, заснованих
|
||||
на кодуванні тексту. Усі ці способи мають свої переваги і недоліки.
|
||||
|
||||
ansi
|
||||
Типовим способом для dos2unix є кодування тексту у форматі ANSI.
|
||||
Перевагою є зворотна сумісність. Цей варіант працює з растровими
|
||||
шрифтами та шрифтами TrueType. У деяких регіонах, ймовірно, вам
|
||||
доведеться змінити активну кодову сторінку DOS OEM на системну
|
||||
кодову сторінку ANSI Windows за допомогою команди "chcp",
|
||||
оскільки dos2unix використовує системну кодову сторінку Windows.
|
||||
|
||||
Недоліком ansi є те, що назви файлів із символами, яких немає у
|
||||
типовому системному кодуванні, буде показано неправильно.
|
||||
Замість цих символів ви побачите знак питання або не той символ.
|
||||
Якщо у вашій системі немає файлів із назвами, які містять
|
||||
нетипові символи, можна скористатися цим варіантом.
|
||||
|
||||
unicode, unicodebom
|
||||
Перевагою кодування unicode (назва у Windows кодування UTF-16) є
|
||||
те, що зазвичай текст буде показано правильно. Змінювати активну
|
||||
кодову сторінку не потрібно. Ймовірно, вам потрібно встановити
|
||||
шрифт консолі TrueType для належного показу нестандартних
|
||||
символів. Якщо символ не передбачено у шрифті TrueType, зазвичай
|
||||
ви побачите невеличкий квадратик замість символу, іноді із
|
||||
знаком питання у ньому.
|
||||
|
||||
Якщо ви користуєтеся консоллю ConEmu, весь текст буде показано
|
||||
належним чином, оскільки ConEmu автоматично вибирає належний
|
||||
шрифт.
|
||||
|
||||
Недоліком unicode є те, що це кодування несумісне з ASCII.
|
||||
Обробка виведених даних є непростою, якщо ви передаватимете ці
|
||||
дані до іншої програми або файла.
|
||||
|
||||
Якщо використовується метод "unicodebom", текст у кодуванні
|
||||
Unicode буде оброблено з урахуванням BOM (позначки порядку
|
||||
байтів). BOM потрібна для правильного переспрямовування або
|
||||
тунелювання даних у PowerShell.
|
||||
|
||||
utf8, utf8bom
|
||||
Перевагою utf8 є те, що це кодування сумісне з ASCII. Вам слід
|
||||
встановити шрифт консолі TrueType. Якщо використано шрифт
|
||||
TrueType, текст буде показано подібно до того, як його показано,
|
||||
якщо визначено кодування "unicode".
|
||||
|
||||
Недоліком є те, що якщо ви скористаєтеся типовим растровим
|
||||
шрифтом, усі символи поза ASCII буде показано неправильно. Не
|
||||
лише назви файлів у unicode, а й перекладені повідомлення
|
||||
стануть непридатними до читання. У Windows, налаштованому на
|
||||
роботі у східно-азійському регіоні, ви можете помітити значне
|
||||
блимання під час показу повідомлень.
|
||||
|
||||
У консолі ConEmu добре працює спосіб кодування utf8.
|
||||
|
||||
Якщо використовується метод "utf8bom", текст у кодуванні UTF-8
|
||||
буде оброблено з урахуванням BOM (позначки порядку байтів). BOM
|
||||
потрібна для правильного переспрямовування або тунелювання даних
|
||||
у PowerShell.
|
||||
|
||||
Типове кодування можна змінити за допомогою змінної середовища
|
||||
DOS2UNIX_DISPLAY_ENC встановленням для неї значення "unicode",
|
||||
"unicodebom", "utf8" або "utf8bom".
|
||||
|
||||
-e, --add-eol
|
||||
Додати розрив рядка до останнього рядка, якщо його там немає. Працює
|
||||
для будь-яких перетворень.
|
||||
|
||||
У файлі, який перетворено з формату DOS до формату Unix може не
|
||||
вистачати розриву рядка в останньому рядку. Існують текстові
|
||||
редактори, які записують текстові файли без розриву рядка в
|
||||
останньому рядку. Деякі програми Unix мають проблеми з обробкою
|
||||
таких файлів, оскільки за стандартом POSIX кожен рядок текстового
|
||||
файла має завершуватися символом розриву рядка. Наприклад,
|
||||
об'єднання файлів може дати не зовсім очікуваний результат.
|
||||
|
||||
--error-binary
|
||||
Повернути помилку, якщо пропущено двійковий файл.
|
||||
|
||||
-f, --force
|
||||
Примусове перетворення двійкових файлів.
|
||||
|
||||
-gb, --gb18030
|
||||
У Windows файли в UTF-16 типово перетворюються на файли в UTF-8,
|
||||
незалежно від встановленої локалі. За допомогою цього параметра ви
|
||||
можете наказати програмі перетворювати файли в UTF-16 на файли у
|
||||
GB18030. Цим параметром можна скористатися лише у Windows. Див.
|
||||
також розділ, присвячений GB18030.
|
||||
|
||||
-h, --help
|
||||
Показати довідкові дані і завершити роботу.
|
||||
|
||||
-i[ПРАПОРЦІ], --info[=ПРАПОРЦІ] ФАЙЛ ...
|
||||
Вивести дані щодо файла. Не виконувати перетворення.
|
||||
|
||||
Буде виведено такі дані, у вказаному порядку: кількість розривів
|
||||
рядків у форматі DOS, кількість розривів рядків у форматі Unix,
|
||||
кількість розривів рядків у форматі Mac, позначка порядку байтів,
|
||||
текстовим чи бінарним є файл та назву файла.
|
||||
|
||||
Приклад результатів:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
Зауважте, що іноді бінарні файли помилково розпізнаються як
|
||||
текстові. Див. також параметр "-s".
|
||||
|
||||
Якщо використано додатковий параметр "-e" або "--add-eol", буде
|
||||
також виведено дані щодо типу розриву рядків для останнього рядка
|
||||
або "noeol", якщо такого немає.
|
||||
|
||||
Приклад результатів:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
Крім того, можна вказати додаткові прапорці для внесення змін у
|
||||
виведені дані. Можна використовувати один або декілька таких
|
||||
прапорців.
|
||||
|
||||
0 Виводити рядки даних щодо файла із завершенням на нульовий
|
||||
символ, а не символ розриву рядка. Це уможливлює правильну
|
||||
інтерпретацію назв файлів, що містять пробіли або символи лапок,
|
||||
якщо використано прапорець «c». Скористайтеся цим прапорцем у
|
||||
поєднанні із параметром -0 або "--null" xargs(1).
|
||||
|
||||
d Вивести кількість символів розривів рядка DOS.
|
||||
|
||||
u Вивести кількість символів розривів рядка Unix.
|
||||
|
||||
m Вивести кількість символів розривів рядка Mac.
|
||||
|
||||
b Вивести позначку порядку байтів.
|
||||
|
||||
t Вивести дані щодо того, є файл текстовим чи бінарним.
|
||||
|
||||
e Вивести тип розриву рядка в останньому рядку або "noeol", якщо
|
||||
останній рядок не містить розриву рядка.
|
||||
|
||||
c Вивести дані лише тих файлів, які було б перетворено.
|
||||
|
||||
Із прапорцем "c" dos2unix виведе лише назви файлів, у яких
|
||||
містяться розриви рядків DOS. unix2dos виведе лише назви файлів,
|
||||
у яких містяться розриви рядків Unix.
|
||||
|
||||
Якщо використано додатковий параметр "-e" або "--add-eol", буде
|
||||
також виведено список файлів, які не містять символу розриву
|
||||
рядка в останньому рядку.
|
||||
|
||||
h Вивести заголовок.
|
||||
|
||||
p Показувати назви файлів без шляхів.
|
||||
|
||||
Приклади:
|
||||
|
||||
Вивести дані щодо усіх файлів *.txt:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
Вивести кількість розривів рядків у форматі DOS і розривів рядків у
|
||||
форматі Unix:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
Вивести лише позначку порядку байтів:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
Вивести список файлів, у яких є символи розриву рядків DOS:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
Вивести список файлів, у яких використано символи розриву рядків
|
||||
Unix:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
Вивести список файлів, у яких є символи розриву рядків DOS або якы
|
||||
не містять символу розриву рядка в останньому рядку:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
Перетворити лише файли із розривами рядків DOS і не чіпати інших
|
||||
файлів:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
Знайти текстові файли і розривами рядків DOS:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
Зберегти часову позначку файла вхідних даних у файлі результатів
|
||||
перетворення.
|
||||
|
||||
-L, --license
|
||||
Вивести умови ліцензування програми.
|
||||
|
||||
-l, --newline
|
||||
Вставити додатковий символ розриву рядка.
|
||||
|
||||
dos2unix: перетворення на два символи розриву рядків Unix
|
||||
відбуватиметься лише для комбінацій розриву рядків DOS. У режимі Mac
|
||||
виконуватиметься перетворення на два розриви рядків Unix лише
|
||||
символів розриву рядків Mac.
|
||||
|
||||
unix2dos: перетворення на дві комбінації розриву рядків DOS
|
||||
відбуватиметься лише для символів розриву рядків DOS. У режимі Mac
|
||||
виконуватиметься перетворення на два розриви рядків Mac лише
|
||||
символів розриву рядків Unix.
|
||||
|
||||
-m, --add-bom
|
||||
Записати до файла результатів позначку порядку байтів (BOM). Типово
|
||||
буде записано позначку порядку байтів UTF-8.
|
||||
|
||||
Якщо дані початкового файла закодовано у UTF-16 і використано
|
||||
параметр "-u", буде дописано позначку порядку байтів UTF-16.
|
||||
|
||||
Не використовуйте цей параметр для кодувань результатів, відмінних
|
||||
від UTF-8, UTF-16 або GB18030. Див. також розділ щодо UNICODE.
|
||||
|
||||
-n, --newfile ВХІДНИЙ_ФАЙЛ ВИХІДНИЙ_ФАЙЛ ...
|
||||
Новий режим обробки файлів. Перетворити дані з файла ВХІДНИЙ_ФАЙЛ і
|
||||
записати результати до файла ВИХІДНИЙ_ФАЙЛ. Назви файлів слід
|
||||
вказувати парами, *не слід* використовувати шаблони заміни, інакше
|
||||
вміст файлів *буде втрачено*.
|
||||
|
||||
Власником перетвореного файла буде призначено користувача, яким було
|
||||
розпочато перетворення у режимі нового файла (парному режимі). Права
|
||||
доступу на читання або запис нового файла буде визначено на основі
|
||||
прав доступу до початкового файла мінус umask(1) для користувача,
|
||||
яким було розпочато перетворення.
|
||||
|
||||
--no-allow-chown
|
||||
Не дозволяти зміну власника файла у старому режимі файлів (типова
|
||||
поведінка).
|
||||
|
||||
Переривати перетворення, якщо у старому режимі файлів не вдасться
|
||||
зберегти параметри належності файла до певного користувача і/або
|
||||
групи. Див. також параметри "-o" і "-n". Цим параметром можна
|
||||
скористатися, лише якщо у dos2unix передбачено підтримку збереження
|
||||
параметрів належності файлів певним користувачам і групам.
|
||||
|
||||
--no-add-eol
|
||||
Не додавати розрив рядка до останнього рядка, якщо його там немає
|
||||
(типова поведінка).
|
||||
|
||||
--no-error-binary
|
||||
Не повертати помилку, якщо пропущено двійковий файл (типова
|
||||
поведінка).
|
||||
|
||||
-O, --to-stdout
|
||||
Записати дані до стандартного виведення, подібного до фільтра Unix.
|
||||
Скористайтеся параметром "-o", щоб повернутися до старого режиму
|
||||
файла (на місці).
|
||||
|
||||
У поєднанні із параметром "-e" файли можна належним чином розрізати.
|
||||
Усередині об'єднаного файла не буде об'єднання останнього і першого
|
||||
рядків і позначок порядку байтів Unicode. Приклад:
|
||||
|
||||
dos2unix -e -O файл1.txt файл2.txt > результат.txt
|
||||
|
||||
-o, --oldfile ФАЙЛ ...
|
||||
Застарілий режим обробки. Виконати перетворення файла ФАЙЛ і
|
||||
перезаписати його вміст. Типово, програма працює у цьому режимі.
|
||||
Можна використовувати шаблони заміни.
|
||||
|
||||
У застарілому режимі (режимі заміщення) перетворений файл належатиме
|
||||
тому самому власнику і групі і матиме ті самі права доступу на
|
||||
читання або запис, що і початковий файл. Крім того, якщо
|
||||
перетворення файла виконується іншим користувачем, який має права
|
||||
доступу на запис до файла (наприклад користувачем root),
|
||||
перетворення буде перервано, якщо зберегти початкові значення не
|
||||
вдасться. Зміна власника може означати неможливість читання файла
|
||||
для його початкового власника. Зміна групи може призвести до проблем
|
||||
із безпекою, оскільки файл може стати доступним для читання
|
||||
користувачам, які не повинні мати такі права доступу. Можливість
|
||||
збереження прав власності та прав доступу до файла передбачено лише
|
||||
у Unix.
|
||||
|
||||
Щоб перевірити, чи передбачено у dos2unix підтримку збереження
|
||||
параметрів власника і групи файлів, віддайте команду "dos2unix -V".
|
||||
|
||||
Перетворення завжди виконується з використанням тимчасового файла.
|
||||
Якщо під час перетворення станеться помилка, тимчасовий файл буде
|
||||
вилучено, а початковий файл залишиться незмінним. Якщо перетворення
|
||||
буде виконано успішно, початковий файл буде замінено на тимчасовий
|
||||
файл. Може так статися, що у вас будуть права на перезапис
|
||||
початкового файла, але не буде прав для встановлення тих самих
|
||||
параметрів власника для тимчасового файла, який замінить собою
|
||||
початковий файл. Це означає, що ви не зможете зберегти параметри
|
||||
належності файла певному користувачу і/або групі. У цьому випадку ви
|
||||
можете скористатися параметром "--allow-chown", щоб програма могла
|
||||
продовжити обробку даних:
|
||||
|
||||
dos2unix --allow-chown якийсь.txt
|
||||
|
||||
Іншим варіантом дій є використання нового режиму файлів:
|
||||
|
||||
dos2unix -n якийсь.txt якийсь.txt
|
||||
|
||||
Перевагою використання параметра "--allow-chown" є те, що ви можете
|
||||
користуватися символами-замінниками, а параметри власників буде
|
||||
збережено, якщо можливо.
|
||||
|
||||
-q, --quiet
|
||||
Режим без виведення повідомлень. Програма не виводитиме жодних
|
||||
попереджень або повідомлень про помилки. Повернутим значенням завжди
|
||||
буде нуль, якщо вказано правильні параметри командного рядка.
|
||||
|
||||
-r, --remove-bom
|
||||
Вилучити позначку порядку байтів (BOM). Не записувати BOM до файла
|
||||
результатів. Це типова поведінка під час перетворення файлів з
|
||||
форматом розриву рядків Unix. Див. також параметр "-b".
|
||||
|
||||
-s, --safe
|
||||
Пропускати двійкові файли (типово).
|
||||
|
||||
Пропускання бінарних файлів реалізовано для того, щоб уникнути
|
||||
випадкових помилок. Майте на увазі, що визначення бінарних файлів не
|
||||
є 100% точним. Програма просто шукає у файлах бінарні символи, які
|
||||
типово не трапляються у текстових файлах. Може так статися, що у
|
||||
бінарному файлі містяться лише звичайні текстові символи. Такий
|
||||
бінарний файл буде помилково сприйнято програмою як текстовий.
|
||||
|
||||
Типово, програма не повертатиме помилки, якщо буде пропущено
|
||||
двійковий файл. Якщо використано параметр "--error-binary", буде
|
||||
повернуто повідомлення про помилку.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
Припускати, що кодуванням вхідних файлів є UTF-16LE.
|
||||
|
||||
Якщо у початковому файлі є позначка порядку байтів (BOM), її буде
|
||||
використано у файлі-результаті, незалежно від використання цього
|
||||
параметра.
|
||||
|
||||
Якщо вами було зроблено помилкове припущення щодо формату файла
|
||||
(файл вхідних даних насправді не є файлом у форматі UTF-16LE), і
|
||||
дані вдасться успішно перетворити, ви отримаєте файл у кодуванні
|
||||
UTF-8 з помилковим вмістом. Скасувати таке помилкове перетворення
|
||||
можна за допомогою зворотного перетворення iconv(1) з даних у
|
||||
форматі UTF-8 на дані у форматі UTF-16LE. Таким чином ви повернетеся
|
||||
до початкового кодування даних у файлі.
|
||||
|
||||
Припущення щодо форматування UTF-16LE працює як визначення *режиму
|
||||
перетворення*. Перемиканням на типовий режим *ascii* можна вимкнути
|
||||
припущення щодо форматування UTF-16LE.
|
||||
|
||||
-ub, --assume-utf16be
|
||||
Припускати, що вхідним форматом є UTF-16BE.
|
||||
|
||||
Цей параметр працює у спосіб, тотожний до параметра "-ul".
|
||||
|
||||
-v, --verbose
|
||||
Виводити докладні повідомлення. Буде показано додаткові дані щодо
|
||||
позначок порядку байтів та кількості перетворених символів розриву
|
||||
рядків.
|
||||
|
||||
-F, --follow-symlink
|
||||
Переходити за символічними посиланням і перетворювати файли, на які
|
||||
вони вказують.
|
||||
|
||||
-R, --replace-symlink
|
||||
Замінити символічні посилання перетвореними файлами (початкові
|
||||
файли, на які вони вказують, змінено не буде).
|
||||
|
||||
-S, --skip-symlink
|
||||
Не змінювати символічні посилання та файли, на які вони посилаються
|
||||
(типово).
|
||||
|
||||
-V, --version
|
||||
Вивести дані щодо версії і завершити роботу.
|
||||
|
||||
РЕЖИМ MAC
|
||||
Типово, розриви рядків DOS перетворюються на розриви рядків Unix, і
|
||||
навпаки. Розриви рядків Mac перетворенню не підлягають.
|
||||
|
||||
У режимі Mac розриви рядків Mac перетворюються на розриви рядків Unix, і
|
||||
навпаки. Розриви рядків DOS перетворенню не підлягають.
|
||||
|
||||
Щоб запустити програму у режимі перетворення Mac, скористайтеся
|
||||
параметром командного рядка "-c mac" або програмами "mac2unix" та
|
||||
"unix2mac".
|
||||
|
||||
РЕЖИМИ ПЕРЕТВОРЕННЯ
|
||||
ascii
|
||||
Це типовий режим перетворення. Цей режим призначено для перетворення
|
||||
файлів у кодуванні ASCII або сумісному з ASCII кодуванні, зокрема
|
||||
UTF-8. Вмикання режиму ascii вимикає режим 7bit і iso.
|
||||
|
||||
Якщо у dos2unix передбачено підтримку UTF-16, файли у кодуванні
|
||||
UTF-16 буде перетворено до поточного кодування символів локалі у
|
||||
системах POSIX та до UTF-8 у Windows. Вмикання режиму ascii вимикає
|
||||
параметр збереження кодування UTF-16 ("-u") і параметр, які надають
|
||||
змогу припускати, що вхідні дані закодовано в UTF-16 ("-ul" і
|
||||
"-ub"). Щоб визначити, чи передбачено у dos2unix підтримку UTF-16,
|
||||
введіть команду "dos2unix -V". Див. також розділ UNICODE.
|
||||
|
||||
7bit
|
||||
У цьому режимі усі 8-бітові символи, які не є частиною ASCII, (з
|
||||
номерами від 128 до 255) буде перетворено на відповідні 7-бітові
|
||||
символи.
|
||||
|
||||
iso Перетворення символів буде виконано з кодування (кодової сторінки)
|
||||
DOS до кодування ISO-8859-1 (Latin-1) у Unix. Символи DOS, які не
|
||||
мають еквівалентів у ISO-8859-1 і перетворення яких неможливе, буде
|
||||
перетворено на символ крапки. Те саме стосується символів
|
||||
ISO-8859-1, які не мають еквівалентів у DOS.
|
||||
|
||||
Якщо буде використано лише параметр "-iso", програма dos2unix
|
||||
спробує визначити активне кодування. Якщо це виявиться неможливим,
|
||||
dos2unix використає типове кодування CP437, яке здебільшого
|
||||
використовується у США. Щоб примусово визначити кодування,
|
||||
скористайтеся параметром -437 (США), -850 (західноєвропейські мови),
|
||||
-860 (португальська), -863 (канадська французька) або -865
|
||||
(скандинавські мови). Використати кодування Windows CP1252
|
||||
(західноєвропейські мови) можна за допомогою параметра -1252. Для
|
||||
інших кодувань використовуйте поєднання dos2unix з iconv(1).
|
||||
Програма iconv здатна виконувати перетворення даних у доволі
|
||||
широкому спектрі кодувань символів.
|
||||
|
||||
Ніколи не користуйтеся перетворенням ISO для текстових файлів у
|
||||
форматі Unicode. Використання подібного перетворення призведе до
|
||||
ушкодження вмісту файлів у кодуванні UTF-8.
|
||||
|
||||
Декілька прикладів:
|
||||
|
||||
Перетворити дані у типовому кодуванні DOS на дані у кодуванні
|
||||
Latin-1 Unix:
|
||||
|
||||
dos2unix -iso -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні DOS CP850 на дані у кодуванні Latin-1
|
||||
Unix:
|
||||
|
||||
dos2unix -850 -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні CP1252 Windows на дані у кодуванні
|
||||
Latin-1 Unix:
|
||||
|
||||
dos2unix -1252 -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні CP252 Windows на дані у кодуванні UTF-8
|
||||
Unix (Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
|
||||
|
||||
Перетворити дані у кодуванні Latin-1 Unix на дані у типовому
|
||||
кодуванні DOS:
|
||||
|
||||
unix2dos -iso -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні Latin-1 Unix на дані у кодуванні DOS
|
||||
CP850:
|
||||
|
||||
unix2dos -850 -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні Latin-1 Unix на дані у кодуванні
|
||||
Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні UTF-8 Unix (Unicode) на дані у
|
||||
кодуванні Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
Кодування
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
Перетворення
|
||||
У текстових файлах Unicode, як і у текстових файлах ASCII, може бути
|
||||
використано розриви рядків DOS, Unix або Mac.
|
||||
|
||||
Усі версії dos2unix та unix2dos здатні виконувати перетворення у
|
||||
кодуванні UTF-8, оскільки UTF-8 було розроблено так, що зворотну
|
||||
сумісність з ASCII збережено.
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
У Unix/Linux файли у кодуванні UTF-16 перетворюються на файли у
|
||||
кодуванні локалі. Для визначення поточного кодування символів локалі
|
||||
скористайтеся командою locale(1). Якщо перетворення виявиться
|
||||
неможливим, програма повідомить про помилку перетворення і пропустить
|
||||
відповідний файл.
|
||||
|
||||
У Windows файли UTF-16 типово буде перетворено на файли UTF-8. Обидва
|
||||
типи систем, Windows та Unix/Linux, мають непогані можливості з
|
||||
підтримки файлів у форматуванні UTF-8.
|
||||
|
||||
Кодування UTF-16 та UTF-8 є повністю сумісними. Під час перетворення не
|
||||
буде втрачено жодної інформації. Якщо під час перетворення даних у
|
||||
кодуванні UTF-16 на дані у кодуванні UTF-8 трапиться помилка, наприклад,
|
||||
якщо у вхідному файлі UTF-16 міститиметься якась помилка, файл буде
|
||||
пропущено.
|
||||
|
||||
Якщо використано параметр "-u", файл результатів буде записано у тому
|
||||
самому кодуванні UTF-16, що і початковий файл. Використання параметра
|
||||
Option "-u" запобігає перетворенню даних у кодування UTF-8.
|
||||
|
||||
У dos2unix та unix2dos не передбачено параметра для перетворення даних у
|
||||
кодуванні UTF-8 на дані у кодуванні UTF-16.
|
||||
|
||||
Режим перетворення ISO та 7-бітовий режим не працюють для файлів UTF-16.
|
||||
|
||||
Позначка порядку байтів
|
||||
У Windows до текстових файлів у кодуванні Unicode типово дописується
|
||||
позначка порядку байтів (BOM), оскільки багато програм Windows (зокрема
|
||||
Notepad) додають таку позначку автоматично. Див. також
|
||||
<https://en.wikipedia.org/wiki/Byte_order_mark>.
|
||||
|
||||
У Unix файли у кодуванні Unicode типово не містять позначки порядку
|
||||
байтів. Вважається, що кодуванням текстових файлів є те кодування, яке
|
||||
визначається поточною локаллю.
|
||||
|
||||
Програма dos2unix може визначити, чи є кодуванням файла UTF-16, лише
|
||||
якщо у файлі міститься позначка порядку байтів. Якщо у файлі, де
|
||||
використано кодування UTF-16, немає такої позначки, dos2unix вважатиме
|
||||
такий файл двійковим (бінарним).
|
||||
|
||||
Для перетворення файлів UTF-16 без позначки порядку байтів скористайтеся
|
||||
параметром "-ul" або "-ub".
|
||||
|
||||
Типово dos2unix не записує до файлів результатів перетворення позначки
|
||||
порядку байтів (BOM). Якщо використано параметр "-b", dos2unix запише до
|
||||
файла результатів BOM, якщо BOM була у файлі початкових даних.
|
||||
|
||||
Типово unix2dos записує позначку порядку байтів (BOM) до файла
|
||||
результатів, якщо BOM є у початковому файлі. Скористайтеся параметром
|
||||
"-r", щоб вилучити BOM.
|
||||
|
||||
dos2unix та unix2dos завжди записують до файла результатів позначку
|
||||
порядку байтів (BOM), якщо використано параметр "-m".
|
||||
|
||||
Назви файлів у Unicode у Windows
|
||||
У dos2unix передбачено підтримку читання і запису назв файлів Unicode у
|
||||
командному рядку Windows. Це означає, що dos2unix може відкривати файли,
|
||||
у назвах яких є символи, які не є частиною типової системної кодової
|
||||
сторінки ANSI. Щоб визначити, чи зібрано dos2unix для Windows з
|
||||
підтримкою назв файлів у кодуванні Unicode, скористайтеся командою
|
||||
"dos2unix -V".
|
||||
|
||||
Із показом назв файлів у кодуванні Unicode у консолі Windows пов’язано
|
||||
декілька проблем. Див. параметр "-D", "--display-enc". Назви файлів може
|
||||
бути некоректно показано у консолі, але запис цих назв відбуватиметься
|
||||
належним чином.
|
||||
|
||||
Приклади для Unicode
|
||||
Перетворити дані з Windows UTF-16 (з позначкою порядку байтів (BOM)) у
|
||||
формат Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt out.txt
|
||||
|
||||
Перетворити дані у форматі Windows UTF-16LE (без BOM) на дані у форматі
|
||||
UTF-8 Unix:
|
||||
|
||||
dos2unix -ul -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні UTF-8 Unix на дані у кодуванні Windows
|
||||
UTF-8 без BOM:
|
||||
|
||||
unix2dos -m -n in.txt out.txt
|
||||
|
||||
Перетворити дані у кодуванні UTF-8 Unix на дані у кодуванні Windows
|
||||
UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
|
||||
|
||||
GB18030
|
||||
GB18030 є китайським урядовим стандартом. Підтримка обов’язкової
|
||||
підмножини стандарту GB18030 є неодмінною вимогою до будь-яких
|
||||
програмних продуктів, які продаються у Китаї. Див. також
|
||||
<https://en.wikipedia.org/wiki/GB_18030>.
|
||||
|
||||
Кодування GB18030 є повністю сумісним із Unicode. Його можна розглядати
|
||||
як формат перетворення unicode. Подібно до UTF-8, GB18030 є сумісним із
|
||||
ASCII. GB18030 також є сумісним із кодовою сторінкою Windows 936, яку ще
|
||||
називають GBK.
|
||||
|
||||
У Unix/Linux файли UTF-16 буде перетворено до кодування GB18030, якщо
|
||||
кодуванням локалі є GB18030. Зауважте, що це спрацює, лише якщо
|
||||
підтримку локалі передбачено у системі. Щоб отримати список
|
||||
підтримуваних локалей, скористайтеся командою "locale -a".
|
||||
|
||||
У Windows для перетворення файлів UTF-16 на файли GB18030 слід вказати
|
||||
параметр "-gb".
|
||||
|
||||
У файлах у кодуванні GB18030 може міститися позначка порядку байтів, так
|
||||
само, як у файлах у кодуванні Unicode.
|
||||
|
||||
ПРИКЛАДИ
|
||||
Прочитати вхідні дані зі стандартного джерела (stdin) і записати
|
||||
результат до стандартного виведення (stdout):
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
Перетворити дані у a.txt і замістити цей файл. Перетворити дані у b.txt
|
||||
і замістити цей файл:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
Перетворити дані у a.txt і замістити файл у режимі перетворення ascii:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
Перетворити дані у a.txt і замістити файл у режимі перетворення ascii.
|
||||
Перетворити дані у b.txt і замістити цей файл у режимі 7-бітового
|
||||
перетворення:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
Перетворити файл a.txt з формату Mac на формат Unix:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
Перетворити файл a.txt з формату Unix на формат Mac:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
Перетворити дані у a.txt, замістити цей файл і зберегти часову позначку
|
||||
початкового файла:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
Перетворити дані у файлі a.txt і записати результати до файла e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
Перетворити дані у файлі a.txt і записати результати до файла e.txt.
|
||||
Скопіювати часову позначку файла a.txt для файла e.txt:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
Перетворити дані у a.txt і замістити цей файл. Перетворити дані у b.txt
|
||||
і записати результат до e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
Перетворити дані у c.txt і записати результати до e.txt. Перетворити
|
||||
дані у a.txt і замістити ними цей файл. Перетворити дані у b.txt і
|
||||
замістити ними цей файл. Перетворити дані у d.txt і записати результати
|
||||
до f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
РЕКУРСИВНЕ ПЕРЕТВОРЕННЯ
|
||||
У оболонці UNIX можна скористатися командами find(1) і xargs(1) для
|
||||
запуску dos2unix рекурсивно для усіх текстових файлів у ієрархії
|
||||
каталогів. Наприклад, щоб виконати перетворення усіх файлів .txt у
|
||||
структурі підкаталогів поточного каталогу, віддайте таку команду:
|
||||
|
||||
find . -name '*.txt' -print0 |xargs -0 dos2unix
|
||||
|
||||
Параметр find(1) "-print0" і відповідний параметр xargs(1) -0 потрібні,
|
||||
якщо у назва файлів є пробіли або лапки. Інакше, ці параметри можна
|
||||
пропустити. Іншим варіантом дій є використання find(1) з параметром
|
||||
"-exec":
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
У командному рядку Windows можна скористатися такою командою:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
Користувачі PowerShell можуть скористатися такою командою у Windows
|
||||
PowerShell:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
ЛОКАЛІЗАЦІЯ
|
||||
LANG
|
||||
Основна мова визначається за допомогою змінної середовища LANG.
|
||||
Значення змінної LANG складається з декількох частин. Перша частина
|
||||
записується малими літерами і визначає код мови. Друга частина є
|
||||
необов’язковою, визначає код країни і записується прописними
|
||||
літерами, відокремлюється від першої частини символом
|
||||
підкреслювання. Передбачено також необов’язкову третю частину:
|
||||
кодування. Ця частина відокремлюється від другої частини крапкою.
|
||||
Ось декілька прикладів для командних оболонок стандартного типу
|
||||
POSIX:
|
||||
|
||||
export LANG=uk українська
|
||||
export LANG=uk_UA українська, Україна
|
||||
export LANG=ru_UA російська, Україна
|
||||
export LANG=es_ES іспанська, Іспанія
|
||||
export LANG=es_MX іспанська, Мексика
|
||||
export LANG=en_US.iso88591 англійська, США, кодування Latin-1
|
||||
export LANG=en_GB.UTF-8 англійська, Великобританія, кодування UTF-8
|
||||
|
||||
Повний список мов та кодів країн наведено у підручнику з gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/Usual-Languag
|
||||
e-Codes.html>
|
||||
|
||||
У системах Unix для отримання даних щодо локалі можна скористатися
|
||||
командою locale(1).
|
||||
|
||||
LANGUAGE
|
||||
За допомогою змінної середовища LANGUAGE ви можете вказати список
|
||||
пріоритетності мов. Записи у списку слід відокремлювати двокрапками.
|
||||
Програма dos2unix надає перевагу LANGUAGE над LANG. Наприклад, перша
|
||||
голландська, далі німецька: "LANGUAGE=nl:de". Спочатку вам слід
|
||||
увімкнути локалізацію, встановивши для змінної LANG (або LC_ALL)
|
||||
значення, відмінне від «C». Далі ви зможете використовувати список
|
||||
пріоритетності мов за допомогою змінної LANGUAGE. Додаткові
|
||||
відомості можна знайти у підручнику з gettext:
|
||||
<https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-
|
||||
variable.html>
|
||||
|
||||
Якщо вами буде вибрано мову, перекладу якою немає, буде показано
|
||||
стандартні повідомлення англійською мовою.
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
Змінну LOCALEDIR, встановлену під час збирання програми, можна
|
||||
змінити за допомогою змінної середовища DOS2UNIX_LOCALEDIR.
|
||||
LOCALEDIR використовується для пошуку файлів перекладів. Типовим
|
||||
значенням у системах GNU є "/usr/local/share/locale". Переглянути
|
||||
поточне значення змінної LOCALEDIR можна переглянути за допомогою
|
||||
параметра --version.
|
||||
|
||||
Приклад (командна оболонка POSIX):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
ПОВЕРНУТЕ ЗНАЧЕННЯ
|
||||
Якщо завдання вдасться успішно виконати, програма поверне нульовий код
|
||||
виходу. Якщо станеться системна помилка, буде повернуто код цієї
|
||||
помилки. Якщо станеться якась інша помилка, буде повернуто код 1.
|
||||
|
||||
У режимі без повідомлень повернутим значенням завжди буде нуль, якщо
|
||||
вказано правильні параметри командного рядка.
|
||||
|
||||
СТАНДАРТИ
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://uk.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://uk.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://uk.wikipedia.org/wiki/Unicode>
|
||||
|
||||
АВТОРИ
|
||||
Benjamin Lin - <blin@socs.uts.edu.au>, Bernd Johannes Wuebben (режим
|
||||
mac2unix) - <wuebben@kde.org>, Christian Wurll (додатковий новий рядок)
|
||||
- <wurll@ira.uka.de>, Erwin Waterlander - <waterlan@xs4all.nl>
|
||||
(супровідник)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
Сторінка на SourceForge: <https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
ТАКОЖ ПЕРЕГЛЯНЬТЕ
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
839
Agent-Windows/OGP64/usr/share/doc/dos2unix/zh_CN/dos2unix.htm
Normal file
839
Agent-Windows/OGP64/usr/share/doc/dos2unix/zh_CN/dos2unix.htm
Normal file
|
|
@ -0,0 +1,839 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>dos2unix 7.5.6 - DOS/Mac - Unix文件格式转换器</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
||||
<link rev="made" href="mailto:ASSI@walter.nonet" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<ul id="index">
|
||||
<li><a href="#pod">名称</a></li>
|
||||
<li><a href="#pod1">概要</a></li>
|
||||
<li><a href="#pod2">说明</a></li>
|
||||
<li><a href="#pod3">选项</a></li>
|
||||
<li><a href="#Mac">Mac模式</a></li>
|
||||
<li><a href="#pod5">转换模式</a></li>
|
||||
<li><a href="#UNICODE">UNICODE</a>
|
||||
<ul>
|
||||
<li><a href="#pod6">编码</a></li>
|
||||
<li><a href="#pod7">转换</a></li>
|
||||
<li><a href="#pod8">字节序标记</a></li>
|
||||
<li><a href="#Windows-Unicode">Windows中Unicode文件的文件名</a></li>
|
||||
<li><a href="#Unicode">Unicode示例</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a href="#GB18030">GB18030</a></li>
|
||||
<li><a href="#pod9">示例</a></li>
|
||||
<li><a href="#pod10">递归转换</a></li>
|
||||
<li><a href="#pod11">区域</a></li>
|
||||
<li><a href="#pod12">返回值</a></li>
|
||||
<li><a href="#pod13">遵循规范</a></li>
|
||||
<li><a href="#pod14">作者</a></li>
|
||||
<li><a href="#pod15">参见</a></li>
|
||||
</ul>
|
||||
|
||||
<h1 id="pod">名称</h1>
|
||||
|
||||
<p>dos2unix - DOS/Mac - Unix文件格式转换器</p>
|
||||
|
||||
<h1 id="pod1">概要</h1>
|
||||
|
||||
<pre><code>dos2unix [选项] [文件 …] [-n 输入文件 输出文件 ...]
|
||||
unix2dos [选项] [文件 …] [-n 输入文件 输出文件 ...]</code></pre>
|
||||
|
||||
<h1 id="pod2">说明</h1>
|
||||
|
||||
<p>本dos2unix软件包包括<code>dos2unix</code>和<code>unix2dos</code>工具,可用于将纯文本文件在DOS或Mac格式与Unix格式之间相互转换。</p>
|
||||
|
||||
<p>DOS/Windows的文本文件中,断行符是由两个字符共同表示的:回车符(CR)和换行符(LF)。Unix的文本文件中,换行符则由单个换行符(LF)表示。而Mac的文本文件则由单个回车符(CR,用于Mac OS X之前的系统)或单个换行符(LF,用于当下的新Mac OS)表示。</p>
|
||||
|
||||
<p>除了断行符,dos2unix还可以转换文件编码。一些DOS编码页可以被转换为Unix Latin-1,Windows Unicode(UTF-16)文件也可以被转换为Unix Unicode(UTF-8)文件。</p>
|
||||
|
||||
<p>二进制文件则会被自动跳过,除非指定了强制转换选项。</p>
|
||||
|
||||
<p>特殊文件,如目录和队列,会被自动跳过。</p>
|
||||
|
||||
<p>符号链接和其所指向的目标默认不会被转换。可以用选项来指定替换符号链接,或者将输出写入到链接目标。Windows下不支持写入到符号链接的目标。</p>
|
||||
|
||||
<p>dos2unix参照SunOS/Solaris下的版本改写而成。这两个版本间有一个重大差异:本版本默认进行原位转换(旧文件模式),而原来SunOS/Solaris下的版本只支持配对转换(新文件模式),参见选项 <code>-o</code> 和 <code>-n</code>。还有一个区别是SunOS/Solaris下的版本默认使用 <i>iso</i> 模式,而本版本默认使用 <i>ascii</i> 模式。</p>
|
||||
|
||||
<h1 id="pod3">选项</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod4"><b>--</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将后面所有的选项当作文件名。如果你希望转换一个文件名以破折号开头的文件,可以使用这个选项。例如,要转换一个名为“-foo”的文件,你可以用这个命令:</p>
|
||||
|
||||
<pre><code>dos2unix -- -foo</code></pre>
|
||||
|
||||
<p>或者在新文件模式下:</p>
|
||||
|
||||
<pre><code>dos2unix -n -- -foo out.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="allow-chown"><b>--allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>在旧文件模式下,允许修改文件的所有者。</p>
|
||||
|
||||
<p>若使用此选项,将允许在转换文件时原始文件的属主或属组发生变更,类似于使用新文件模式进行转换。另请参见选项<code>-o</code> 和 <code>-n</code>。仅当 dos2unix 支持保护文件的属主/属组时才能使用该选项。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ascii"><b>-ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>默认转换模式。。参见 CONVERSION MODES 一节。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso"><b>-iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>在DOS和ISO-8859-1字符集之间转换。参见 CONVERSION MODES 一节。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-1252"><b>-1252</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用Windows 1252 编码页(西欧)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-437"><b>-437</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用DOS 437 编码页(美国)。这是ISO转换时的默认编码页。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-850"><b>-850</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用DOS 850 编码页(西欧)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-860"><b>-860</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用DOS 860 编码页(葡萄牙)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-863"><b>-863</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用DOS 863 编码页(加拿大法语)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-865"><b>-865</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用DOS 865 编码页(北欧)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="pod-7"><b>-7</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将8位字符转换到7位空间。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b---keep-bom"><b>-b, --keep-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>保留字节序标记(BOM)。当输入文件含有BOM头时,也向输出文件写入BOM。这是转换到DOS断行符时的默认行为。参见选项 <code>-r</code>。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c---convmode"><b>-c, --convmode 转换模式</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>改变转换模式。转换模式可以为:<i>ascii</i>、<i>7bit</i>、<i>iso</i>或<i>mac</i>,默认为ascii。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="D---display-enc-ENCODAGE"><b>-D, --display-enc ENCODAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>设置显示文本的编码。编码可以为:<i>ansi</i>、<i>unicode</i>、<i>unicodebom</i>、<i>utf8</i>、<i>utf8bom</i>,默认为 ansi。</p>
|
||||
|
||||
<p>这一选项只对支持Unicode文件名的Windows版dos2unix有效。它对文件名的读写无效,只影响它们的显示结果。</p>
|
||||
|
||||
<p>在Windows控制台中,有几种可以根据文本编码来显示文本的方法。它们各有利弊。</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ansi"><b>ansi</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>dos2unix默认使用ANSI编码文本。优点是它能提供向后兼容性,并能用于raster和TrueType字体。在一些地方,你可能需要使用 <code>chcp</code> 命令将活动DOS OEM编码页设置为Windows系统ANSI编码页,因为dos2unix使用Windows系统编码页。</p>
|
||||
|
||||
<p>ansi的缺点是含有非系统默认编码页中字符的国际化文件名将无法被正确显示。你会看到一些问号或其他错误的字符。如果你不需要处理外文文件名,这一方法是不错的选择。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="unicode-unicodebom"><b>unicode,unicodebom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Unicode编码(Windows中对UTF-16的称呼)的优点是文本可以被正确显示,也无需改变活动编码页。你可能需要设置终端字体为TrueType以便正确显示国际化字符。如果TrueType字体中不包含某个字符,你会看到一个小方块,有时方块中还会有一个问号。</p>
|
||||
|
||||
<p>当你使用ConEmu终端时,所以的文本将会被正确显示,因为ConEmu会自动选择合适的字体。</p>
|
||||
|
||||
<p>Unicode的缺点在于它与ASCII不兼容。当你将输出重定向到其他程序或文件时,它可能不那么容易处理。</p>
|
||||
|
||||
<p>当使用 <code>unicodebom</code> 方法时,将会在Unicode文本前添加一个BOM(字节序标记)。在PowerShell中,需要根据BOM来进行正确的重定向或管道输出。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="utf8-utf8bom"><b>utf8,utf8bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>utf8的优点在于它与ASCII兼容。你需要设置终端的字体为TrueType字体。使用TrueType字体可以使得文本得以正确显示,就像使用 <code>unicode</code> 编码时那样。</p>
|
||||
|
||||
<p>缺点是当你使用默认的raster字体时,所有的非ASCII字符将无法被正确显示。不仅是unicode文件名,连翻译的消息也无法被读取。在配置为东亚地区的Windows中,当终端中显示这些消息时你可能会看到闪烁现象。</p>
|
||||
|
||||
<p>在ConEmu终端中,utf编码方式可以正常工作。</p>
|
||||
|
||||
<p>当使用 <code>utf8bom</code> 方法时,将会在Unicode文本前添加一个BOM(字节序标记)。在PowerShell中,需要根据BOM来进行正确的重定向或管道输出。</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>默认的编码方式可以通过设置 DOS2UNIX_DISPLAY_ENC 环境变量为 <code>unicode</code> 、<code>unicodebom</code>、<code>utf8</code> 或 <code>utf8bom</code> 来改变。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e---add-eol"><b>-e, --add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>如果文件末尾缺少换行符,则追加一个换行符。每次转换时均执行此操作。</p>
|
||||
|
||||
<p>从DOS转换至Unix格式的文件的末尾可能缺少换行符;部分文本编辑器也会主动忽略文本文件末尾的换行符。由于POSIX规范要求文本文件中的每一行必须以换行符结尾,部分Unix程序在处理此类缺少末尾换行符的文件时可能存在问题,例如:拼接两个文本文件时,第一个文件的最后一行会直接与第二个文件的第一行相连,从而产生非预期的结果。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="error-binary"><b>--error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Return an error if a binary file is skipped.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="f---force"><b>-f, --force</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>强制转换二进制文件。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="gb---gb18030"><b>-gb, --gb18030</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>在Windows中,UTF-16默认被转换为UTF-8格式,无论区域设置为何。请使用这一选项将UTF-16文件转换为GB18030格式。此选项只在Windows下有效。参加 GB18030 一节。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h---help"><b>-h, --help</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示帮助,然后退出。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="i---info"><b>-i[标志], --info[=标志] 文件 …</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示文件信息。不进行转换。</p>
|
||||
|
||||
<p>将会显示下列信息(按顺序):DOS断行符的数量、Unix断行符的数量、Mac断行符的数量、是否有BOM、文本/二进制、文件名。</p>
|
||||
|
||||
<p>输出示例:</p>
|
||||
|
||||
<pre><code> 6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe</code></pre>
|
||||
|
||||
<p>注意,二进制文件有时会被误判为文本文件。参见选项 <code>-s</code>。</p>
|
||||
|
||||
<p>如果额外使用了 <code>-e</code> 或 <code>--add-eol</code> 选项,则最后一行的断行符类型也会被显示,或者在缺失的情况下显示 <code>noeol</code>。</p>
|
||||
|
||||
<p>输出示例:</p>
|
||||
|
||||
<pre><code>6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt</code></pre>
|
||||
|
||||
<p>可以为输出设置额外的标志(一个或多个)。</p>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="pod0"><b>0</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>使用零字符("\0")而非换行符来分割文件信息行。用于在指定了 c 选项的情况下,正确解析含有空格或引号的文件名。请结合 xargs(1) 的选项 <code>-0</code> 或 <code>--null</code> 来使用。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="d"><b>d</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示DOS断行符的数量。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u"><b>u</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示Unix断行符的数量。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m"><b>m</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示Mac断行符的数量。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="b"><b>b</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示BOM状况。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="t"><b>t</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示文件为文本或二进制。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="e"><b>e</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示最后一行的断行符类型,如果不存在则显示 <code>noeol</code>。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="c"><b>c</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>只显示将会被转换的文件。</p>
|
||||
|
||||
<p>若设置了 <code>c</code>标志,dos2unix将只显示含有DOS断行符的文件,unix2dos将只显示含有Unix断行符的文件。</p>
|
||||
|
||||
<p>如果额外使用了 <code>-e</code> 或 <code>--add-eol</code> 选项,则最后一行缺失断行符的文件将被显示。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="h"><b>h</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示头部。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="p"><b>p</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示不含路径的文件名。</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p>示例:</p>
|
||||
|
||||
<p>显示所有 *.txt 文件的信息:</p>
|
||||
|
||||
<pre><code>dos2unix -i *.txt</code></pre>
|
||||
|
||||
<p>只显示DOS断行符和Unix断行符的数量:</p>
|
||||
|
||||
<pre><code>dos2unix -idu *.txt</code></pre>
|
||||
|
||||
<p>只显示BOM状况:</p>
|
||||
|
||||
<pre><code>dos2unix --info=b *.txt</code></pre>
|
||||
|
||||
<p>列出含有DOS断行符的文件:</p>
|
||||
|
||||
<pre><code>dos2unix -ic *.txt</code></pre>
|
||||
|
||||
<p>列出含有Unix断行符的文件:</p>
|
||||
|
||||
<pre><code>unix2dos -ic *.txt</code></pre>
|
||||
|
||||
<p>列出含有DOS断行符或最后一行缺少断行符的文件:</p>
|
||||
|
||||
<pre><code>dos2unix -e -ic *.txt</code></pre>
|
||||
|
||||
<p>只转换含有DOS断行符的文件,保持其他文件不变:</p>
|
||||
|
||||
<pre><code>dos2unix -ic0 *.txt | xargs -0 dos2unix</code></pre>
|
||||
|
||||
<p>查找含有DOS断行符的文本文件:</p>
|
||||
|
||||
<pre><code>find -name '*.txt' -print0 | xargs -0 dos2unix -ic</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="k---keepdate"><b>-k, --keepdate</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将输入文件的时间戳应用到输出文件。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="L---license"><b>-L, --license</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示程序许可证。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="l---newline"><b>-l, --newline</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>添加额外的新行。</p>
|
||||
|
||||
<p><b>dos2unix</b>:只有DOS断行符会被转换为两个Unix断行符。在Mac模式下,只有Mac断行符会被转换为Unix断行符。</p>
|
||||
|
||||
<p><b>unix2dos</b>:只有Unix断行符会被转换为两个DOS断行符。在Mac模式下,Unix断行符会被转换为两个Mac断行符。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="m---add-bom"><b>-m, --add-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将字节序标记(BOM)写入到输出文件。默认情况下将写入UTF-8 BOM。</p>
|
||||
|
||||
<p>当输入文件为UTF-16格式,并且使用了 <code>-u</code>选项,将写入UTF-16 BOM。</p>
|
||||
|
||||
<p>当输出文件不是UTF-8、UTF-16或GB18030格式时,请不要使用此选项。参加 UNICODE 一节。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="n---newline"><b>-n, --newline 输入文件 输出文件 ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>新文件模式。转换输入文件并写入到输出文件。文件名必须成对给出,并且 <i>不能</i> 使用通配符,否则你 <i>将会</i>丢失文件。</p>
|
||||
|
||||
<p>使用新文件(配对)模式转换时,命令执行者必须为文件的所有者。新文件的读/写权限将由源文件的权限减去命令执行者的 umask(1) 得到。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-allow-chown"><b>--no-allow-chown</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>在旧文件模式下,不允许修改文件的所有者(默认选项)。</p>
|
||||
|
||||
<p>当原始文件的属主/属组无法保持不变时,停止格式转换。另请参见<code>-o</code> 和 <code>-n</code>选项。仅当 dos2unix 支持保护文件的属主/属组时才能使用该选项。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-add-eol"><b>--no-add-eol</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not add a line break to the last line if there isn't one (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="no-error-binary"><b>--no-error-binary</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Do not return an error if a binary file is skipped (default).</p>
|
||||
|
||||
</dd>
|
||||
<dt id="O---to-stdout"><b>-O, --to-stdout</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将结果重定向至标准输出(类似Unix过滤器)。可以使用选项 <code>-o</code> 来切换回旧文件(原位修改)模式。</p>
|
||||
|
||||
<p>与选项 <code>-e</code>一起使用时,可以确保拼接文件时上一个文件的最后一行不会错误地与下一个文件的第一行合并,且不会受到Unicode字节序记号的干扰。例如:</p>
|
||||
|
||||
<pre><code>dos2unix -e -O file1.txt file2.txt > output.txt</code></pre>
|
||||
|
||||
</dd>
|
||||
<dt id="o---oldfile"><b>-o, --oldfile 文件 ...</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>旧文件模式。转换并将输出覆盖到源文件。程序默认使用此模式,允许使用通配符。</p>
|
||||
|
||||
<p>在旧文件(替换)模式下,被转换的文件的所有者、组和读/写权限保持不变。当文件被其他具有写权限的用户(如root)转换时,情况也是如此。如果无法保持这些值不变,转换将会终止。改变源文件的所有者可能造成其无法读取该文件,而改变组则可能带来安全隐患,使文件被不法分子读取。只有Unix才支持转换时保留所有者、组和读/写权限。</p>
|
||||
|
||||
<p>若要查看 dos2unix 是否支持保护文件的所有者,请输入<code>dos2unix -V</code>。</p>
|
||||
|
||||
<p>dos2unix 在转换格式时会生成一个临时文件。如果在转换时出错,它会删除临时文件,从而保证原始文件不被更改;如果转换成功,将用临时文件替换原始文件。在这一过程中,如果 dos2unix 无法将临时文件的所有者设置为原始文件的所有者,那么新生成的文件也无法保留原始文件的属主/属组属性(即便您对原始文件有写入权限)。在这种情况下,可以使用<code>--allow-chown</code>选项来继续进行转换:</p>
|
||||
|
||||
<pre><code>dos2unix --allow-chown foo.txt</code></pre>
|
||||
|
||||
<p>或者在新文件模式下:</p>
|
||||
|
||||
<pre><code>dos2unix -n foo.txt foo.txt</code></pre>
|
||||
|
||||
<p>使用<code>--allow-chown</code>选项的好处在于:您可以使用通配符来操作文件,同时尽可能保持文件的所有者不变。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="q---quiet"><b>-q, --quiet</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>安静模式。不显示任何警告或信息。返回值为0,除非命令行选项有误。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="r---remove-bom"><b>-r, --remove-bom</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>移除字节序标记(BOM),不写入BOM到输出文件。这是转换到Unix断行符时的默认行为。参见选项 <code>-b</code>。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="s---safe"><b>-s, --safe</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>跳过二进制文件(默认)。</p>
|
||||
|
||||
<p>跳过二进制文件是为了避免可能的错误。请注意,对二进制文件的探测并不能做到100%准确。程序通过扫描二进制文件所特有的标记来将其与文本文件区分开来,但有的二进制文件可能只包含普通的文本字符,这样的文件就会被误判为文本文件。</p>
|
||||
|
||||
<p>By default, no error is returned when a binary file is skipped. When the <code>--error-binary</code> option is used, an error is returned.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="u---keep-utf16"><b>-u, --keep-utf16</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Keep the original UTF-16 encoding of the input file. The output file will be written in the same UTF-16 encoding, little- or big-endian, as the input file. This prevents transformation to UTF-8. An UTF-16 BOM will be written accordingly. This option can be disabled with the <code>-ascii</code> option.</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ul---assume-utf16le"><b>-ul, --assume-utf16le</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>假定输入文件格式为UTF-16LE。</p>
|
||||
|
||||
<p>输入文件中有BOM时,将会覆盖此选项。</p>
|
||||
|
||||
<p>如果你做了错误的假设(输入文件不为UTF-16LE格式),并且转换成功,你将会得到一个错误的UTF-8格式的文件。你可以用 iconv(1) 来撤销转换,将其从UTF-8转换回UTF-16LE。这样做可以恢复源文件。</p>
|
||||
|
||||
<p>对UTF-16LE的假定将根据 l<转换模式> 来工作。若改变了默认的 l<ascii> 模式,则这一假定将会被关闭。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="ub---assume-utf16be"><b>-ub, --assume-utf16be</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>假定输入文件格式为UTF-16BE。</p>
|
||||
|
||||
<p>这一选项与 <code>-ul</code> 类似。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="v---verbose"><b>-v, --verbose</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示更多信息。将会显示有关BOM和转换统计的额外信息。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="F---follow-symlink"><b>-F, --follow-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>追踪符号链接并转换其目标。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="R---replace-symlink"><b>-R, --replace-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>将符号链接的目标替换为转换后的文件(原来的目标文件保持不变)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="S---skip-symlink"><b>-S, --skip-symlink</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>保持符号链接和其目标文件不变(默认)。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="V---version"><b>-V, --version</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>显示版本信息,然后退出。</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="Mac">Mac模式</h1>
|
||||
|
||||
<p>默认情况下断行符将从DOS格式转换为Unix格式,或相反。Mac格式的断行符将不会被转换。</p>
|
||||
|
||||
<p>Mac模式下,Mac断行符将被转换为Unix格式,或相反。DOS断行符将不会被转换。</p>
|
||||
|
||||
<p>若要以Mac模式运行,请使用命令行选项 <code>-c mac</code>,或使用命令 <code>mac2unix</code> 或 <code>unix2mac</code>。</p>
|
||||
|
||||
<h1 id="pod5">转换模式</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="ascii1"><b>ascii</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>这是默认转换模式。该模式用于转换ASCII和ASCII兼容编码的文件,例如UTF-8。启用<b>ascii</b>模式会禁用<b>7bit</b>和<b>iso</b>模式。</p>
|
||||
|
||||
<p>如果dos2unix带有UTF-16支持,则UTF-16编码的文件在POSIX系统上将被转换为当前语区对应的字符编码,在Windows上则会被转换为UTF-8。启用 <b>ascii</b> 模式将禁用维持UTF-16编码的选项(<code>-u</code>)和假定输入为UTF-16的选项(<code>-ul</code> 和 <code>-ub</code>)。如需查看dos2unix是否带有UTF-16支持,请运行 <code>dos2unix -V</code>。更多信息另请参见 UNICODE 章节。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="bit"><b>7bit</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>在此模式下,所以的8位非ASCII字符(取值范围128-255)将被转换到7位编码空间。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="iso1"><b>iso</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>Unix下,将在DOS字符集(编码页)和ISO字符集 ISO-8859-1(Latin-1)之间进行转换。不具有 ISO-8859-1 中对等字符的DOS字符将会被转换为点号(“.”)。当 ISO-8859-1 字符集中没有DOS中的对等字符时也是如此。</p>
|
||||
|
||||
<p>当只指定了 <code>-iso</code> 选项时,dos2unix将尝试确定当前活动代码页。若无法确定,则使用默认代码页 CP437(普遍用于美国)。若要强制指定代码页,请使用选项 <code>-437</code>(美国)、<code>-850</code>(西欧)、<code>-860</code>(葡萄牙)、<code>-863</code>(法国、加拿大)或<code>-865</code>(北欧)。 Windows CP1252代码页(西欧)也可以通过选项 <code>-1252</code> 获得支持。若要使用其他代码页,可以结合 iconv(1) 使用dos2unix。iconv可以在很多字符编码间进行转换。</p>
|
||||
|
||||
<p>不对Unicode编码文本使用ISO转换。因这一转换会导致UTF-8编码文件损坏。</p>
|
||||
|
||||
<p>一些示例:</p>
|
||||
|
||||
<p>从DOS默认编码页转换到Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从DOS CP850转换到Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从Windows CP1252转换到Unix Latin-1:</p>
|
||||
|
||||
<pre><code>dos2unix -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从WIndows CP1252转换到Unix UTF-8(Unicode):</p>
|
||||
|
||||
<pre><code>iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt</code></pre>
|
||||
|
||||
<p>从Unix Latin-1转换到DOS默认编码页:</p>
|
||||
|
||||
<pre><code>unix2dos -iso -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从Unix Latin-1转换到DOS CP850:</p>
|
||||
|
||||
<pre><code>unix2dos -850 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从Unix Latin-1转换到Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos -1252 -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>从Unix UTF-8(Unicode)转换到Windows CP1252:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt</code></pre>
|
||||
|
||||
<p>See also <a href="https://czyborra.com/charsets/codepages.html">https://czyborra.com/charsets/codepages.html</a> and <a href="https://czyborra.com/charsets/iso8859.html">https://czyborra.com/charsets/iso8859.html</a>.</p>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="UNICODE">UNICODE</h1>
|
||||
|
||||
<h2 id="pod6">编码</h2>
|
||||
|
||||
<p>There exist different Unicode encodings. On Unix and Linux Unicode files are typically encoded in UTF-8 encoding. On Windows Unicode text files can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly encoded in UTF-16 format.</p>
|
||||
|
||||
<h2 id="pod7">转换</h2>
|
||||
|
||||
<p>Unicode文本文件可以含有DOS、Unix或Mac断行符,就像ASCII文本文件一样。</p>
|
||||
|
||||
<p>所有版本的dos2unix和unix2dos都可以转换UTF-8文件,因为UTF-8向后兼容ASCII。</p>
|
||||
|
||||
<p>dos2unix and unix2dos with Unicode UTF-16 support, can read little- and big-endian UTF-16 encoded text files. To see if dos2unix was built with UTF-16 support type <code>dos2unix -V</code>.</p>
|
||||
|
||||
<p>在Unix/Linux中,UTF-16编码文件将被转换为区域字符编码所指定的编码。可以使用 locale(1) 命令来查看当前的区域字符编码。若无法转换,程序将报告转换错误并跳过此文件。</p>
|
||||
|
||||
<p>在Windows中,UTF-16文件被默认转换为UTF-8格式。Windows和Unix/Linux均支持UTF-8格式的文本文件。</p>
|
||||
|
||||
<p>UTF-16和UTF-8编码相互兼容,所以彼此转换时不会丢失文本。倘若转换中出错,比如UTF-16格式的输入文件含有错误,那么该文件将被跳过。</p>
|
||||
|
||||
<p>若使用了 <code>-u</code> 选项,输出文件将会使用和输入文件相同的UTF-16编码。<code>-u</code>选项将阻止程序转换到UTF-8。</p>
|
||||
|
||||
<p>dos2unix和unix2dos没有用于转换UTF-8到UTF-16的选项。</p>
|
||||
|
||||
<p>ISO和7位编码模式的转换无法用于UTF-16文件。</p>
|
||||
|
||||
<h2 id="pod8">字节序标记</h2>
|
||||
|
||||
<p>在Windows中,文本文件一般含有字节序标记(BOM),因为很多Windows程序(包括记事本)默认添加BOM。参见 <a href="https://en.wikipedia.org/wiki/Byte_order_mark">https://en.wikipedia.org/wiki/Byte_order_mark</a>。</p>
|
||||
|
||||
<p>在Unix中,Unicode文件一般不含BOM。假定文本文件使用区域字符编码设置所指定的编码。</p>
|
||||
|
||||
<p>dos2unix只能检测含有BOM文件的UTF-16格式。若UTF-16文件不含BOM,dos2unix会将其视作二进制文件。</p>
|
||||
|
||||
<p>请使用选项 <code>-ul</code> 或 <code>-ub</code> 来转换不含BOM的UTF-16文件。</p>
|
||||
|
||||
<p>dos2unix默认不输出BOM。使用 <code>-b</code> 选项可以让dos2unix将BOM添加到输出文件,如果输入文件也含有BOM的话。</p>
|
||||
|
||||
<p>unix2dos默认输出BOM,如果输入文件也含有BOM的话。使用 <code>-r</code> 可以移除BOM。</p>
|
||||
|
||||
<p>若使用了 <code>-m</code> 选项,dos2unix和unix2dos将总是输出BOM。</p>
|
||||
|
||||
<h2 id="Windows-Unicode">Windows中Unicode文件的文件名</h2>
|
||||
|
||||
<p>dos2unix对于Windows命令提示符中读取和写入Unicode文件名有额外的支持。这意味着dos2unix可以打开那些包含非默认系统ANSI编码页字符的文件。若要查看Windows版dos2unix在编译时是否加入了Unicode文件名支持,请输入 <code>dos2unix -V</code>。</p>
|
||||
|
||||
<p>在Windows终端中显示Unicode文件名有一些需要注意的问题。请参见 <code>-D</code> 和 <code>--display-enc</code> 选项。文件名在终端中可能无法被正确显示,但写入文件时文件名仍然是正确的。</p>
|
||||
|
||||
<h2 id="Unicode">Unicode示例</h2>
|
||||
|
||||
<p>转换Windows UTF-16到Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>转换Windows UTF-16LE(不含BOM)到Unix UTF-8:</p>
|
||||
|
||||
<pre><code>dos2unix -ul -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>转换Unix UTF-8到Windows UTF-8(并添加BOM):</p>
|
||||
|
||||
<pre><code>unix2dos -m -n in.txt out.txt</code></pre>
|
||||
|
||||
<p>转换Unix UTF-8到Windows UTF-16:</p>
|
||||
|
||||
<pre><code>unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt</code></pre>
|
||||
|
||||
<h1 id="GB18030">GB18030</h1>
|
||||
|
||||
<p>GB18030是中国国家标准。GB18030标准的一系列子集被强制应用于中国销售的软件产品。参见 <a href="https://en.wikipedia.org/wiki/GB_18030">https://en.wikipedia.org/wiki/GB_18030</a>。</p>
|
||||
|
||||
<p>GB18030与Unicode完全兼容,并且可以被认为是Unicode格式的变体。和UTF-8一样,GB18030也兼容ASCII。GB18030也兼容Windows 936代码页(GBK)。</p>
|
||||
|
||||
<p>在Unix/Linux中,若区域编码被设置为GB18030,UTF-16文件将被转换为GB18030格式。注意只有当系统支持区域设置时这一才会进行这一转换。可以使用 <code>locale -a</code> 命令来获取受支持的区域。</p>
|
||||
|
||||
<p>在Windows中,你需要使用 <code>-gb</code> 选项来转换UTF-16文件到GB18030编码。</p>
|
||||
|
||||
<p>GB18030编码的文件和Unicode文件一样可以含有BOM。</p>
|
||||
|
||||
<h1 id="pod9">示例</h1>
|
||||
|
||||
<p>从标准输入读取,并输出到标准输出:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>转换并覆盖a.txt和b.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt</code></pre>
|
||||
|
||||
<p>转换并覆盖a.txt,使用ascii模式:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt</code></pre>
|
||||
|
||||
<p>转换并覆盖a.txt,使用ascii模式;转换并覆盖b.txt,使用7位编码模式:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt</code></pre>
|
||||
|
||||
<p>将a.txt从Mac格式转换到Unix格式:</p>
|
||||
|
||||
<pre><code>dos2unix -c mac a.txt
|
||||
mac2unix a.txt</code></pre>
|
||||
|
||||
<p>将a.txt从Unix格式转换到Mac格式:</p>
|
||||
|
||||
<pre><code>unix2dos -c mac a.txt
|
||||
unix2mac a.txt</code></pre>
|
||||
|
||||
<p>转换并覆盖a.txt,保留原始时间戳:</p>
|
||||
|
||||
<pre><code>dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt</code></pre>
|
||||
|
||||
<p>转换a.txt,并输出到e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>转换a.txt,并输出到e.txt,同时使e.txt的时间戳和a.txt一致:</p>
|
||||
|
||||
<pre><code>dos2unix -k -n a.txt e.txt</code></pre>
|
||||
|
||||
<p>转换并覆盖a.txt;转换b.txt并输出到e.txt:</p>
|
||||
|
||||
<pre><code>dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt</code></pre>
|
||||
|
||||
<p>转换c.txt并输出到e.txt;转换并覆盖a.txt和b.txt;转换d.txt并输出到f.txt:</p>
|
||||
|
||||
<pre><code>dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt</code></pre>
|
||||
|
||||
<h1 id="pod10">递归转换</h1>
|
||||
|
||||
<p>结合 find(1) 和 xargs(1) 使用 dos2unix 可以递归地转换目录树中的文本文件。例如,转换当前目录的目录树中所有的 .txt 文件:</p>
|
||||
|
||||
<pre><code>dos2unix < a.txt
|
||||
cat a.txt | dos2unix</code></pre>
|
||||
|
||||
<p>若文件名中有空格或引号,则需要使用 find(1) 选项 <code>-print0</code> 及相应的 xargs(1) 选项 <code>-0</code>;其他情况下则可以省略它们。也可以结合 <code>-exec</code> 选项来使用 find(1):</p>
|
||||
|
||||
<pre><code>find . -name '*.txt' -exec dos2unix {} \;</code></pre>
|
||||
|
||||
<p>在Windows命令提示符中,可以使用下列命令:</p>
|
||||
|
||||
<pre><code>for /R %G in (*.txt) do dos2unix "%G"</code></pre>
|
||||
|
||||
<p>PowerShell用户可以在Windows PowerShell中使用如下命令:</p>
|
||||
|
||||
<pre><code>get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}</code></pre>
|
||||
|
||||
<h1 id="pod11">区域</h1>
|
||||
|
||||
<dl>
|
||||
|
||||
<dt id="LANG"><b>LANG</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>LANG环境变量指定了程序所使用的首选语言。它包括几个部分:第一部分是小写的语言编码,第二部分是(可选的)大写的国家/地区代码,前面用下划线连接;第三部分也是可选的,即字符编码,前面用点连接。一些POSIX规范的示例如下:</p>
|
||||
|
||||
<pre><code>export LANG=zh 中文
|
||||
export LANG=zh_CN 中文,中国
|
||||
export LANG=zh_TW 中文,台湾
|
||||
export LANG=es_ES 西班牙语,西班牙
|
||||
export LANG=es_MX 西班牙语,墨西哥
|
||||
export LANG=en_US.iso88591 英语,美国,Latin-1编码
|
||||
export LANG=en_GB.UTF-8 英语,英国,UTF-8编码</code></pre>
|
||||
|
||||
<p>完整的语言和国家/地区编码可以在gettext手册中找到:<a href="https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html">https://www.gnu.org/software/gettext/manual/html_node/Usual-Language-Codes.html</a></p>
|
||||
|
||||
<p>在Unix系统中,你可以使用 locale(1) 命令获取特定区域的信息。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="LANGUAGE"><b>LANGUAGE</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>可以使用LANGUAGE变量指定一系列语言的优先级,各项之间由冒号分割。dos2unix首先使用LANGUAGE变量,其次才是LANG。例如,首选中文、其次英文:<code>LANGUAGE=zh:en</code>。在使用语言优先级之前,必须先启用区域化功能,即将LANG(或LC_ALL)变量设置为除了“C”以外的其他值。参见gettext手册:<a href="https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html">https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html</a></p>
|
||||
|
||||
<p>如果你选择了一个不可用的语言,程序将会输出标准的英语信息。</p>
|
||||
|
||||
</dd>
|
||||
<dt id="DOS2UNIX_LOCALEDIR"><b>DOS2UNIX_LOCALEDIR</b></dt>
|
||||
<dd>
|
||||
|
||||
<p>DOS2UNIX_LOCALEDIR环境变量将覆盖编译时设置的LOCALEDIR变量。LOCALEDIR被用于查找语言文件。GNU程序的默认值为 <code>/usr/local/share/locale</code>。可以使用 <b>--version</b> 查看当前的LOCALEDIR。</p>
|
||||
|
||||
<p>示例(POSIX shell):</p>
|
||||
|
||||
<pre><code>export DOS2UNIX_LOCALEDIR=$HOME/share/locale</code></pre>
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<h1 id="pod12">返回值</h1>
|
||||
|
||||
<p>若成功,返回0。若出现系统错误,则返回最近一次系统错误号。若发生其他错误,返回1。</p>
|
||||
|
||||
<p>在安静模式下,返回值总是为0,除非命令行选项有误。</p>
|
||||
|
||||
<h1 id="pod13">遵循规范</h1>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Text_file">https://en.wikipedia.org/wiki/Text_file</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Carriage_return">https://en.wikipedia.org/wiki/Carriage_return</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Newline">https://en.wikipedia.org/wiki/Newline</a></p>
|
||||
|
||||
<p><a href="https://en.wikipedia.org/wiki/Unicode">https://en.wikipedia.org/wiki/Unicode</a></p>
|
||||
|
||||
<h1 id="pod14">作者</h1>
|
||||
|
||||
<p>Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben(mac2unix模式) - <wuebben@kde.org>,Christian Wurll(添加额外新行) - <wurll@ira.uka.de>,Erwin Waterlander - <waterlan@xs4all.nl>(维护者)</p>
|
||||
|
||||
<p>Project page: <a href="https://waterlander.net/dos2unix/">https://waterlander.net/dos2unix/</a></p>
|
||||
|
||||
<p>SourceForge主页:<a href="https://sourceforge.net/projects/dos2unix/">https://sourceforge.net/projects/dos2unix/</a></p>
|
||||
|
||||
<h1 id="pod15">参见</h1>
|
||||
|
||||
<p>file(1) find(1) iconv(1) locale(1) xargs(1)</p>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
632
Agent-Windows/OGP64/usr/share/doc/dos2unix/zh_CN/dos2unix.txt
Normal file
632
Agent-Windows/OGP64/usr/share/doc/dos2unix/zh_CN/dos2unix.txt
Normal file
|
|
@ -0,0 +1,632 @@
|
|||
名称
|
||||
dos2unix - DOS/Mac - Unix文件格式转换器
|
||||
|
||||
概要
|
||||
dos2unix [选项] [文件 …] [-n 输入文件 输出文件 ...]
|
||||
unix2dos [选项] [文件 …] [-n 输入文件 输出文件 ...]
|
||||
|
||||
说明
|
||||
本dos2unix软件包包括"dos2unix"和"unix2dos"工具,可用于将纯文本文件在DOS或Mac格式与Unix格式之间相互转换。
|
||||
|
||||
DOS/Windows的文本文件中,断行符是由两个字符共同表示的:回车符(CR)和换行符(LF)。Unix的文本文件中,换行符则由单个换行符(L
|
||||
F)表示。而Mac的文本文件则由单个回车符(CR,用于Mac OS X之前的系统)或单个换行符(LF,用于当下的新Mac OS)表示。
|
||||
|
||||
除了断行符,dos2unix还可以转换文件编码。一些DOS编码页可以被转换为Unix Latin-1,Windows
|
||||
Unicode(UTF-16)文件也可以被转换为Unix Unicode(UTF-8)文件。
|
||||
|
||||
二进制文件则会被自动跳过,除非指定了强制转换选项。
|
||||
|
||||
特殊文件,如目录和队列,会被自动跳过。
|
||||
|
||||
符号链接和其所指向的目标默认不会被转换。可以用选项来指定替换符号链接,或者将输出写入到链接目标。Windows下不支持写入到符号链接的目标。
|
||||
|
||||
dos2unix参照SunOS/Solaris下的版本改写而成。这两个版本间有一个重大差异:本版本默认进行原位转换(旧文件模式),而原来SunO
|
||||
S/Solaris下的版本只支持配对转换(新文件模式),参见选项 "-o" 和
|
||||
"-n"。还有一个区别是SunOS/Solaris下的版本默认使用 *iso* 模式,而本版本默认使用 *ascii* 模式。
|
||||
|
||||
选项
|
||||
-- 将后面所有的选项当作文件名。如果你希望转换一个文件名以破折号开头的文件,可以使用这个选项。例如,要转换一个名为“-foo”的文件,你可以
|
||||
用这个命令:
|
||||
|
||||
dos2unix -- -foo
|
||||
|
||||
或者在新文件模式下:
|
||||
|
||||
dos2unix -n -- -foo out.txt
|
||||
|
||||
--allow-chown
|
||||
在旧文件模式下,允许修改文件的所有者。
|
||||
|
||||
若使用此选项,将允许在转换文件时原始文件的属主或属组发生变更,类似于使用新文件模式进行转换。另请参见选项"-o" 和 "-n"。仅当
|
||||
dos2unix 支持保护文件的属主/属组时才能使用该选项。
|
||||
|
||||
-ascii
|
||||
默认转换模式。。参见 CONVERSION MODES 一节。
|
||||
|
||||
-iso
|
||||
在DOS和ISO-8859-1字符集之间转换。参见 CONVERSION MODES 一节。
|
||||
|
||||
-1252
|
||||
使用Windows 1252 编码页(西欧)。
|
||||
|
||||
-437
|
||||
使用DOS 437 编码页(美国)。这是ISO转换时的默认编码页。
|
||||
|
||||
-850
|
||||
使用DOS 850 编码页(西欧)。
|
||||
|
||||
-860
|
||||
使用DOS 860 编码页(葡萄牙)。
|
||||
|
||||
-863
|
||||
使用DOS 863 编码页(加拿大法语)。
|
||||
|
||||
-865
|
||||
使用DOS 865 编码页(北欧)。
|
||||
|
||||
-7 将8位字符转换到7位空间。
|
||||
|
||||
-b, --keep-bom
|
||||
保留字节序标记(BOM)。当输入文件含有BOM头时,也向输出文件写入BOM。这是转换到DOS断行符时的默认行为。参见选项 "-r"。
|
||||
|
||||
-c, --convmode 转换模式
|
||||
改变转换模式。转换模式可以为:*ascii*、*7bit*、*iso*或*mac*,默认为ascii。
|
||||
|
||||
-D, --display-enc ENCODAGE
|
||||
设置显示文本的编码。编码可以为:*ansi*、*unicode*、*unicodebom*、*utf8*、*utf8bom*,默认为
|
||||
ansi。
|
||||
|
||||
这一选项只对支持Unicode文件名的Windows版dos2unix有效。它对文件名的读写无效,只影响它们的显示结果。
|
||||
|
||||
在Windows控制台中,有几种可以根据文本编码来显示文本的方法。它们各有利弊。
|
||||
|
||||
ansi
|
||||
dos2unix默认使用ANSI编码文本。优点是它能提供向后兼容性,并能用于raster和TrueType字体。在一些地方,你可
|
||||
能需要使用 "chcp" 命令将活动DOS
|
||||
OEM编码页设置为Windows系统ANSI编码页,因为dos2unix使用Windows系统编码页。
|
||||
|
||||
ansi的缺点是含有非系统默认编码页中字符的国际化文件名将无法被正确显示。你会看到一些问号或其他错误的字符。如果你不需要处理外文
|
||||
文件名,这一方法是不错的选择。
|
||||
|
||||
unicode,unicodebom
|
||||
Unicode编码(Windows中对UTF-16的称呼)的优点是文本可以被正确显示,也无需改变活动编码页。你可能需要设置终端字
|
||||
体为TrueType以便正确显示国际化字符。如果TrueType字体中不包含某个字符,你会看到一个小方块,有时方块中还会有一个问
|
||||
号。
|
||||
|
||||
当你使用ConEmu终端时,所以的文本将会被正确显示,因为ConEmu会自动选择合适的字体。
|
||||
|
||||
Unicode的缺点在于它与ASCII不兼容。当你将输出重定向到其他程序或文件时,它可能不那么容易处理。
|
||||
|
||||
当使用 "unicodebom"
|
||||
方法时,将会在Unicode文本前添加一个BOM(字节序标记)。在PowerShell中,需要根据BOM来进行正确的重定向或管道
|
||||
输出。
|
||||
|
||||
utf8,utf8bom
|
||||
utf8的优点在于它与ASCII兼容。你需要设置终端的字体为TrueType字体。使用TrueType字体可以使得文本得以正确显
|
||||
示,就像使用 "unicode" 编码时那样。
|
||||
|
||||
缺点是当你使用默认的raster字体时,所有的非ASCII字符将无法被正确显示。不仅是unicode文件名,连翻译的消息也无法被
|
||||
读取。在配置为东亚地区的Windows中,当终端中显示这些消息时你可能会看到闪烁现象。
|
||||
|
||||
在ConEmu终端中,utf编码方式可以正常工作。
|
||||
|
||||
当使用 "utf8bom"
|
||||
方法时,将会在Unicode文本前添加一个BOM(字节序标记)。在PowerShell中,需要根据BOM来进行正确的重定向或管道
|
||||
输出。
|
||||
|
||||
默认的编码方式可以通过设置 DOS2UNIX_DISPLAY_ENC 环境变量为 "unicode"
|
||||
、"unicodebom"、"utf8" 或 "utf8bom" 来改变。
|
||||
|
||||
-e, --add-eol
|
||||
如果文件末尾缺少换行符,则追加一个换行符。每次转换时均执行此操作。
|
||||
|
||||
从DOS转换至Unix格式的文件的末尾可能缺少换行符;部分文本编辑器也会主动忽略文本文件末尾的换行符。由于POSIX规范要求文本文件中的
|
||||
每一行必须以换行符结尾,部分Unix程序在处理此类缺少末尾换行符的文件时可能存在问题,例如:拼接两个文本文件时,第一个文件的最后一行会直
|
||||
接与第二个文件的第一行相连,从而产生非预期的结果。
|
||||
|
||||
--error-binary
|
||||
Return an error if a binary file is skipped.
|
||||
|
||||
-f, --force
|
||||
强制转换二进制文件。
|
||||
|
||||
-gb, --gb18030
|
||||
在Windows中,UTF-16默认被转换为UTF-8格式,无论区域设置为何。请使用这一选项将UTF-16文件转换为GB18030格式。
|
||||
此选项只在Windows下有效。参加 GB18030 一节。
|
||||
|
||||
-h, --help
|
||||
显示帮助,然后退出。
|
||||
|
||||
-i[标志], --info[=标志] 文件 …
|
||||
显示文件信息。不进行转换。
|
||||
|
||||
将会显示下列信息(按顺序):DOS断行符的数量、Unix断行符的数量、Mac断行符的数量、是否有BOM、文本/二进制、文件名。
|
||||
|
||||
输出示例:
|
||||
|
||||
6 0 0 no_bom text dos.txt
|
||||
0 6 0 no_bom text unix.txt
|
||||
0 0 6 no_bom text mac.txt
|
||||
6 6 6 no_bom text mixed.txt
|
||||
50 0 0 UTF-16LE text utf16le.txt
|
||||
0 50 0 no_bom text utf8unix.txt
|
||||
50 0 0 UTF-8 text utf8dos.txt
|
||||
2 418 219 no_bom binary dos2unix.exe
|
||||
|
||||
注意,二进制文件有时会被误判为文本文件。参见选项 "-s"。
|
||||
|
||||
如果额外使用了 "-e" 或 "--add-eol" 选项,则最后一行的断行符类型也会被显示,或者在缺失的情况下显示 "noeol"。
|
||||
|
||||
输出示例:
|
||||
|
||||
6 0 0 no_bom text dos dos.txt
|
||||
0 6 0 no_bom text unix unix.txt
|
||||
0 0 6 no_bom text mac mac.txt
|
||||
1 0 0 no_bom text noeol noeol_dos.txt
|
||||
|
||||
可以为输出设置额外的标志(一个或多个)。
|
||||
|
||||
0 使用零字符("\0")而非换行符来分割文件信息行。用于在指定了 c 选项的情况下,正确解析含有空格或引号的文件名。请结合
|
||||
xargs(1) 的选项 -0 或 "--null" 来使用。
|
||||
|
||||
d 显示DOS断行符的数量。
|
||||
|
||||
u 显示Unix断行符的数量。
|
||||
|
||||
m 显示Mac断行符的数量。
|
||||
|
||||
b 显示BOM状况。
|
||||
|
||||
t 显示文件为文本或二进制。
|
||||
|
||||
e 显示最后一行的断行符类型,如果不存在则显示 "noeol"。
|
||||
|
||||
c 只显示将会被转换的文件。
|
||||
|
||||
若设置了 "c"标志,dos2unix将只显示含有DOS断行符的文件,unix2dos将只显示含有Unix断行符的文件。
|
||||
|
||||
如果额外使用了 "-e" 或 "--add-eol" 选项,则最后一行缺失断行符的文件将被显示。
|
||||
|
||||
h 显示头部。
|
||||
|
||||
p 显示不含路径的文件名。
|
||||
|
||||
示例:
|
||||
|
||||
显示所有 *.txt 文件的信息:
|
||||
|
||||
dos2unix -i *.txt
|
||||
|
||||
只显示DOS断行符和Unix断行符的数量:
|
||||
|
||||
dos2unix -idu *.txt
|
||||
|
||||
只显示BOM状况:
|
||||
|
||||
dos2unix --info=b *.txt
|
||||
|
||||
列出含有DOS断行符的文件:
|
||||
|
||||
dos2unix -ic *.txt
|
||||
|
||||
列出含有Unix断行符的文件:
|
||||
|
||||
unix2dos -ic *.txt
|
||||
|
||||
列出含有DOS断行符或最后一行缺少断行符的文件:
|
||||
|
||||
dos2unix -e -ic *.txt
|
||||
|
||||
只转换含有DOS断行符的文件,保持其他文件不变:
|
||||
|
||||
dos2unix -ic0 *.txt | xargs -0 dos2unix
|
||||
|
||||
查找含有DOS断行符的文本文件:
|
||||
|
||||
find -name '*.txt' -print0 | xargs -0 dos2unix -ic
|
||||
|
||||
-k, --keepdate
|
||||
将输入文件的时间戳应用到输出文件。
|
||||
|
||||
-L, --license
|
||||
显示程序许可证。
|
||||
|
||||
-l, --newline
|
||||
添加额外的新行。
|
||||
|
||||
dos2unix:只有DOS断行符会被转换为两个Unix断行符。在Mac模式下,只有Mac断行符会被转换为Unix断行符。
|
||||
|
||||
unix2dos:只有Unix断行符会被转换为两个DOS断行符。在Mac模式下,Unix断行符会被转换为两个Mac断行符。
|
||||
|
||||
-m, --add-bom
|
||||
将字节序标记(BOM)写入到输出文件。默认情况下将写入UTF-8 BOM。
|
||||
|
||||
当输入文件为UTF-16格式,并且使用了 "-u"选项,将写入UTF-16 BOM。
|
||||
|
||||
当输出文件不是UTF-8、UTF-16或GB18030格式时,请不要使用此选项。参加 UNICODE 一节。
|
||||
|
||||
-n, --newline 输入文件 输出文件 ...
|
||||
新文件模式。转换输入文件并写入到输出文件。文件名必须成对给出,并且 *不能* 使用通配符,否则你 *将会*丢失文件。
|
||||
|
||||
使用新文件(配对)模式转换时,命令执行者必须为文件的所有者。新文件的读/写权限将由源文件的权限减去命令执行者的 umask(1) 得到。
|
||||
|
||||
--no-allow-chown
|
||||
在旧文件模式下,不允许修改文件的所有者(默认选项)。
|
||||
|
||||
当原始文件的属主/属组无法保持不变时,停止格式转换。另请参见"-o" 和 "-n"选项。仅当 dos2unix
|
||||
支持保护文件的属主/属组时才能使用该选项。
|
||||
|
||||
--no-add-eol
|
||||
Do not add a line break to the last line if there isn't one
|
||||
(default).
|
||||
|
||||
--no-error-binary
|
||||
Do not return an error if a binary file is skipped (default).
|
||||
|
||||
-O, --to-stdout
|
||||
将结果重定向至标准输出(类似Unix过滤器)。可以使用选项 "-o" 来切换回旧文件(原位修改)模式。
|
||||
|
||||
与选项
|
||||
"-e"一起使用时,可以确保拼接文件时上一个文件的最后一行不会错误地与下一个文件的第一行合并,且不会受到Unicode字节序记号的干扰。
|
||||
例如:
|
||||
|
||||
dos2unix -e -O file1.txt file2.txt > output.txt
|
||||
|
||||
-o, --oldfile 文件 ...
|
||||
旧文件模式。转换并将输出覆盖到源文件。程序默认使用此模式,允许使用通配符。
|
||||
|
||||
在旧文件(替换)模式下,被转换的文件的所有者、组和读/写权限保持不变。当文件被其他具有写权限的用户(如root)转换时,情况也是如此。如
|
||||
果无法保持这些值不变,转换将会终止。改变源文件的所有者可能造成其无法读取该文件,而改变组则可能带来安全隐患,使文件被不法分子读取。只有U
|
||||
nix才支持转换时保留所有者、组和读/写权限。
|
||||
|
||||
若要查看 dos2unix 是否支持保护文件的所有者,请输入"dos2unix -V"。
|
||||
|
||||
dos2unix
|
||||
在转换格式时会生成一个临时文件。如果在转换时出错,它会删除临时文件,从而保证原始文件不被更改;如果转换成功,将用临时文件替换原始文件。在
|
||||
这一过程中,如果 dos2unix
|
||||
无法将临时文件的所有者设置为原始文件的所有者,那么新生成的文件也无法保留原始文件的属主/属组属性(即便您对原始文件有写入权限)。在这种情
|
||||
况下,可以使用"--allow-chown"选项来继续进行转换:
|
||||
|
||||
dos2unix --allow-chown foo.txt
|
||||
|
||||
或者在新文件模式下:
|
||||
|
||||
dos2unix -n foo.txt foo.txt
|
||||
|
||||
使用"--allow-chown"选项的好处在于:您可以使用通配符来操作文件,同时尽可能保持文件的所有者不变。
|
||||
|
||||
-q, --quiet
|
||||
安静模式。不显示任何警告或信息。返回值为0,除非命令行选项有误。
|
||||
|
||||
-r, --remove-bom
|
||||
移除字节序标记(BOM),不写入BOM到输出文件。这是转换到Unix断行符时的默认行为。参见选项 "-b"。
|
||||
|
||||
-s, --safe
|
||||
跳过二进制文件(默认)。
|
||||
|
||||
跳过二进制文件是为了避免可能的错误。请注意,对二进制文件的探测并不能做到100%准确。程序通过扫描二进制文件所特有的标记来将其与文本文件
|
||||
区分开来,但有的二进制文件可能只包含普通的文本字符,这样的文件就会被误判为文本文件。
|
||||
|
||||
By default, no error is returned when a binary file is skipped. When
|
||||
the "--error-binary" option is used, an error is returned.
|
||||
|
||||
-u, --keep-utf16
|
||||
Keep the original UTF-16 encoding of the input file. The output file
|
||||
will be written in the same UTF-16 encoding, little- or big-endian,
|
||||
as the input file. This prevents transformation to UTF-8. An UTF-16
|
||||
BOM will be written accordingly. This option can be disabled with
|
||||
the "-ascii" option.
|
||||
|
||||
-ul, --assume-utf16le
|
||||
假定输入文件格式为UTF-16LE。
|
||||
|
||||
输入文件中有BOM时,将会覆盖此选项。
|
||||
|
||||
如果你做了错误的假设(输入文件不为UTF-16LE格式),并且转换成功,你将会得到一个错误的UTF-8格式的文件。你可以用
|
||||
iconv(1) 来撤销转换,将其从UTF-8转换回UTF-16LE。这样做可以恢复源文件。
|
||||
|
||||
对UTF-16LE的假定将根据 l<转换模式> 来工作。若改变了默认的 l<ascii> 模式,则这一假定将会被关闭。
|
||||
|
||||
-ub, --assume-utf16be
|
||||
假定输入文件格式为UTF-16BE。
|
||||
|
||||
这一选项与 "-ul" 类似。
|
||||
|
||||
-v, --verbose
|
||||
显示更多信息。将会显示有关BOM和转换统计的额外信息。
|
||||
|
||||
-F, --follow-symlink
|
||||
追踪符号链接并转换其目标。
|
||||
|
||||
-R, --replace-symlink
|
||||
将符号链接的目标替换为转换后的文件(原来的目标文件保持不变)。
|
||||
|
||||
-S, --skip-symlink
|
||||
保持符号链接和其目标文件不变(默认)。
|
||||
|
||||
-V, --version
|
||||
显示版本信息,然后退出。
|
||||
|
||||
Mac模式
|
||||
默认情况下断行符将从DOS格式转换为Unix格式,或相反。Mac格式的断行符将不会被转换。
|
||||
|
||||
Mac模式下,Mac断行符将被转换为Unix格式,或相反。DOS断行符将不会被转换。
|
||||
|
||||
若要以Mac模式运行,请使用命令行选项 "-c mac",或使用命令 "mac2unix" 或 "unix2mac"。
|
||||
|
||||
转换模式
|
||||
ascii
|
||||
这是默认转换模式。该模式用于转换ASCII和ASCII兼容编码的文件,例如UTF-8。启用ascii模式会禁用7bit和iso模式。
|
||||
|
||||
如果dos2unix带有UTF-16支持,则UTF-16编码的文件在POSIX系统上将被转换为当前语区对应的字符编码,在Windows上
|
||||
则会被转换为UTF-8。启用 ascii 模式将禁用维持UTF-16编码的选项("-u")和假定输入为UTF-16的选项("-ul" 和
|
||||
"-ub")。如需查看dos2unix是否带有UTF-16支持,请运行 "dos2unix -V"。更多信息另请参见 UNICODE
|
||||
章节。
|
||||
|
||||
7bit
|
||||
在此模式下,所以的8位非ASCII字符(取值范围128-255)将被转换到7位编码空间。
|
||||
|
||||
iso Unix下,将在DOS字符集(编码页)和ISO字符集 ISO-8859-1(Latin-1)之间进行转换。不具有 ISO-8859-1
|
||||
中对等字符的DOS字符将会被转换为点号(“.”)。当 ISO-8859-1 字符集中没有DOS中的对等字符时也是如此。
|
||||
|
||||
当只指定了 "-iso" 选项时,dos2unix将尝试确定当前活动代码页。若无法确定,则使用默认代码页
|
||||
CP437(普遍用于美国)。若要强制指定代码页,请使用选项
|
||||
-437(美国)、-850(西欧)、-860(葡萄牙)、-863(法国、加拿大)或-865(北欧)。 Windows
|
||||
CP1252代码页(西欧)也可以通过选项 -1252 获得支持。若要使用其他代码页,可以结合 iconv(1)
|
||||
使用dos2unix。iconv可以在很多字符编码间进行转换。
|
||||
|
||||
不对Unicode编码文本使用ISO转换。因这一转换会导致UTF-8编码文件损坏。
|
||||
|
||||
一些示例:
|
||||
|
||||
从DOS默认编码页转换到Unix Latin-1:
|
||||
|
||||
dos2unix -iso -n in.txt out.txt
|
||||
|
||||
从DOS CP850转换到Unix Latin-1:
|
||||
|
||||
dos2unix -850 -n in.txt out.txt
|
||||
|
||||
从Windows CP1252转换到Unix Latin-1:
|
||||
|
||||
dos2unix -1252 -n in.txt out.txt
|
||||
|
||||
从WIndows CP1252转换到Unix UTF-8(Unicode):
|
||||
|
||||
iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
|
||||
|
||||
从Unix Latin-1转换到DOS默认编码页:
|
||||
|
||||
unix2dos -iso -n in.txt out.txt
|
||||
|
||||
从Unix Latin-1转换到DOS CP850:
|
||||
|
||||
unix2dos -850 -n in.txt out.txt
|
||||
|
||||
从Unix Latin-1转换到Windows CP1252:
|
||||
|
||||
unix2dos -1252 -n in.txt out.txt
|
||||
|
||||
从Unix UTF-8(Unicode)转换到Windows CP1252:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
|
||||
|
||||
See also <https://czyborra.com/charsets/codepages.html> and
|
||||
<https://czyborra.com/charsets/iso8859.html>.
|
||||
|
||||
UNICODE
|
||||
编码
|
||||
There exist different Unicode encodings. On Unix and Linux Unicode files
|
||||
are typically encoded in UTF-8 encoding. On Windows Unicode text files
|
||||
can be encoded in UTF-8, UTF-16, or UTF-16 big-endian, but are mostly
|
||||
encoded in UTF-16 format.
|
||||
|
||||
转换
|
||||
Unicode文本文件可以含有DOS、Unix或Mac断行符,就像ASCII文本文件一样。
|
||||
|
||||
所有版本的dos2unix和unix2dos都可以转换UTF-8文件,因为UTF-8向后兼容ASCII。
|
||||
|
||||
dos2unix and unix2dos with Unicode UTF-16 support, can read little- and
|
||||
big-endian UTF-16 encoded text files. To see if dos2unix was built with
|
||||
UTF-16 support type "dos2unix -V".
|
||||
|
||||
在Unix/Linux中,UTF-16编码文件将被转换为区域字符编码所指定的编码。可以使用 locale(1)
|
||||
命令来查看当前的区域字符编码。若无法转换,程序将报告转换错误并跳过此文件。
|
||||
|
||||
在Windows中,UTF-16文件被默认转换为UTF-8格式。Windows和Unix/Linux均支持UTF-8格式的文本文件。
|
||||
|
||||
UTF-16和UTF-8编码相互兼容,所以彼此转换时不会丢失文本。倘若转换中出错,比如UTF-16格式的输入文件含有错误,那么该文件将被跳过。
|
||||
|
||||
若使用了 "-u" 选项,输出文件将会使用和输入文件相同的UTF-16编码。"-u"选项将阻止程序转换到UTF-8。
|
||||
|
||||
dos2unix和unix2dos没有用于转换UTF-8到UTF-16的选项。
|
||||
|
||||
ISO和7位编码模式的转换无法用于UTF-16文件。
|
||||
|
||||
字节序标记
|
||||
在Windows中,文本文件一般含有字节序标记(BOM),因为很多Windows程序(包括记事本)默认添加BOM。参见
|
||||
<https://en.wikipedia.org/wiki/Byte_order_mark>。
|
||||
|
||||
在Unix中,Unicode文件一般不含BOM。假定文本文件使用区域字符编码设置所指定的编码。
|
||||
|
||||
dos2unix只能检测含有BOM文件的UTF-16格式。若UTF-16文件不含BOM,dos2unix会将其视作二进制文件。
|
||||
|
||||
请使用选项 "-ul" 或 "-ub" 来转换不含BOM的UTF-16文件。
|
||||
|
||||
dos2unix默认不输出BOM。使用 "-b" 选项可以让dos2unix将BOM添加到输出文件,如果输入文件也含有BOM的话。
|
||||
|
||||
unix2dos默认输出BOM,如果输入文件也含有BOM的话。使用 "-r" 可以移除BOM。
|
||||
|
||||
若使用了 "-m" 选项,dos2unix和unix2dos将总是输出BOM。
|
||||
|
||||
Windows中Unicode文件的文件名
|
||||
dos2unix对于Windows命令提示符中读取和写入Unicode文件名有额外的支持。这意味着dos2unix可以打开那些包含非默认系统AN
|
||||
SI编码页字符的文件。若要查看Windows版dos2unix在编译时是否加入了Unicode文件名支持,请输入 "dos2unix -V"。
|
||||
|
||||
在Windows终端中显示Unicode文件名有一些需要注意的问题。请参见 "-D" 和 "--display-enc"
|
||||
选项。文件名在终端中可能无法被正确显示,但写入文件时文件名仍然是正确的。
|
||||
|
||||
Unicode示例
|
||||
转换Windows UTF-16到Unix UTF-8:
|
||||
|
||||
dos2unix -n in.txt out.txt
|
||||
|
||||
转换Windows UTF-16LE(不含BOM)到Unix UTF-8:
|
||||
|
||||
dos2unix -ul -n in.txt out.txt
|
||||
|
||||
转换Unix UTF-8到Windows UTF-8(并添加BOM):
|
||||
|
||||
unix2dos -m -n in.txt out.txt
|
||||
|
||||
转换Unix UTF-8到Windows UTF-16:
|
||||
|
||||
unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
|
||||
|
||||
GB18030
|
||||
GB18030是中国国家标准。GB18030标准的一系列子集被强制应用于中国销售的软件产品。参见
|
||||
<https://en.wikipedia.org/wiki/GB_18030>。
|
||||
|
||||
GB18030与Unicode完全兼容,并且可以被认为是Unicode格式的变体。和UTF-8一样,GB18030也兼容ASCII。GB1803
|
||||
0也兼容Windows 936代码页(GBK)。
|
||||
|
||||
在Unix/Linux中,若区域编码被设置为GB18030,UTF-16文件将被转换为GB18030格式。注意只有当系统支持区域设置时这一才会进
|
||||
行这一转换。可以使用 "locale -a" 命令来获取受支持的区域。
|
||||
|
||||
在Windows中,你需要使用 "-gb" 选项来转换UTF-16文件到GB18030编码。
|
||||
|
||||
GB18030编码的文件和Unicode文件一样可以含有BOM。
|
||||
|
||||
示例
|
||||
从标准输入读取,并输出到标准输出:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
转换并覆盖a.txt和b.txt:
|
||||
|
||||
dos2unix a.txt b.txt
|
||||
dos2unix -o a.txt b.txt
|
||||
|
||||
转换并覆盖a.txt,使用ascii模式:
|
||||
|
||||
dos2unix a.txt
|
||||
|
||||
转换并覆盖a.txt,使用ascii模式;转换并覆盖b.txt,使用7位编码模式:
|
||||
|
||||
dos2unix a.txt -c 7bit b.txt
|
||||
dos2unix -c ascii a.txt -c 7bit b.txt
|
||||
dos2unix -ascii a.txt -7 b.txt
|
||||
|
||||
将a.txt从Mac格式转换到Unix格式:
|
||||
|
||||
dos2unix -c mac a.txt
|
||||
mac2unix a.txt
|
||||
|
||||
将a.txt从Unix格式转换到Mac格式:
|
||||
|
||||
unix2dos -c mac a.txt
|
||||
unix2mac a.txt
|
||||
|
||||
转换并覆盖a.txt,保留原始时间戳:
|
||||
|
||||
dos2unix -k a.txt
|
||||
dos2unix -k -o a.txt
|
||||
|
||||
转换a.txt,并输出到e.txt:
|
||||
|
||||
dos2unix -n a.txt e.txt
|
||||
|
||||
转换a.txt,并输出到e.txt,同时使e.txt的时间戳和a.txt一致:
|
||||
|
||||
dos2unix -k -n a.txt e.txt
|
||||
|
||||
转换并覆盖a.txt;转换b.txt并输出到e.txt:
|
||||
|
||||
dos2unix a.txt -n b.txt e.txt
|
||||
dos2unix -o a.txt -n b.txt e.txt
|
||||
|
||||
转换c.txt并输出到e.txt;转换并覆盖a.txt和b.txt;转换d.txt并输出到f.txt:
|
||||
|
||||
dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
|
||||
|
||||
递归转换
|
||||
结合 find(1) 和 xargs(1) 使用 dos2unix 可以递归地转换目录树中的文本文件。例如,转换当前目录的目录树中所有的
|
||||
.txt 文件:
|
||||
|
||||
dos2unix < a.txt
|
||||
cat a.txt | dos2unix
|
||||
|
||||
若文件名中有空格或引号,则需要使用 find(1) 选项 "-print0" 及相应的 xargs(1) 选项
|
||||
-0;其他情况下则可以省略它们。也可以结合 "-exec" 选项来使用 find(1):
|
||||
|
||||
find . -name '*.txt' -exec dos2unix {} \;
|
||||
|
||||
在Windows命令提示符中,可以使用下列命令:
|
||||
|
||||
for /R %G in (*.txt) do dos2unix "%G"
|
||||
|
||||
PowerShell用户可以在Windows PowerShell中使用如下命令:
|
||||
|
||||
get-childitem -path . -filter '*.txt' -recurse | foreach-object {dos2unix $_.Fullname}
|
||||
|
||||
区域
|
||||
LANG
|
||||
LANG环境变量指定了程序所使用的首选语言。它包括几个部分:第一部分是小写的语言编码,第二部分是(可选的)大写的国家/地区代码,前面用下
|
||||
划线连接;第三部分也是可选的,即字符编码,前面用点连接。一些POSIX规范的示例如下:
|
||||
|
||||
export LANG=zh 中文
|
||||
export LANG=zh_CN 中文,中国
|
||||
export LANG=zh_TW 中文,台湾
|
||||
export LANG=es_ES 西班牙语,西班牙
|
||||
export LANG=es_MX 西班牙语,墨西哥
|
||||
export LANG=en_US.iso88591 英语,美国,Latin-1编码
|
||||
export LANG=en_GB.UTF-8 英语,英国,UTF-8编码
|
||||
|
||||
完整的语言和国家/地区编码可以在gettext手册中找到:<https://www.gnu.org/software/gettext/m
|
||||
anual/html_node/Usual-Language-Codes.html>
|
||||
|
||||
在Unix系统中,你可以使用 locale(1) 命令获取特定区域的信息。
|
||||
|
||||
LANGUAGE
|
||||
可以使用LANGUAGE变量指定一系列语言的优先级,各项之间由冒号分割。dos2unix首先使用LANGUAGE变量,其次才是LANG。
|
||||
例如,首选中文、其次英文:"LANGUAGE=zh:en"。在使用语言优先级之前,必须先启用区域化功能,即将LANG(或LC_ALL)变
|
||||
量设置为除了“C”以外的其他值。参见gettext手册:<https://www.gnu.org/software/gettext/ma
|
||||
nual/html_node/The-LANGUAGE-variable.html>
|
||||
|
||||
如果你选择了一个不可用的语言,程序将会输出标准的英语信息。
|
||||
|
||||
DOS2UNIX_LOCALEDIR
|
||||
DOS2UNIX_LOCALEDIR环境变量将覆盖编译时设置的LOCALEDIR变量。LOCALEDIR被用于查找语言文件。GNU程序的
|
||||
默认值为 "/usr/local/share/locale"。可以使用 --version 查看当前的LOCALEDIR。
|
||||
|
||||
示例(POSIX shell):
|
||||
|
||||
export DOS2UNIX_LOCALEDIR=$HOME/share/locale
|
||||
|
||||
返回值
|
||||
若成功,返回0。若出现系统错误,则返回最近一次系统错误号。若发生其他错误,返回1。
|
||||
|
||||
在安静模式下,返回值总是为0,除非命令行选项有误。
|
||||
|
||||
遵循规范
|
||||
<https://en.wikipedia.org/wiki/Text_file>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Carriage_return>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Newline>
|
||||
|
||||
<https://en.wikipedia.org/wiki/Unicode>
|
||||
|
||||
作者
|
||||
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben(mac2unix模式)
|
||||
- <wuebben@kde.org>,Christian Wurll(添加额外新行) - <wurll@ira.uka.de>,Erwin
|
||||
Waterlander - <waterlan@xs4all.nl>(维护者)
|
||||
|
||||
Project page: <https://waterlander.net/dos2unix/>
|
||||
|
||||
SourceForge主页:<https://sourceforge.net/projects/dos2unix/>
|
||||
|
||||
参见
|
||||
file(1) find(1) iconv(1) locale(1) xargs(1)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue