Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
717 views
in Technique[技术] by (71.8m points)

linux - Anything like dos2unix for Windows?

I have some shell scripts created on windows I want to run dos2unix on them.

But as I have read that dos2unix works in Linux environment so, is there a way that I can convert my files to UNIX format while working in Windows?

I have already installed CYGWIN but I am facing some issues as

Administrator@SGH735082N ~
$ pwd
/home/Administrator

Administrator@SGH735082N ~
$ cd C:CVS Code

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix BLPDB000
BLPDB000:
dos2Unix processing BLPDB000: No such file or directory

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix -h
dos2Unix: bad argument -h: unknown option

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix --help
dos2Unix version 0.1.3
  converts the line endings of text files from
  DOS style (0x0d 0x0a) to UNIX style (0x0a)

Usage: dos2Unix [OPTION...] [input file list...]

Main options (not all may apply)
  -A, --auto     Output format will be the opposite of the autodetected source
                 format
  -D, --u2d      Output will be in DOS format
  --unix2dos     Output will be in DOS format
  -U, --d2u      Output will be in UNIX format
  --dos2unix     Output will be in UNIX format
  --force        Ignore binary file detection
  --safe         Do not modify binary files

Help options
  -?, --help     Show this help message
  --usage        Display brief usage message
  --version      Display version information
  --license      Display licensing information

Other arguments
  [input file list...]       for each file listed, convert in place.
                             If none specified, then use stdin/stdout

Administrator@SGH735082N /cygdrive/c/CVS
$

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix  -oBLPDB000
dos2Unix: bad argument -oBLPDB000: unknown option

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix -k BLPDB000
dos2Unix: bad argument -k: unknown option

Administrator@SGH735082N /cygdrive/c/CVS
$ dos2Unix BLPDB000.txt
BLPDB000.txt:
dos2Unix processing BLPDB000.txt: No such file or directory

Administrator@SGH735082N /cygdrive/c/CVS
$ pwd
/cygdrive/c/CVS
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use Notepad++.

The instructions to convert a directory recursively are as follows:

  1. Menu: Search -> Find in Files...
  2. Directory = the directory you want to be converted to Unix format, recursively. E.g., C:MyDir
  3. Find what =
  4. Replace with =
  5. Search Mode = Extended
  6. Press "Replace in Files"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...